-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Insets] How to use navigationBarsWithImePadding with Column verticalScroll? #210
Comments
Hmmm, using I think we might be missing a callback from the modifier to know when to call FYI, I think you'll have better luck with laying out from the bottom: Column(
modifier = Modifier
// other modifiers
.verticalScroll(scrollState, reverseScrolling = true),
verticalArrangement = Arrangement.Bottom,
) Laying out from the bottom means that the scroll position should remain the same as the |
Hi, I have an even problematic scenario about managing the same thing. The problem is that, my I could call Do you guys have any idea how to do this? |
I don't think this is supported yet (but I'll ask the team later). I just saw that someone raised this bug which is very related. |
Thanks @chrisbanes |
@qrezet have you find any solution or workaround to your problem |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
The recent @ExperimentalComposeUiApi
fun Modifier.bringIntoViewAfterImeAnimation(): Modifier = composed {
val imeInsets = LocalWindowInsets.current.ime
var focusState by remember { mutableStateOf<FocusState?>(null) }
val relocationRequester = remember { RelocationRequester() }
LaunchedEffect(
imeInsets.isVisible,
imeInsets.animationInProgress,
focusState,
relocationRequester
) {
if (imeInsets.isVisible &&
!imeInsets.animationInProgress &&
focusState?.isFocused == true) {
relocationRequester.bringIntoView()
}
}
relocationRequester(relocationRequester)
.onFocusChanged { focusState = it }
}
var textField by remember { mutableStateOf(TextFieldValue()) }
TextField(
value = textField,
onValueChange = { textField = it },
modifier = Modifier.bringIntoViewAfterImeAnimation()
) It's not perfect, but it should form the basis of a solution. The idea is that each focusable item needs to be responsible for requesting that it is visible when necessary. The only difference from the usual logic is that we need to wait for any IME animations to finish before requesting. Note: |
it doesn't work for me |
@chrisbanes It works with latest 1.0.0, but no effect with latest snapshot version. 😢 |
I think something is currently broken with |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Hello!
What is the best way to handle
Column
verticalScroll
andnavigationBarsWithImePadding
?I have layout like this:
![](https://user-images.githubusercontent.com/469111/108875356-62d16d80-75fd-11eb-924c-bbb6100457e5.png)
When keyboard is shown it looks like this:
What I want to achieve (automatically scroll to given or focused composable when IME is shown) :
I was trying to play with
scrollState.smoothScrollTo
but without any reliable success :(. @chrisbanes do you have any recommendations or best ways of doing so?Code:
The text was updated successfully, but these errors were encountered: