Follow-up related question...
When using a LazyColumn as the content for a Scaffold with enterAlwaysScrollBehavior() - is it possible to reveal the TopAppBar when using automated scrolling? Following the above example, I issue a scroll request with a lanuched effect when the navbaritem is clicked...
Copy code
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = { TopAppBar(scrollBehavior = scrollBehavior, title = {...})
) { paddingValues ->
val state = rememberLazyListState()
LaunchedEffect(...) { state.animateScrollToItem(0) }
LazyColumn(state = state) {...}
}
The scroll position is moved to the top as expected. However, the upwards scroll doesn't seem to trigger the enterAlwaysScrollBehavior for revealing the TopAppBar again
t
Tolriq
07/08/2024, 8:05 AM
Unfortunately no, you need to manuall call the nestedScrollConnection functions to simulate that.
c
Christopher Mederos
07/08/2024, 8:33 AM
ok interesting... so I would want to pass a lambda to my launchedEffect that includes some instruction for the nested connection to consume some scroll?
Don't know the best way with TopAppbar, but if there's a state or other ways to directly control it, then it's better to use that. But faking nestedScroll usually works (I use that for other custom components, but no reason it does not work here too)
👍 1
c
Christopher Mederos
07/08/2024, 8:37 AM
ok nice, that's very helpful!
t
Tolriq
07/08/2024, 8:40 AM
Maybe @Andrey Kulikov knows why manual scroll does not trigger the nestedscrolls.