Skip to content

Commit

Permalink
Fix #430
Browse files Browse the repository at this point in the history
  • Loading branch information
SapuSeven committed Nov 21, 2023
1 parent 3cc80cc commit 5447e31
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ import kotlinx.coroutines.launch
fun ReportsInfoBottomSheet(reportsDataStore: DataStore<Preferences> = LocalContext.current.reportsDataStore) {
val scope = rememberCoroutineScope()
var bottomSheetVisible by rememberSaveable { mutableStateOf(false) }
val bottomSheetState = rememberStandardBottomSheetState(initialValue = SheetValue.Expanded)
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
var saveEnabled by rememberSaveable { mutableStateOf(true) }

LaunchedEffect(Unit) {
if (reportsDataStore.data.map { prefs ->
prefs[reportsDataStoreBreadcrumbsEnable.first]
}.first() == null) {
bottomSheetVisible = true
bottomSheetState.show()
sheetState.show()
}
}

Expand All @@ -47,8 +47,13 @@ fun ReportsInfoBottomSheet(reportsDataStore: DataStore<Preferences> = LocalConte
modifier = Modifier.fillMaxSize()
) {
ModalBottomSheet(
onDismissRequest = { bottomSheetVisible = false },
sheetState = bottomSheetState,
onDismissRequest = {
scope.launch {
sheetState.hide()
bottomSheetVisible = false
}
},
sheetState = sheetState,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
Expand Down Expand Up @@ -125,9 +130,9 @@ fun ReportsInfoBottomSheet(reportsDataStore: DataStore<Preferences> = LocalConte
?: reportsDataStoreBreadcrumbsEnable.second
}

bottomSheetState.hide()
sheetState.hide()
}.invokeOnCompletion {
if (!bottomSheetState.isVisible) {
if (!sheetState.isVisible) {
bottomSheetVisible = false
}
}
Expand Down

0 comments on commit 5447e31

Please sign in to comment.