commonMain.com.copperleaf.ballast.navigation.internal.BackstackNavigatorImpl.kt Maven / Gradle / Ivy
package com.copperleaf.ballast.navigation.internal
import com.copperleaf.ballast.navigation.routing.Backstack
import com.copperleaf.ballast.navigation.routing.BackstackNavigator
import com.copperleaf.ballast.navigation.routing.Destination
import com.copperleaf.ballast.navigation.routing.Route
import com.copperleaf.ballast.navigation.routing.RouteAnnotation
import com.copperleaf.ballast.navigation.routing.RouterContract
import com.copperleaf.ballast.navigation.routing.UnmatchedDestination
internal class BackstackNavigatorImpl(
private var currentState: RouterContract.State,
private val currentInput: RouterContract.Inputs,
) : BackstackNavigator {
override val backstack: Backstack
get() = currentState.backstack
override fun updateBackstack(block: (Backstack) -> Backstack) {
currentState = currentState.copy(
backstack = block(currentState.backstack)
)
}
override fun matchDestination(destinationUrl: String, extraAnnotations: Set): Destination {
return currentState.routingTable.findMatch(
UnmatchedDestination.parse(destinationUrl, extraAnnotations)
)
}
internal fun applyUpdate(): RouterContract.State {
with(currentInput) {
navigate()
}
return currentState
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy