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

watchosMain.dev.programadorthi.routing.darwin.UIKitUINavigationController.ios.kt Maven / Gradle / Ivy

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
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy