Sean Proctor
05/18/2023, 1:27 PMAnimatedVisibility
working. It works fine to hide my composable, but it doesn't show it when visible
changes back to true.Scaffold(
floatingActionButton = {
val showFab = listState.isScrollingUp().value
println("showing fab: $showFab")
AnimatedVisibility(visible = showFab) {
FloatingActionButton(
onClick = {
...
}
) {
Icon(
imageVector = Icons.Default.Add,
contentDescription = "add"
)
}
}
},
...
)
Yves Kalume
05/18/2023, 2:01 PMSean Proctor
05/18/2023, 2:28 PMzokipirlo
05/18/2023, 4:56 PMshowFab
as derivedStateOf
of listState
. Like explained here: https://medium.com/androiddevelopers/jetpack-compose-when-should-i-use-derivedstateof-63ce7954c11b
val isEnabled = remember {
derivedStateOf { lazyListState.firstVisibleItemIndex > 0 }
}
Sean Proctor
05/19/2023, 11:39 AMderivedStateOf
to combine values. I want the FAB to be visible when the user has last scrolled up, so the previous index needs to be remembered.zokipirlo
05/19/2023, 11:50 AMshowFab
before Scaffold
?