Made some updates to Voyant. It now supports comp...
# feed
k
Made some updates to Voyant. It now supports compose navigation along with voyager 🧭 . Fixes: Material theme is now correctly applied to all the child view controllers https://github.com/Kashif-E/Voyant
👏 3
f
Wow! Amazing work! I saw you library and thought to migrate to Voyager just for that. But now it's just amazing! I'll give it a try! Thank you so much!
K 1
Update: I'm getting
NavigationController is null
and a crash on Android. Is there something that I might be doing wrong? My 2 screens look like this ( just changed the name for the second)
Copy code
object MovieScreenRoute : VoyantRoute {
    @Composable
    override fun content() {
        val navController = rememberKMPNavController()
        Box(modifier = Modifier.fillMaxSize()) {
            Text(
                "Movie Screen",
                modifier = Modifier.padding(16.dp).align(Alignment.Center).clickable {
                    navController.navigate(MovieDetailsScreenRoute)
                })
        }
    }
}
My Entrypoint:
Copy code
val navController = rememberNavController()
            NavHost(navController = navController, startDestination = MovieScreenRoute) {
                composable<MovieScreenRoute> { backStackEntry ->
                    val searchDomainModel = backStackEntry.toRoute<MovieScreenRoute>()
                    searchDomainModel.content()
                }
                composable<MovieDetailsScreenRoute> { navBackStackEntry ->
                    val movieDetailsScreenRoute = navBackStackEntry.toRoute<MovieDetailsScreenRoute>()
                    movieDetailsScreenRoute.content()
                }
            }
k
This looks good, i dont have access to my laptop at the moment will update once i get back
Can you share stacktrace? Is the project on github?
f
On iOS I just get
NavigationController is null
While on Android it crashes, my compose and compose-navigation version are
1.7.0-beta01
Copy code
Process: com.feernandooff.chronoguides, PID: 938
                                                                                                     java.lang.IllegalStateException: You must call setGraph() before calling getGraph()
                                                                                                     	at androidx.navigation.NavController.getGraph(NavController.kt:103)
                                                                                                     	at androidx.navigation.NavController.generateRouteFilled(NavController.kt:1656)
                                                                                                     	at androidx.navigation.NavController.navigate(NavController.kt:2421)
                                                                                                     	at androidx.navigation.NavController.navigate$default(NavController.kt:2416)
                                                                                                     	at com.kashif.voyant_navigation_compose.AndroidNavController.navigate(Extensions.android.kt:10)
                                                                                                     	at feature.settings.MovieScreenRoute.content$lambda$2$lambda$1$lambda$0(SettingsScreen.kt:86)
                                                                                                     	at feature.settings.MovieScreenRoute.$r8$lambda$1cIKXxKGeI1xTtqiPBB0tKQ7N4Q(Unknown Source:0)
                                                                                                     	at feature.settings.MovieScreenRoute$$ExternalSyntheticLambda1.invoke(Unknown Source:2)
                                                                                                     	at androidx.compose.foundation.ClickableNode$clickPointerInput$3.invoke-k-4lQ0M(Clickable.kt:639)
k
are you using swift ui or uikit on ios side
f
I'm using Compose Multiplatfrom, so I'm mounting the App Composable on Swift trough SwiftUI
k
Oh now i get it, there’s an extra step for swift ui ill update the readme. Apologies for my ignorance
@Fernando I have updated the readme for usage inside swift ui, you should be able to fix the issue after adding the necessary code.
f
Hey @Kashismails It works wonders on iOS now! Thank you very much for your help! However on Android it is still crashing with the log that I posted before, is there soemthing I should do on Android to make it work? 👀
Copy code
java.lang.IllegalStateException: You must call setGraph() before calling getGraph()
                                                                                                     	at androidx.navigation.NavController.getGraph(NavController.kt:103)
                                                                                                     	at androidx.navigation.NavController.generateRouteFilled(NavController.kt:1656)
                                                                                                     	at androidx.navigation.NavController.navigate(NavController.kt:2421)
k
This is related to android navigation let me check this as well, can you share the complete code of nav graph?
f
Sure. Main App:
Copy code
fun koinConfiguration() = koinApplication {
    modules(sharedModule())
}

@Composable
fun App() {
    KoinApplication(application = { koinConfiguration() }) {
        ChronoGuidesTheme {

            val navController = rememberNavController()
            NavHost(navController = navController, startDestination = MovieScreenRoute) {
                composable<MovieScreenRoute> { backStackEntry ->
                    val searchDomainModel = backStackEntry.toRoute<MovieScreenRoute>()
                    searchDomainModel.content()
                }
                composable<MovieDetailScreenRoute> { navBackStackEntry ->
                    val movieDetailsScreenRoute = navBackStackEntry.toRoute<MovieDetailScreenRoute>()
                    movieDetailsScreenRoute.content()
                }
            }

        }
    }
}
Screens:
Copy code
@Serializable
object MovieScreenRoute : VoyantRoute {
    @Composable
    override fun content() {
        val navController = rememberKMPNavController()
        Box(modifier = Modifier.fillMaxSize()) {
            Button(onClick = {}) {
                Text("Button")
            }
            Text(
                "Movie Screen",
                modifier = Modifier.padding(16.dp).align(Alignment.Center).clickable {
                    navController.navigate(MovieDetailScreenRoute)
                })
        }
    }
}

@Serializable
object MovieDetailScreenRoute : VoyantRoute {
    @Composable
    override fun content() {
        val navController = rememberKMPNavController()
        Box(modifier = Modifier.fillMaxSize()) {
            Text(
                "Detail Screen",
                modifier = Modifier.padding(16.dp).align(Alignment.Center).clickable {
                    navController.navigate(MovieScreenRoute)
                })
        }
    }
}
Libraries:
Copy code
compose-version = "1.7.0-beta02"
compose-navigation = "2.8.0-alpha10"

material-navigation = { module = "org.jetbrains.compose.material:material-navigation", version.ref = "compose-version" }
navigation-compose = { module = "org.jetbrains.androidx.navigation:navigation-compose", version.ref = "compose-navigation" }
@Kashismails Let me know if I can be of any help and again, thank you so much for your work
Btw, is there a way to use a bottom sheet with Navigation Compose or is only a feature of voyager? 👀
k
For now no, but i am figuring out the best way to use the material3 version
can you try upgrading to
1.7.0-rc01
f
I'll give it a try!
Thanks
k
found the issue needs a fix, will update here once done
@Fernando i have published a new release and made some updates to the existing APIs try now it should be working. do read the README
f
Sorry! Thanks @Kashismails I'll give it a try.
👍 1