Skip to content

Commit

Permalink
Fix: BottomSheet closes when recomposing in iOS #330 (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
hm-tamim authored Mar 24, 2024
1 parent ab8ed66 commit 02b0877
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.material.contentColorFor
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.ProvidableCompositionLocal
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
Expand Down Expand Up @@ -59,16 +60,16 @@ public fun BottomSheetNavigator(
val coroutineScope = rememberCoroutineScope()
val sheetState = rememberModalBottomSheetState(
initialValue = ModalBottomSheetValue.Hidden,
confirmValueChange = { state ->
if (state == ModalBottomSheetValue.Hidden) {
hideBottomSheet?.invoke()
}
true
},
skipHalfExpanded = skipHalfExpanded,
animationSpec = animationSpec
)

LaunchedEffect(sheetState, sheetState.currentValue) {
if (sheetState.currentValue == ModalBottomSheetValue.Hidden) {
hideBottomSheet?.invoke()
}
}

Navigator(HiddenBottomSheetScreen, onBackPressed = null, key = key) { navigator ->
val bottomSheetNavigator = remember(navigator, sheetState, coroutineScope) {
BottomSheetNavigator(navigator, sheetState, coroutineScope)
Expand Down

0 comments on commit 02b0877

Please sign in to comment.