diff --git a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt index 3e2afd8e2..af13abb95 100644 --- a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt +++ b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/AppNavigation.kt @@ -114,6 +114,13 @@ fun AppNavigation( composable { backStackEntry -> val args = backStackEntry.toRoute() + val initialPlatform = + args.initialPlatform?.let { name -> + runCatching { + zed.rainxch.search.presentation.model.SearchPlatformUi + .valueOf(name) + }.getOrNull() + } SearchRoot( onNavigateBack = { navController.navigateUp() @@ -142,7 +149,7 @@ fun AppNavigation( }, viewModel = koinViewModel { - parametersOf(args.initialPlatform) + parametersOf(initialPlatform) }, ) } @@ -170,7 +177,7 @@ fun AppNavigation( onNavigateToSearchByPlatform = { platform -> navController.navigate( GithubStoreGraph.SearchScreen( - initialPlatform = platform.toSearchPlatformUi(), + initialPlatform = platform.toSearchPlatformUi().name, ), ) }, diff --git a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/GithubStoreGraph.kt b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/GithubStoreGraph.kt index 42ceb746c..292292084 100644 --- a/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/GithubStoreGraph.kt +++ b/composeApp/src/commonMain/kotlin/zed/rainxch/githubstore/app/navigation/GithubStoreGraph.kt @@ -1,7 +1,6 @@ package zed.rainxch.githubstore.app.navigation import kotlinx.serialization.Serializable -import zed.rainxch.search.presentation.model.SearchPlatformUi @Serializable sealed interface GithubStoreGraph { @@ -10,7 +9,12 @@ sealed interface GithubStoreGraph { @Serializable data class SearchScreen( - val initialPlatform: SearchPlatformUi? = null, + // String over enum: Compose Navigation's Desktop (`nonAndroid.kt`) + // serializer needs an explicit NavType for non-primitive nav args, + // which enums don't have out of the box. Enum-as-name string keeps + // the contract type-safe at the caller / VM boundary while letting + // the route serialize on every target with no typeMap. + val initialPlatform: String? = null, ) : GithubStoreGraph @Serializable