@@ -66,21 +66,19 @@ actual fun NavHost(
66
66
67
67
// Find the ComposeNavigator, returning early if it isn't found
68
68
// (such as is the case when using TestNavHostController)
69
- val composeNavigator = navController.navigatorProvider.get< Navigator < out NavDestination >>(
70
- ComposeNavigator .NAME
71
- ) as ? ComposeNavigator ? : return
69
+ val composeNavigator =
70
+ navController.navigatorProvider.get< Navigator < out NavDestination >>( ComposeNavigator .NAME )
71
+ as ? ComposeNavigator ? : return
72
72
73
73
// val currentBackStack by composeNavigator.backStack.collectAsState()
74
74
75
- // BackHandler(currentBackStack.size > 1) {
76
- // navController.popBackStack()
77
- // }
75
+ // `progress`, `isPredictiveBack`, etc.
78
76
79
77
/*
80
78
DisposableEffect(lifecycleOwner) {
81
79
// Setup the navController with proper owners
82
80
navController.setLifecycleOwner(lifecycleOwner)
83
- onDispose { }
81
+ onDispose {}
84
82
}
85
83
*/
86
84
@@ -100,6 +98,13 @@ actual fun NavHost(
100
98
val backStackEntry: NavBackStackEntry ? = visibleEntries.lastOrNull()
101
99
102
100
if (backStackEntry != null ) {
101
+ // TODO remove this if not needed
102
+ DisposableEffect (true ) {
103
+ onDispose {
104
+ visibleEntries.forEach { entry -> composeNavigator.onTransitionComplete(entry) }
105
+ }
106
+ }
107
+
103
108
// `fillMaxSize` is added here to make the Box align to the size of its parent
104
109
// TODO consider adding a version of `NavHost` without `modifier` and `contentAlignment`
105
110
// Originally it was `transition.AnimatedContent` here.
@@ -110,8 +115,9 @@ actual fun NavHost(
110
115
// while in the scope of the composable, we provide the navBackStackEntry as the
111
116
// ViewModelStoreOwner and LifecycleOwner
112
117
currentEntry?.LocalOwnersProvider(saveableStateHolder) {
113
- (currentEntry.destination as ComposeNavigator.Destination)
114
- .content(currentEntry)
118
+ (currentEntry.destination as ComposeNavigator.Destination).content(
119
+ currentEntry
120
+ )
115
121
}
116
122
*/
117
123
currentEntry?.let {
@@ -120,19 +126,18 @@ actual fun NavHost(
120
126
}
121
127
}
122
128
129
+ // TODO remove this if not needed
123
130
DisposableEffect (true ) {
124
131
onDispose {
125
- visibleEntries.forEach { entry ->
126
- composeNavigator.onTransitionComplete(entry)
127
- }
132
+ visibleEntries.forEach { entry -> composeNavigator.onTransitionComplete(entry) }
128
133
}
129
134
}
130
135
}
131
136
132
137
/*
133
- val dialogNavigator = navController.navigatorProvider.get<Navigator<out NavDestination>>(
134
- DialogNavigator.NAME
135
- ) as? DialogNavigator ?: return
138
+ val dialogNavigator =
139
+ navController.navigatorProvider.get<Navigator<out NavDestination>>( DialogNavigator.NAME)
140
+ as? DialogNavigator ?: return
136
141
137
142
// Show any dialog destinations
138
143
DialogHost(dialogNavigator)
0 commit comments