question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:open
  • Created 3 years ago
  • Reactions:17
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
pictoscommented, Apr 17, 2021

@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 same Image 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 (?)

0reactions
karthikraja-arumugamcommented, Jun 28, 2023

Do we have any workaround for this? We need a notification when the image has been successfully loaded into view.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found