Skip to content

Commit

Permalink
Reset settings navigation when dismiss
Browse files Browse the repository at this point in the history
  • Loading branch information
StaehliJ committed Aug 16, 2023
1 parent 1911c9e commit 70f158a
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,29 @@ fun DemoPlayer(
) {
val bottomSheetNavigator = rememberBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)
LaunchedEffect(bottomSheetNavigator.navigatorSheetState.isVisible) {
if (!bottomSheetNavigator.navigatorSheetState.isVisible) {
navController.popBackStack(route = RoutePlayer, false)
}
}
ModalBottomSheetLayout(
modifier = modifier,
bottomSheetNavigator = bottomSheetNavigator
) {
NavHost(navController, startDestination = "player") {
NavHost(navController, startDestination = RoutePlayer) {
composable(route = "player") {
PlayerContent(
player = player,
pictureInPicture = pictureInPicture,
pictureInPictureClick = pictureInPictureClick,
displayPlaylist = displayPlaylist,
) {
navController.navigate(route = "settings") {
navController.navigate(route = RouteSettings) {
launchSingleTop = true
}
}
}
bottomSheet(route = "settings") {
bottomSheet(route = RouteSettings) {
LaunchedEffect(pictureInPicture) {
if (pictureInPicture) {
navController.popBackStack()
Expand Down Expand Up @@ -125,3 +130,6 @@ private fun FullScreenMode(fullScreen: Boolean) {
systemUiController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}

private const val RoutePlayer = "player"
private const val RouteSettings = "settings"

0 comments on commit 70f158a

Please sign in to comment.