watchosMain.dev.programadorthi.routing.darwin.UIKitUINavigationController.ios.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of uikit Show documentation
Show all versions of uikit Show documentation
An extensible and multiplatform routing system powered by Ktor
The newest version!
package dev.programadorthi.routing.darwin
import platform.Foundation.NSCoder
import platform.WatchKit.WKInterfaceController
// All credits to: https://stackoverflow.com/a/50191172
public actual class UIKitUINavigationController actual constructor(coder: NSCoder) : WKInterfaceController() {
private val controllers = mutableListOf()
private val topController: WKInterfaceController?
get() = controllers.lastOrNull()
public actual fun viewControllers(): List {
return controllers.toList()
}
public actual fun popViewControllerAnimated(animated: Boolean): UIKitUIViewController? {
return controllers.removeLastOrNull()
}
public actual fun popToViewController(
viewController: UIKitUIViewController,
animated: Boolean,
): List? {
controllers.removeAll { it == viewController }
return controllers
}
public actual fun pushViewController(
viewController: UIKitUIViewController,
animated: Boolean,
) {
controllers += viewController
}
public actual fun setViewControllers(
viewControllers: List,
animated: Boolean,
) {
controllers.clear()
controllers += viewControllers
}
}