Chris Miller
10/06/2021, 4:35 PMScaffold
with a TopAppBar
, BottomNavigation
and the content is a Column
containing a LazyColumn
plus a TextField
. When the onscreen keyboard is displayed, I want the TopAppBar
and LazyColumn
to stay where they are, the TextField
to be pushed up to just above the keyboard, and the BottomNavigation
to be hidden. I'm trying to achieve this with accompanist-insets-ui, but haven't been able to figure out how. navigationBarsWithImePadding()
comes close, but results in extra whitespace between the TextField and the keyboard, due to the TextField not being located right at the bottom of the screen when there's no keyboard showing. Any ideas on how I can solve this?Chris Miller
10/06/2021, 4:38 PMAlex Vanyo
10/06/2021, 5:22 PMBottomNavigation
when the IME is visible? Or are you relying on the IME to obscure it?Chris Miller
10/06/2021, 5:22 PMAlex Vanyo
10/06/2021, 5:27 PMChris Miller
10/06/2021, 5:29 PMAlex Vanyo
10/06/2021, 5:34 PMBottomNavigation
is at 100%
when the IME is closed, and 0%
when the IME is open), the math might work out nicely for the TextField
. In that case you might want to use just imePadding()
as well for the TextField
, if the navigation bars are dealt with separatelyChris Miller
10/06/2021, 5:38 PMAlex Vanyo
10/06/2021, 5:58 PMWindowInsets.Type.animationFraction
should allow you to get the underlying animation progressChris Miller
10/06/2021, 6:00 PMChris Miller
10/06/2021, 6:03 PMLocalView.current.rootWindowInsets
in a @Composable, how do I trigger recomposition when the insets change? Or will that happen for me?Alex Vanyo
10/06/2021, 6:08 PMLocalWindowInsets.current.ime
(from accompanist
) you shouldn’t have to worry about recomposition: all of those values will be observable to Compose automatically.
Or in other words, accompanist
manages all of that for you, so you don’t have to use LocalView.current
directlyChris Miller
10/06/2021, 6:08 PMChris Miller
10/06/2021, 6:15 PMif (!LocalWindowInsets.current.ime.isVisible) { }
gives the end result I'm after, but as you insinuated, I'll need to take into account the animation fraction to prevent the UI "jumping". I'll have a crack at that later on, for now I'm off to have some dinner. Many thanks for the help!Stylianos Gakis
10/06/2021, 6:22 PMChris Miller
10/06/2021, 6:23 PMAlex Vanyo
10/06/2021, 6:47 PM