How wokdsem/kioto works
Project Type and Purpose
• This is a Kotlin Multiplatform library (Kioto) plus a sample “example” app demonstrating its usage on Android and iOS.
• Kioto provides a lightweight, opinionated UI/navigation framework for Compose Multiplatform Mobile, enforcing clean architecture via Nodes, NodeViews, NodeTokens, and a central NodeNav.
High-level Components
a. Kioto Library Module (“kioto/” folder)
• commonMain: Core abstractions – Node, NodeNav, NodeView, NodeToken, Context, Compose integration
• androidMain: Android-specific hosts and Platform.android.kt (NodeHost composable)
• iosMain: iOS-specific hosts and Platform.ios.kt (nodeHost UIViewController)
b. Sample Application Module (“example/” folder)
• commonMain: example business logic and features built on Kioto (Demo, Movies, Navigation features)
• androidMain: Android app entry point (MainActivity + AndroidManifest + resources)
• iosMain (exampleIOs/iosApp): iOS app project (Xcode files, Info.plist, SwiftUI UIViewControllerRepresentable)
c. Build & Configuration
• Gradle Kotlin DSL (build.gradle.kts, settings.gradle.kts, libs.versions.toml, gradle wrapper)
• exampleIOs Xcode configuration files (Config.xcconfig, pbxproj)
Relationships and Data Flow
1. At app launch (Android MainActivity or iOS UIViewController), an instance of NodeNav is created and configured with a root Token (e.g., Demo.Token).
2. NodeHost (Android) or nodeHost (iOS) renders a Compose tree that listens to NodeNav.
3. NodeNav drives a stack of Nodes; each Node is instantiated via its NodeToken (node() factory), holds its own State, subscribes to suspend/flow sources, and exposes a NodeView.
4. NodeView (a @Composable on Android or Swift-wrapped on iOS) renders UI for that Node’s State and invokes listener callbacks for events.
5. Callbacks call nav.navigate / nav.resetNavigation / presentStack / etc., which mutate the NodeNav stack. NodeNav emits new Node sequences, NodeHost recomposes accordingly.
6. Context and CompositionLocals (LocalPlatform, LocalNodeNavigation) flow down the Compose tree, allowing Nodes to retrieve dependencies (e.g., Logger).
Architectural Patterns & Design Principles
• Modular Node pattern: each UI screen is a Node (state + logic) + NodeView (UI) + NodeToken (factory glue).
• Centralized Navigation: NodeNav maintains a stack-of-stacks model, supporting push, pop, replace, present, and back gestures.
• Separation of concerns:
• Domain/data lives in commonMain of both kioto and example modules
• UI rendering lives in NodeView classes under commonMain + platform hosts in androidMain/iosMain
• Platform integration isolated in androidMain/iosMain of kioto
• Multiplatform consistency: shared API across Android and iOS, platform entry points only differ in host composables.