Skip to content

UIKit Integration

Thiago Santos edited this page Aug 18, 2024 · 1 revision

Important

This module is a case of studies that shows how you can extend Kotlin Routing to your context.

This module provides a way to work with UIKit UIViewControllers and route to them.

sourceSets { iosMain.dependencies { implementation("dev.programadorthi.routing:uikit:$version") } }

Install UIKit plugin

Installing the UIKit plugin needs to provide a UINavigationController.

import dev.programadorthi.routing.darwin.UIKitPlugin // ... val router = routing { install(UIKitPlugin) { navigationController = YourUINavigationControllerInstance } }

Define controller handlers

val router = routing { controller(path = "...") { YourUIControllerInstance } }

Push a Controller

router.call(uri = "...", routeMethod = RouteMethod.Push)

Replace a Controller

router.call(uri = "...", routeMethod = RouteMethod.Replace)

Replace all Controllers

router.call(uri = "...", routeMethod = RouteMethod.ReplaceAll)

Pop a Controller

router.popController() // or animated router.popController(animated = true)

Type-safe and other improvements are on the road.

Clone this wiki locally