[Spec] ImageSourceHandler
See original GitHub issue[ImageSource]
Create a service that handles the ImageSource logic on shared code based on this discussion between me, @PureWeen, and @mattleibow.
The general idea is to have an ImageSource handler class that will handle all ImageSource updates in the shared layer and reflects them to the Control.
API
[ IImageSourceHandler]
interface IImageSourceHandler
{
ImageSource Current {get;}
ImageSource LoadingPlaceholder {get;}
ImageSource ErrorPlaceholder {get;}
ImageSource Desired {get;}
// Those can be internals
Action OnLoadingStarted {get;}
Action OnSourceChanged {get;}
Action OnLoadingFailed {get;}
Action OnLoadingCompleted {get;}
}
Properties
API | Description |
---|---|
Current | This will be the current ImageSource for displayed Image. |
LoadingPlaceholder | ImageSource that will be presented while we load/download the Desired ImageSource |
ErrorPlaceholder | ImageSource that will be presented if something goes wrong with the Desired ImageSource |
Desired | The ImageSource that the user wants to present in the control |
Events
API | Description |
---|---|
OnLoadingStarted | Action that will be fired when we start to load the Desired ImageSource |
OnSourceChanged | Action that will be fired when Current value changes |
OnLoadingFailed | Action that will be fired when something goes wrong during the Loading process |
OnLoadingCompleted | Action that will be fired when we loaded the Desired ImageSource successfully |
Scenarios
<Image Desired="ImageThatIWant"
LoadingPlaceholder="LoadingTheDesiredSource"
ErrorPlaceholder="ImageIfSomethingGoesWrong" />
Backward Compatibility
Minimum API levels? Breaking changes? Unsupported platforms?
Difficulty: medium
Issue Analytics
- State:
- Created 3 years ago
- Reactions:17
- Comments:11 (8 by maintainers)
Top Results From Across the Web
roubachof/Xamarin.Forms.ImageSourceHandlers: GlideX. ...
ImageSourceHandler = complete image caching solution for Xamarin. ... Forms image source handlers will just be overridden with cache-enabled ...
Read more >FFImageLoading.ImageSourceHandler 1.0.0
This repository was inspired by Jonathan Peppers GlideX implementation of the new IImageViewHandler interface for Xamarin.
Read more >Ultimate Image Caching for Xamarin.Forms
Forms image source handlers will just be overridden with cache-enabled ones. On iOS the ImageSourceHandler is implemented with ...
Read more >FileImageSource Class (Xamarin.Forms)
Gets or sets a value that allows the automation framework to find and interact with this element. (Inherited from Element). BindingContext. Gets or...
Read more >C# (CSharp) ImageLoaderSourceHandler Examples
These are the top rated real world C# (CSharp) examples of ImageLoaderSourceHandler extracted from open source projects. You can rate examples to help...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mattleibow, thinking aloud here.
If inside the ImageSource we have a Stream or byte array that stores the current
Bitmap
(but could be any image file), and if the dev uses it in more than one place all they will see the sameImage File
and the same state (Loading, Loaded, Error, etc).With this approach, we need to care about disposing of that Stream, not sure if this easy to do. Also, making it immutable can reduce the complexity (?)
Do we have any workaround for this? We need a notification when the image has been successfully loaded into view.