@@ -16,6 +16,7 @@ import androidx.compose.runtime.getValue
16
16
import androidx.compose.runtime.remember
17
17
import androidx.compose.ui.Modifier
18
18
import androidx.compose.ui.platform.LocalLayoutDirection
19
+ import androidx.navigation.NavDestination.Companion.hasRoute
19
20
import androidx.navigation.compose.currentBackStackEntryAsState
20
21
import androidx.navigation.compose.rememberNavController
21
22
import co.touchlab.kermit.Logger
@@ -43,13 +44,15 @@ fun App(
43
44
val snackbarHostState = remember { SnackbarHostState () }
44
45
45
46
val currentNavEntry by navController.currentBackStackEntryAsState()
46
- val currentRoute = currentNavEntry?.destination?.route
47
- val isMainScreen = MAIN_NAVIGATION_SCREENS .map { it.route }.contains(currentRoute)
47
+ val isMainScreen = MAIN_NAVIGATION_SCREENS .any {
48
+ currentNavEntry?.destination?.hasRoute(it::class ) == true
49
+ }
48
50
49
51
CompositionLocalProvider (
50
- values = dependencies.localeDirection?.invoke()?.let { LocalLayoutDirection provides it }?.let {
51
- arrayOf(LocalSnackbarHostState provides snackbarHostState, it)
52
- } ? : arrayOf(LocalSnackbarHostState provides snackbarHostState),
52
+ values = dependencies.localeDirection?.invoke()?.let { LocalLayoutDirection provides it }
53
+ ?.let {
54
+ arrayOf(LocalSnackbarHostState provides snackbarHostState, it)
55
+ } ? : arrayOf(LocalSnackbarHostState provides snackbarHostState),
53
56
) {
54
57
AppTheme {
55
58
Surface (
@@ -113,17 +116,22 @@ fun App(
113
116
LaunchedEffect (deepLink) {
114
117
when (deepLink) {
115
118
is DeepLink .AddDescriptor -> {
116
- navController.navigate(" add-descriptor/${deepLink.id} " )
119
+ navController.navigate(
120
+ Screen .AddDescriptor (deepLink.id.toLongOrNull() ? : return @LaunchedEffect),
121
+ )
117
122
onDeeplinkHandled()
118
123
}
124
+
119
125
is DeepLink .RunUrls -> {
120
- navController.navigate(Screen .ChooseWebsites (deepLink.url).route )
126
+ navController.navigate(Screen .ChooseWebsites (deepLink.url))
121
127
onDeeplinkHandled()
122
128
}
129
+
123
130
DeepLink .Error -> {
124
131
snackbarHostState.showSnackbar(getString(Res .string.AddDescriptor_Toasts_Unsupported_Url ))
125
132
onDeeplinkHandled()
126
133
}
134
+
127
135
null -> Unit
128
136
}
129
137
}
0 commit comments