Is it possible to know the ime padding before the ...
# compose
a
Is it possible to know the ime padding before the ime is shown ? would be cool to use the keyboard as source of truth for animations.
1
j
cc @Sean McQuillan [G]
s
Your best bet for accurate information is insets https://github.com/chrisbanes/accompanist/tree/main/insets
a
is it possible to know the insets padding of ime before the ime is shown ? so i could interpolate other animation depending on the max ime padding, when the keyboard becomes visible
s
Not sure what's possible. maybe @cb ^
a
thats a nice blogpost, i didnt see it before. But as i get its also reacting to the changing padding, like the accompanist abstraction. I guess what i had in mind is not possible yet. Maybe one day 🤞
c
Can you go into more detail of what you want to do?
Sounds a bit like you’re trying to implement transition?
a
I basically just want a float from 0 to 1, which is updating while the keyboard animates in or out. keyboard completely visible would be 1 and invisible would be 0. My use case is I want to drive this animations based on the state of the keyboard animation. https://twitter.com/SophosAdriano/status/1366418357646483462?s=19
c
Ah, well the
WindowInsetsAnimation
APIs have exactly that: https://developer.android.com/reference/android/view/WindowInsetsAnimation#getFraction()
You'll need to do all of wiring up yourself right now, although I could expose this value in Accompanist.
Thinking about it, I should probably expose both the 'animated' insets, the 'layout' insets, and the animated progress. For this example, you'd only want the 'layout' insets and the progress
a
awesome 🎉 looking forward to dig into that, thank you 🙏
c
FYI, this landed in Accompanist 0.7.0. You can now fetch the layout insets, animation insets, and the fraction/progress: https://github.com/google/accompanist/pull/242
🎉 1
🙏 1