pref: LaunchedEffect

This commit is contained in:
HuanCheng65 2023-01-06 11:27:17 +08:00
parent 5515e8f457
commit fd8f89153b
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
1 changed files with 13 additions and 9 deletions

View File

@ -184,14 +184,18 @@ fun BlockSettingsPage(
}
) { paddingValues ->
val snackbarHostState = LocalSnackbarHostState.current
LaunchedEffect(null) {
coroutineScope.launch {
viewModel.uiEventFlow
.filterIsInstance<BlockSettingsUiEvent.Success>()
.collect {
snackbarHostState.showSnackbar(when (it) {
snackbarHostState.showSnackbar(
when (it) {
is BlockSettingsUiEvent.Success.Add -> context.getString(R.string.toast_add_success)
is BlockSettingsUiEvent.Success.Delete -> context.getString(R.string.toast_delete_success)
})
}
)
}
}
}
HorizontalPager(