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

commonMain.moe.tlaster.precompose.navigation.route.GroupRoute.kt Maven / Gradle / Ivy

Go to download

A third-party Jetbrains Compose library with ViewModel, LiveData and Navigation support.

There is a newer version: 1.7.0-alpha03
Show newest version
package moe.tlaster.precompose.navigation.route

internal data class GroupRoute(
    override val route: String,
    val initialRoute: Route,
) : Route {
    fun hasRoute(route: String): Boolean {
        if (this.route == route) {
            return true
        }
        return if (initialRoute is GroupRoute) {
            initialRoute.hasRoute(route)
        } else {
            initialRoute.route == route
        }
    }
}

internal fun GroupRoute.isSceneRoute(): Boolean = if (initialRoute is GroupRoute) {
    initialRoute.isSceneRoute()
} else {
    initialRoute is SceneRoute
}
internal fun Route.isSceneRoute(): Boolean {
    return this is SceneRoute || this is GroupRoute && this.isSceneRoute()
}

internal fun GroupRoute.toSceneRoute(): SceneRoute? = if (initialRoute is GroupRoute) {
    initialRoute.toSceneRoute()
} else {
    initialRoute as? SceneRoute
}

internal fun Route.toSceneRoute(): SceneRoute? {
    return this as? SceneRoute ?: (this as? GroupRoute)?.toSceneRoute()
}

internal fun GroupRoute.isFloatingRoute(): Boolean = if (initialRoute is GroupRoute) {
    initialRoute.isFloatingRoute()
} else {
    initialRoute is FloatingRoute
}
internal fun Route.isFloatingRoute(): Boolean {
    return this is FloatingRoute || this is GroupRoute && this.isFloatingRoute()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy