fix: fix top app bar not loading on filter change
This commit is contained in:
parent
ca0734e977
commit
2ee169d7e1
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue