File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed
demo/src/main/kotlin/dev/hrach/navigation/demo
modalsheet/src/main/kotlin/dev/hrach/navigation/modalsheet Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ internal fun NavHost(
5555 composable<Destinations .List > { List () }
5656 composable<Destinations .Profile > { Profile () }
5757 modalSheet<Destinations .Modal1 > { Modal1 (navController) }
58- modalSheet<Destinations .Modal2 > { Modal2 () }
58+ modalSheet<Destinations .Modal2 > { Modal2 (navController ) }
5959 bottomSheet<Destinations .BottomSheet > { BottomSheet (navController) }
6060 }
6161 ModalSheetHost (
Original file line number Diff line number Diff line change @@ -2,23 +2,38 @@ package dev.hrach.navigation.demo.screens
22
33import androidx.compose.foundation.background
44import androidx.compose.foundation.layout.Column
5+ import androidx.compose.foundation.layout.Spacer
56import androidx.compose.foundation.layout.WindowInsets
67import androidx.compose.foundation.layout.fillMaxSize
8+ import androidx.compose.foundation.layout.height
79import androidx.compose.foundation.layout.systemBars
810import androidx.compose.foundation.layout.windowInsetsPadding
911import androidx.compose.material3.MaterialTheme
12+ import androidx.compose.material3.OutlinedButton
1013import androidx.compose.material3.Text
1114import androidx.compose.runtime.Composable
1215import androidx.compose.ui.Modifier
16+ import androidx.compose.ui.unit.dp
17+ import androidx.navigation.NavController
18+ import dev.hrach.navigation.demo.Destinations
1319
1420@Composable
15- internal fun Modal2 () {
21+ internal fun Modal2 (navController : NavController ) {
1622 Column (
1723 Modifier
1824 .fillMaxSize()
1925 .background(MaterialTheme .colorScheme.surface)
2026 .windowInsetsPadding(WindowInsets .systemBars),
2127 ) {
2228 Text (" Modal 2" )
29+
30+ Spacer (Modifier .height(32 .dp))
31+ OutlinedButton (
32+ onClick = {
33+ navController.popBackStack<Destinations .Modal1 >(inclusive = true )
34+ },
35+ ) {
36+ Text (" Close modals" )
37+ }
2338 }
2439}
Original file line number Diff line number Diff line change @@ -227,8 +227,8 @@ public fun ModalSheetHost(
227227 }
228228 }
229229 LaunchedEffect (transition.currentState, transition.targetState) {
230- if (transition.currentState == transition.targetState && backStackEntry != null ) {
231- modalSheetNavigator.onTransitionComplete(backStackEntry)
230+ if (transition.currentState == transition.targetState) {
231+ transitionsInProgress.forEach { entry -> modalSheetNavigator.onTransitionComplete(entry) }
232232 zIndices
233233 .filter { it.key != transition.targetState?.id }
234234 .forEach { zIndices.remove(it.key) }
You can’t perform that action at this time.
0 commit comments