glide
glide copied to clipboard
Feature request: expose rememberGlidePainter function for compose
I would like to propose exposing a rememberGlidePainter() function that returns a Painter that fetches the remote image. This would behave similarly to how it works in Coil via rememberAsyncImagePainter(): https://coil-kt.github.io/coil/compose/#asyncimagepainter
This would allow you to load an image just using a simple Painter that could be rendered using any composable (instead of forcing you to render it via GlideImage).
Without this feature, it becomes very difficult to migrate from coil to glide for example.
+1.
I would also like to request this kind of feature, that would help a lot
https://github.com/bumptech/glide/commit/60b567e5feec70ba810a663e56a10d837f26c56c gives you similar functionality via GlideSubcomposition.
There is still no direct equivalent of rememberAsyncPainter. I'm curious to hear more about that use case - when do you need the painter rather than a subcomposition in Coil?
We can provide similar functionality by exposing GlideNode directly (see the PR), but that's not done yet.
@sjudd Thanks for the response. My thinking was that it would be nice to provide a Painter instead of a composable in the same way that libraries typically would provide a Drawable-based API instead of a View-based API... in the same way that Drawables grant you more flexibility than a View, having the ability to work with an arbitrary Painter sounded like it would enable you to use it however you want in any API that works with a Painter.
I see GlideSubcomposition will provide this painter as part of the scope though so this might be good enough. If the recommendation is coming from the compose team that you shouldn't provide a rememberGlidePainter() function then I trust their judgement. :)
I completely agree with this suggestion. I've been searching for this feature and encountered the same situation – it's available in Coil but not in Glide. Having this functionality in Glide would be a great idea .
Exposing a Painter would help us draw the image directly into a draw scope. We had a case where we wanted to have a press Indication based on an image loaded via Glide. Indication gives us a draw scope, we couldn't find a way of working with the image loaded by Glide directly. Our Indication had to report back the value so we could then animate the UI node.