All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.app.softwork.routingcompose.DelegateRouter.kt Maven / Gradle / Ivy

Go to download

A multiplatform library for routing to use with JetPack Compose Web, HTML and Desktop

There is a newer version: 0.4.0
Show newest version
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)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy