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(
55
55
composable<Destinations .List > { List () }
56
56
composable<Destinations .Profile > { Profile () }
57
57
modalSheet<Destinations .Modal1 > { Modal1 (navController) }
58
- modalSheet<Destinations .Modal2 > { Modal2 () }
58
+ modalSheet<Destinations .Modal2 > { Modal2 (navController ) }
59
59
bottomSheet<Destinations .BottomSheet > { BottomSheet (navController) }
60
60
}
61
61
ModalSheetHost (
Original file line number Diff line number Diff line change @@ -2,23 +2,38 @@ package dev.hrach.navigation.demo.screens
2
2
3
3
import androidx.compose.foundation.background
4
4
import androidx.compose.foundation.layout.Column
5
+ import androidx.compose.foundation.layout.Spacer
5
6
import androidx.compose.foundation.layout.WindowInsets
6
7
import androidx.compose.foundation.layout.fillMaxSize
8
+ import androidx.compose.foundation.layout.height
7
9
import androidx.compose.foundation.layout.systemBars
8
10
import androidx.compose.foundation.layout.windowInsetsPadding
9
11
import androidx.compose.material3.MaterialTheme
12
+ import androidx.compose.material3.OutlinedButton
10
13
import androidx.compose.material3.Text
11
14
import androidx.compose.runtime.Composable
12
15
import androidx.compose.ui.Modifier
16
+ import androidx.compose.ui.unit.dp
17
+ import androidx.navigation.NavController
18
+ import dev.hrach.navigation.demo.Destinations
13
19
14
20
@Composable
15
- internal fun Modal2 () {
21
+ internal fun Modal2 (navController : NavController ) {
16
22
Column (
17
23
Modifier
18
24
.fillMaxSize()
19
25
.background(MaterialTheme .colorScheme.surface)
20
26
.windowInsetsPadding(WindowInsets .systemBars),
21
27
) {
22
28
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
+ }
23
38
}
24
39
}
Original file line number Diff line number Diff line change @@ -227,8 +227,8 @@ public fun ModalSheetHost(
227
227
}
228
228
}
229
229
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) }
232
232
zIndices
233
233
.filter { it.key != transition.targetState?.id }
234
234
.forEach { zIndices.remove(it.key) }
You can’t perform that action at this time.
0 commit comments