
Tiny library simplifies navigation in Compose Multiplatform applications, featuring screens navigation, optional ViewModel with work cancellation, and desktop-specific windows navigation capabilities.
Tiny library for easy navigation in Compose Multiplatform applications.
Provides:
ViewModel with work cancellation support - multiplatformFor each version of navigation specific version of Compose Multiplatform is required
| navigation | compose-multiplatform |
|---|---|
| 1.4.0 | 1.6.1 |
| 1.3.2 | 1.5.12 |
| 1.3.1 | 1.5.11 |
| 1.3.0 | 1.5.10 |
| 1.2.0 | 1.5.3 |
| 1.1.0 | 1.5.2 |
| 1.0.0 | 1.5.1 |
Add mavenCentral and google repositories:
repositories {
mavenCentral()
google()
}Declare dependencies in build.gradle.kts:
dependencies {
// Screens navigation - multiplatform
implementation("io.github.lukwol:navigation-screens:1.4.0")
// Screens navigation with ViewModel support - multiplatform
implementation("io.github.lukwol:navigation-screens-viewmodel:1.4.0")
// Windows navigation - desktop application only
implementation("io.github.lukwol:navigation-windows:1.4.0")
}Bootstrap new project with handy app-template.
Basic screens navigation:
ScreensNavigation(
startRoute = AppRoutes.FirstScreenRoute,
) {
screen(AppRoutes.FirstScreenRoute) {
FirstScreen()
}
screen(AppRoutes.SecondScreenRoute) { args: String? ->
SecondScreen(args)
}
}Screens navigation with ViewModel and custom animations:
ScreensNavigation(
startRoute = AppRoutes.FirstScreenRoute,
enterTransition = {
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Left)
},
exitTransition = {
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Left)
},
popEnterTransition = {
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Right)
},
popExitTransition = {
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Right)
},
) {
screen(
route = AppRoutes.FirstScreenRoute,
viewModelFactory = {
FirstScreenViewModel()
}
) { viewModel ->
FirstScreen(viewModel)
}
screen(
route = AppRoutes.SecondScreenRoute,
viewModelWithArgs = { args: SomeArgs? ->
SecondScreenViewModel(args)
}
) { viewModel ->
SecondScreen(viewModel)
}
}WindowsNavigation(
startRoute = AppRoutes.FirstWindowRoute
) {
window(
route = AppRoutes.FirstWindowRoute,
title = "First Window"
) {
ScreensNavigation(
startRoute = AppRoutes.FirstScreenRoute
) {
// ...
}
}
window(
route = AppRoutes.SecondWindowRoute,
title = "Second Window"
) {
ScreensNavigation(
startRoute = AppRoutes.SecondScreenRoute
) {
// ...
}
}
}// Obtain LocalScreensController in your view
val screensController = LocalScreensController.current
// Push screen
screensController.push(AppRoutes.SecondScreenRoute)
// Optionally pass arguments if needed
screensController.push(AppRoutes.SecondScreenRoute, SomeArguments)
// Pop screen to navigate back
screensController.pop()
// Optionally pass route, up to which screens should be dismissed
screensController.pop(AppRoutes.FirstScreenRoute)// Obtain LocalWindowController in your view
val windowsController = LocalWindowController.current
// Open window
windowsController.open(AppRoutes.SecondWindowRoute)
// Optionally pass arguments if needed
windowsController.open(AppRoutes.SecondWindowRoute, SomeArguments)
// Close window
windowsController.close(AppRoutes.SecondWindowRoute)API Reference is available at https://lukwol.github.io/navigation/
Project is available under MIT License.
Tiny library for easy navigation in Compose Multiplatform applications.
Provides:
ViewModel with work cancellation support - multiplatformFor each version of navigation specific version of Compose Multiplatform is required
| navigation | compose-multiplatform |
|---|---|
| 1.4.0 | 1.6.1 |
| 1.3.2 | 1.5.12 |
| 1.3.1 | 1.5.11 |
| 1.3.0 | 1.5.10 |
| 1.2.0 | 1.5.3 |
| 1.1.0 | 1.5.2 |
| 1.0.0 | 1.5.1 |
Add mavenCentral and google repositories:
repositories {
mavenCentral()
google()
}Declare dependencies in build.gradle.kts:
dependencies {
// Screens navigation - multiplatform
implementation("io.github.lukwol:navigation-screens:1.4.0")
// Screens navigation with ViewModel support - multiplatform
implementation("io.github.lukwol:navigation-screens-viewmodel:1.4.0")
// Windows navigation - desktop application only
implementation("io.github.lukwol:navigation-windows:1.4.0")
}Bootstrap new project with handy app-template.
Basic screens navigation:
ScreensNavigation(
startRoute = AppRoutes.FirstScreenRoute,
) {
screen(AppRoutes.FirstScreenRoute) {
FirstScreen()
}
screen(AppRoutes.SecondScreenRoute) { args: String? ->
SecondScreen(args)
}
}Screens navigation with ViewModel and custom animations:
ScreensNavigation(
startRoute = AppRoutes.FirstScreenRoute,
enterTransition = {
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Left)
},
exitTransition = {
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Left)
},
popEnterTransition = {
slideIntoContainer(AnimatedContentTransitionScope.SlideDirection.Right)
},
popExitTransition = {
slideOutOfContainer(AnimatedContentTransitionScope.SlideDirection.Right)
},
) {
screen(
route = AppRoutes.FirstScreenRoute,
viewModelFactory = {
FirstScreenViewModel()
}
) { viewModel ->
FirstScreen(viewModel)
}
screen(
route = AppRoutes.SecondScreenRoute,
viewModelWithArgs = { args: SomeArgs? ->
SecondScreenViewModel(args)
}
) { viewModel ->
SecondScreen(viewModel)
}
}WindowsNavigation(
startRoute = AppRoutes.FirstWindowRoute
) {
window(
route = AppRoutes.FirstWindowRoute,
title = "First Window"
) {
ScreensNavigation(
startRoute = AppRoutes.FirstScreenRoute
) {
// ...
}
}
window(
route = AppRoutes.SecondWindowRoute,
title = "Second Window"
) {
ScreensNavigation(
startRoute = AppRoutes.SecondScreenRoute
) {
// ...
}
}
}// Obtain LocalScreensController in your view
val screensController = LocalScreensController.current
// Push screen
screensController.push(AppRoutes.SecondScreenRoute)
// Optionally pass arguments if needed
screensController.push(AppRoutes.SecondScreenRoute, SomeArguments)
// Pop screen to navigate back
screensController.pop()
// Optionally pass route, up to which screens should be dismissed
screensController.pop(AppRoutes.FirstScreenRoute)// Obtain LocalWindowController in your view
val windowsController = LocalWindowController.current
// Open window
windowsController.open(AppRoutes.SecondWindowRoute)
// Optionally pass arguments if needed
windowsController.open(AppRoutes.SecondWindowRoute, SomeArguments)
// Close window
windowsController.close(AppRoutes.SecondWindowRoute)API Reference is available at https://lukwol.github.io/navigation/
Project is available under MIT License.