I try to wrap my head around the best approach to ...
# compose
s
I try to wrap my head around the best approach to modify https://github.com/mxalbert1996/Zoomable to include a sticky zoom feature - so that multiple images in a HorizontalPager sync their scale & translation. The ZoomableState can't be shared across multiple Zoomable instances because aside the scale, translationX & translationY I want to sync it contains the bounds, size of parent & children. The difficulty here is that I want to use HorizontalPager with
beyondBoundsPageCount = 1
to avoid black flicker (due to loading) on changing the image. If this wasn't the problem I could simply use the constructor and provide the old scale & translation as input. So I was thinking if using MutableStateFlow for these values would help. But to collect them I need to coroutine inside. Maybe I'm thinking to complicated here. My first workaround attempt to just use a LaunchedEffect() on the interesting ZoomableState values and update the other ZoomableState I hold in a list was not succesful. I don't understand why. Maybe it's time to ask smarter people for their ideas. 😅
1
a
translationX & translationY I want to sync it contains the bounds, size of parent & children
Do you mean the parent/child sizes of your images are different? How would you expect the translation to be synced if that’s the case?
s
The parent sizes will be the same, but the child sizes may differ. If the translation would be out of bounds the updateBounds() method will fix that.
The sticky Zoom feature is present in Narrative Select, Mylio and surely a bunch of other apps. Usually the pictures people compare have the same dimensions. It’s useful to do closeup checks on eyes for example.
Thank you a lot for solving this for me, Albert! 🙂
snapshotFlow
looks very interesting. I think I need to spent some time studying it. 😄 For the others: Albert sent me this gist. This will make the Ashampoo Photo Organizer experience so much better. 😍
👍 1
s
out of curiosity, what does this look like in practice? I installed mylio, but I don't see the zoom values sticking across photos.
s
In Mylio it’s not a default. You need to enable sticky zoom in the settings. Narrative Select has this as unchangeable default - and Ashampoo Photo Organizer will, too. Maybe I will improve over Mylio & Narrative Select if I only keep the zoom if two photos have the same dimensions. It makes a lot of sense comparing two shots of a burst for details, but maybe not so much if dimensions change. But that’s fine-tuning.
s
Hmmm I can't seem to find the option to turn on sticky zoom in mylio. Any chance you can share a screen recording? Their app is so overwhelming to navigate...
s
I agree. Mylio is powerful, but has a very bad UX. My goal with Ashampoo Photo Organizer is basically to craft a combination of Narrative Select & Mylio with good UX. 😄 Let me search for that function in Mylio… I also forgot. 🫣
Here you go. 🙂
s
this is super helpful, thank you! ❤️ I've been wanting to add support for initial zoom & pan in my own library for a while. this is a good motivation to do so.
👍 1
s
Alberts Zoomable is great, it serves me well. 🙂
s
it's also funny that the option to enable sticky zoom is completely absent on my phone. I wonder if they're only showing it for large screens.
s
Maybe the performance could be increased on animated zooming. I feel that it’s sometimes a bit laggy on the JVM. But I don’t understand Compose good enough to actually tweak it. 👀
it's also funny that the option to enable sticky zoom is completely absent on my phone. I wonder if they're only showing it for large screens.
Interesting. 🤔
You are right, it’s not present on my iPhone, too. But since there is a filmstrip it would be possible to compare two pictures like this. There are a lot of strange things about Mylio. I never understood why it can’t embed metadata on mobile or why it won’t write them back to system photos. Ashampoo Photo Organizer has identical features on all platforms like people would expect. The only thing that differs so far is that embedding metadata on mobile is always on, because the system photo apps don’t recognize XMP sidecars and this confuses people. I don’t see why sticky zoom should not work mobile.
Okay, also not present on iPad. Maybe they use different technologies and one doesn’t support sticky zoom. 🤷‍♂️
s
haha 😄 > Maybe the performance could be increased on animated zooming irrc albert's code is quite optimized, so I wonder if it's compose multiplatform that isn't super performant yet. does the performance improve for smaller photos?
👍 1
s
Yes, smaller photos are better. But also on an older Android device (Galaxy Tab S6 Lite) a lag is noticeable compared to the system app.
👍 1
Could be a indeed a Compose issue.