Initial setup for navigation display with nav3
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
909bd347a7
commit
89d55ede72
7 changed files with 107 additions and 4 deletions
|
|
@ -6,15 +6,18 @@
|
|||
package net.newpipe.app
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import net.newpipe.app.di.KoinApp
|
||||
import net.newpipe.app.navigation.Screen
|
||||
import net.newpipe.app.theme.AppTheme
|
||||
import org.koin.compose.KoinApplication
|
||||
import org.koin.plugin.module.dsl.koinConfiguration
|
||||
|
||||
/**
|
||||
* Entry point for the multiplatform compose application
|
||||
* @param startDestination Starting destination for the app
|
||||
*/
|
||||
@Composable
|
||||
@Preview
|
||||
fun App() {
|
||||
fun App(startDestination: Screen? = null) {
|
||||
KoinApplication(configuration = koinConfiguration<KoinApp>()) {
|
||||
AppTheme {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package net.newpipe.app.navigation
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.navigation3.runtime.entryProvider
|
||||
import androidx.navigation3.runtime.rememberNavBackStack
|
||||
import androidx.navigation3.ui.NavDisplay
|
||||
|
||||
/**
|
||||
* Navigation display for compose screens
|
||||
* @param startDestination Starting destination for the app
|
||||
*/
|
||||
@Composable
|
||||
fun NavDisplay(startDestination: Screen) {
|
||||
val backstack = rememberNavBackStack(screenConfig, startDestination)
|
||||
|
||||
NavDisplay(
|
||||
backStack = backstack,
|
||||
entryProvider = entryProvider {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2026 NewPipe e.V. <https://newpipe-ev.de>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package net.newpipe.app.navigation
|
||||
|
||||
import androidx.navigation3.runtime.NavKey
|
||||
import androidx.savedstate.serialization.SavedStateConfiguration
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.modules.SerializersModule
|
||||
import kotlinx.serialization.modules.polymorphic
|
||||
|
||||
/**
|
||||
* Destinations for navigation in compose
|
||||
*/
|
||||
@Serializable
|
||||
sealed interface Screen : NavKey
|
||||
|
||||
/**
|
||||
* Saved state configuration for screens
|
||||
*/
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
internal val screenConfig = SavedStateConfiguration {
|
||||
serializersModule = SerializersModule {
|
||||
polymorphic(NavKey::class) {
|
||||
subclassesOfSealed<Screen>()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue