Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private fun BottomSheetHost(
val destination = targetBackStackEntry?.destination as? BottomSheetNavigator.Destination
val sheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = destination?.skipPartiallyExpanded ?: true,
confirmValueChange = { destination?.confirmValueChange ?: true },
)

@Suppress("ProduceStateDoesNotAssignValue") // false positive
Expand Down Expand Up @@ -175,7 +176,10 @@ private fun BottomSheetHost(
scrimColor = scrimColor,
dragHandle = dragHandle,
contentWindowInsets = contentWindowInsets,
properties = ModalBottomSheetProperties(securePolicy = destination.securePolicy),
properties = ModalBottomSheetProperties(
securePolicy = destination.securePolicy,
shouldDismissOnBackPress = destination.shouldDismissOnBackPress,
),
) {
LaunchedEffect(backStackEntry) {
navigator.onTransitionComplete(backStackEntry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class BottomSheetNavigator : Navigator<BottomSheetNavigator.Destination>(
internal val content: @Composable (NavBackStackEntry) -> Unit,
) : NavDestination(navigator), FloatingWindow {
internal var securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit
internal var shouldDismissOnBackPress: Boolean = true
internal var confirmValueChange: Boolean = true
internal var skipPartiallyExpanded: Boolean = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public class BottomSheetNavigatorDestinationBuilder :
private val content: @Composable (NavBackStackEntry) -> Unit

public var securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit
public var shouldDismissOnBackPress: Boolean = true
public var skipPartiallyExpanded: Boolean = true
public var confirmValueChange: Boolean = true

/**
* DSL for constructing a new [BottomSheetNavigator.Destination]
Expand Down Expand Up @@ -66,6 +68,8 @@ public class BottomSheetNavigatorDestinationBuilder :
return super.build().also { destination ->
destination.securePolicy = securePolicy
destination.skipPartiallyExpanded = skipPartiallyExpanded
destination.confirmValueChange = confirmValueChange
destination.shouldDismissOnBackPress = shouldDismissOnBackPress
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public inline fun <reified T : Any> NavGraphBuilder.bottomSheet(
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
deepLinks: List<NavDeepLink> = emptyList(),
securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
shouldDismissOnBackPress: Boolean = true,
skipPartiallyExpanded: Boolean = true,
confirmValueChange: Boolean = true,
noinline content: @Composable (NavBackStackEntry) -> Unit,
) {
destination(
Expand All @@ -28,7 +30,9 @@ public inline fun <reified T : Any> NavGraphBuilder.bottomSheet(
deepLink(deepLink)
}
this.securePolicy = securePolicy
this.shouldDismissOnBackPress = shouldDismissOnBackPress
this.skipPartiallyExpanded = skipPartiallyExpanded
this.confirmValueChange = confirmValueChange
},
)
}
Expand All @@ -38,7 +42,9 @@ public fun NavGraphBuilder.bottomSheet(
arguments: List<NamedNavArgument> = emptyList(),
deepLinks: List<NavDeepLink> = emptyList(),
securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
shouldDismissOnBackPress: Boolean = true,
skipPartiallyExpanded: Boolean = true,
confirmValueChange: Boolean = true,
content: @Composable (backstackEntry: NavBackStackEntry) -> Unit,
) {
destination(
Expand All @@ -54,7 +60,9 @@ public fun NavGraphBuilder.bottomSheet(
deepLink(deepLink)
}
this.securePolicy = securePolicy
this.shouldDismissOnBackPress = shouldDismissOnBackPress
this.skipPartiallyExpanded = skipPartiallyExpanded
this.confirmValueChange = confirmValueChange
},
)
}