URL with size parameters - how to implement without subcomposition #1772
Unanswered
pavelsidyakin-warnermedia
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Assume that remote image URLs can have size parameters - to load an image of the exact size as the target view.
Examples: https://fpoimg.com, https://placekitten.com/ etc.
So, we need to pass the size of a view to the request.
This can be easily achieved using
BoxWithConstraints
.Example with BoxWithConstraints
However, since
BoxWithConstraints
is implemented overSubcomposeLayout
, it has limitations, like we cannot use intrinsic measurements for the parent. Example use-case - a text with background: background should befillMaxSize
and for the parent we can use intrinsic size.I want to implement an async image container without using
SubcomposeLayout
.Here is a try
Full sample is here:
https://github.com/PavelSidyakin/Coil-Size-Url-Parameters-Demo
But it doesn't work correctly - when the view's size changes, the image is just scaled and an image with the new size is not requested.
Current result:
Expected result: the views with and without subcomposition behave the same - an image with a new size is requested and displayed.
Beta Was this translation helpful? Give feedback.
All reactions