2025-12-18 17:30:36 -06:00
# `:core:navigation`
2026-02-20 06:41:52 -06:00
## Overview
2026-03-31 16:25:37 -05:00
The `:core:navigation` module defines the type-safe Navigation 3 route model for Android and Desktop using Kotlin Serialization.
2026-02-20 06:41:52 -06:00
## Key Components
### 1. `Routes.kt`
2026-03-31 16:25:37 -05:00
Contains serializable `NavKey` route classes/objects used by shared feature graphs.
### 2. `DeepLinkRouter.kt`
Parses Meshtastic deep-link URIs and synthesizes a typed backstack (for example `/nodes/1234/device-metrics` ).
### 3. `NavigationConfig.kt`
2026-04-10 10:05:07 -05:00
Defines `MeshtasticNavSavedStateConfig` using sealed interface hierarchies so Navigation 3 backstacks can be persisted/restored safely — new routes are auto-registered at compile time.
2026-02-20 06:41:52 -06:00
## Features
2026-03-31 16:25:37 -05:00
- **Type-Safety**: Uses serializable `NavKey` routes instead of ad-hoc string routes.
- **Deep-link synthesis**: Converts incoming URIs into typed backstacks via `DeepLinkRouter` .
- **Centralized definition**: Routes and saved-state serializers are declared in one place to avoid feature-module cycles.
2026-02-20 06:41:52 -06:00
## Usage
2026-03-31 16:25:37 -05:00
Feature modules depend on this module to define their entry points and navigate via `NavBackStack<NavKey>` .
2026-02-20 06:41:52 -06:00
```kotlin
2026-03-31 16:25:37 -05:00
import androidx.navigation3.runtime.NavBackStack
import androidx.navigation3.runtime.NavKey
2026-04-10 10:05:07 -05:00
import org.meshtastic.core.navigation.NodesRoute
2026-02-20 06:41:52 -06:00
2026-03-31 16:25:37 -05:00
fun openNodeDetail(backStack: NavBackStack< NavKey > , destNum: Int) {
2026-04-10 10:05:07 -05:00
backStack.add(NodesRoute.NodeDetail(destNum))
2026-03-31 16:25:37 -05:00
}
2026-02-20 06:41:52 -06:00
```
2025-12-18 17:30:36 -06:00
## Module dependency graph
<!-- region graph -->
```mermaid
graph TB
2026-03-24 21:15:51 -05:00
:core:navigation[navigation]:::kmp-library-compose
2025-12-18 17:30:36 -06:00
classDef android-application fill:#CAFFBF ,stroke:#000 ,stroke-width:2px,color:#000 ;
classDef android-application-compose fill:#CAFFBF ,stroke:#000 ,stroke-width:2px,color:#000 ;
2026-03-12 22:15:20 -05:00
classDef compose-desktop-application fill:#CAFFBF ,stroke:#000 ,stroke-width:2px,color:#000 ;
2025-12-18 17:30:36 -06:00
classDef android-feature fill:#FFD6A5 ,stroke:#000 ,stroke-width:2px,color:#000 ;
classDef android-library fill:#9BF6FF ,stroke:#000 ,stroke-width:2px,color:#000 ;
classDef android-library-compose fill:#9BF6FF ,stroke:#000 ,stroke-width:2px,color:#000 ;
classDef android-test fill:#A0C4FF ,stroke:#000 ,stroke-width:2px,color:#000 ;
classDef jvm-library fill:#BDB2FF ,stroke:#000 ,stroke-width:2px,color:#000 ;
2026-03-17 16:51:09 -05:00
classDef kmp-feature fill:#FFD6A5 ,stroke:#000 ,stroke-width:2px,color:#000 ;
2026-03-24 21:15:51 -05:00
classDef kmp-library-compose fill:#FFC1CC ,stroke:#000 ,stroke-width:2px,color:#000 ;
2025-12-18 17:30:36 -06:00
classDef kmp-library fill:#FFC1CC ,stroke:#000 ,stroke-width:2px,color:#000 ;
classDef unknown fill:#FFADAD ,stroke:#000 ,stroke-width:2px,color:#000 ;
```
<!-- endregion -->