fix: fix top app bar not loading on filter change

This commit is contained in:
Stefan Schüller 2022-02-04 23:47:05 +01:00
parent ca0734e977
commit 2ee169d7e1
1 changed files with 21 additions and 18 deletions

View File

@ -59,24 +59,6 @@ fun VideoListScreen(
val context = LocalContext.current
// Events
LaunchedEffect(key1 = true) {
viewModel.eventFlow.collectLatest { event ->
when(event) {
is VideoListViewModel.UiEvent.ScrollToTop -> {
listState.scrollToItem(index = 0)
}
is VideoListViewModel.UiEvent.ShowToast -> {
Toast.makeText(
context,
event.message,
event.length
).show()
}
}
}
}
// Auto hide top appbar
val toolBarHeight = 56.dp
val toolBarHeightPx = with(LocalDensity.current) { toolBarHeight.roundToPx().toFloat()}
@ -92,6 +74,27 @@ fun VideoListScreen(
}
}
// Events
LaunchedEffect(key1 = true) {
viewModel.eventFlow.collectLatest { event ->
when(event) {
is VideoListViewModel.UiEvent.ScrollToTop -> {
listState.scrollToItem(index = 0)
// reset toolbar to visible
toolBarOffsetHeightPx.value = 0f
}
is VideoListViewModel.UiEvent.ShowToast -> {
Toast.makeText(
context,
event.message,
event.length
).show()
}
}
}
}
Box(
Modifier
.fillMaxSize()