A simple, highly customizable compose navigation component for Android & Desktop platform
Introduction
A simple, highly customizable compose navigation component for Android & Desktop platform.
Screenshot
Android
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ScreenContainer(this, this, this) {
// Screen Host
}
}
}
}
Desktop
fun main() = application {
val size = DpSize(480.dp, 720.dp)
val windowState = rememberWindowState(size = size)
ScreenContainer(
title = "Compose Screen",
state = windowState,
onCloseRequest = {
exitApplication()
},
) {
// Screen Host
}
}
Usage – TODO
Screen Host
val screenNavigator = rememberScreenNavigator()
// Init the application screen graph
ScreenHost(screenNavigator = screenNavigator, rootScreenName = Manifest.MainActivityScreen) {
// register your screen
activity(screenName = (Manifest.MainActivityScreen)) {
MainActivityScreen(screenNavigator)
}
activity(screenName = Manifest.PushPopActivityScreen) {
PushPopActivityScreen(screenNavigator, it.arguments)
}
popup(screenName = Manifest.PushTestDialogPopupScreen) {
PushTestDialogPopupScreen(screenNavigator)
}
...
}
Push
// push
screenNavigator.push(screenName = Manifest.PushPopActivityScreen)
// push with arguments
val count = 1
screenNavigator.push(
screenName = Manifest.PushPopActivityScreen,
arguments = ScreenArgs.putValue("KEY_COUNT", count)
)
Pop
screenNavigator.pop()
Pop Interceptor
screenNavigator.pop(popOptions = PopOptions(popStackFinalInterceptor = { list, destroyList, _ ->
list.size > 10 && destroyList.firstOrNull()?.screen?.name == Manifest.PushPopActivityScreen
}))
Popup
PopupWindow
ViewModel
Compose ViewModel
Android ViewModel
Download – TODO
Android
implementation(“io.github.succlz123:compose-screen-android:0.0.1”)
Desktop
implementation(“io.github.succlz123:compose-screen-desktop:0.0.1”)
Thanks
- https://developer.android.com/jetpack/compose/navigation
- https://github.com/bytedance/scene
- https://github.com/olshevski/compose-navigation-reimagined