https://github.com/androidbroadcast/navstate
https://github.com/androidbroadcast/navstate
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/androidbroadcast/navstate
- Owner: androidbroadcast
- License: apache-2.0
- Created: 2024-05-24T16:06:18.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-10T12:22:26.000Z (over 1 year ago)
- Last Synced: 2025-05-05T03:18:55.313Z (about 1 year ago)
- Language: Kotlin
- Size: 199 KB
- Stars: 23
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
NavState
========
# ‼️ WORK IN PROGRESS ‼️
NavState is simple declarative Navigation Library represent navigation history as global state
## Add library
```kotlin
// Add Jitpack to dependencies resolutions settings.gradle.kts
dependencyResolutionManagement {
repositories {
maven("https://jitpack.io")
}
}
// Add dependencies to use without UI
implementation("com.github.androidbroadcast.NavState:navstate-core:0.1.1")
// For project with Compose
implementation("com.github.androidbroadcast.NavState:navstate-compose:0.1.1")
// For project with Compose with NavHost generation
implementation("com.github.androidbroadcast.NavState:navstate-compose-annotations:0.1.1")
ksp("com.github.androidbroadcast.NavState:navstate-compose-processor:0.1.1")
```
## Compose Sample with NavHost generation
```kotlin
@Serializable
class UserListDest : NavDest
@Serializable
class ProfileDest(val userId: UserId) : NavDest
@Composable
fun RootScreen() {
GeneratedNavHost(
initialDestination = UserListDest()
)
}
@Composable
@NavDest(dest = UserListDest::class)
fun UserListScreen() {
val navigator = LocalNavigator.current
val onItemSelected: (String) -> Unit = { id -> navgiator.enqueue(Forward(ProfileDest(id))) }
}
@Composable
@NavDest(dest = ProfileDest::class)
fun ProfileScreen(dest: ProfileDest) {
// ...
}
```
Facts about library:
- Can work with Compose Multiplatform, SwiftUI, Android Fragments, View and any other UI framework
- Fully async using Coroutines
- Fully testable navigation without UI