commonMain.app.softwork.routingcompose.DelegateRouter.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of routing-compose-jvm Show documentation
Show all versions of routing-compose-jvm Show documentation
A multiplatform library for routing to use with JetPack Compose Web, HTML and Desktop
package app.softwork.routingcompose
internal class DelegateRouter(val basePath: String, val router: Router) : Router by router {
override fun navigate(to: String, hide: Boolean) {
when {
to.startsWith("/") -> {
router.navigate(to, hide)
}
basePath == "/" -> {
router.navigate("/$to", hide)
}
to.startsWith(".") -> {
val newPath = router.currentPath.relative(to)
router.navigate(newPath.path)
}
else -> {
router.navigate("$basePath/$to", hide)
}
}
}
}