diff --git a/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/app/AppScreen.kt b/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/app/AppScreen.kt index 5b4e5cf3a..122d23f2d 100644 --- a/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/app/AppScreen.kt +++ b/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/app/AppScreen.kt @@ -56,37 +56,39 @@ private fun Content( ) { FloconNavigation( navigationState = navigationState, - sceneStrategy = PanelSceneStrategy() - .then(WindowSceneStrategy()) - .then(DialogSceneStrategy()) - .then(BigDialogSceneStrategy()) - .then( - MenuSceneStrategy( - menuContent = { - LeftPanelView( - current = uiState.contentState.current, - state = uiState.menuState, - expanded = it, - onClickItem = { menu -> onAction(AppAction.SelectMenu(menu.screen)) } - ) - }, - topBarContent = { - MainScreenTopBar( - devicesState = uiState.deviceState, - appsState = uiState.appState, - recordState = uiState.recordState, - deleteApp = { onAction(AppAction.DeleteApp(it)) }, - deleteDevice = { onAction(AppAction.DeleteDevice(it)) }, - onDeviceSelected = { onAction(AppAction.SelectDevice(it)) }, - onAppSelected = { onAction(AppAction.SelectApp(it)) }, - onRecordClicked = { onAction(AppAction.Record) }, - onRestartClicked = { onAction(AppAction.Restart) }, - onTakeScreenshotClicked = { onAction(AppAction.Screenshoot) } - ) - } - ) + sceneStrategies = listOf( + PanelSceneStrategy(), + WindowSceneStrategy(), + DialogSceneStrategy(), + BigDialogSceneStrategy(), + SinglePaneSceneStrategy() + ), + sceneDecoratorStrategies = listOf( + MenuSceneStrategy( + menuContent = { + LeftPanelView( + current = uiState.contentState.current, + state = uiState.menuState, + expanded = it, + onClickItem = { menu -> onAction(AppAction.SelectMenu(menu.screen)) } + ) + }, + topBarContent = { + MainScreenTopBar( + devicesState = uiState.deviceState, + appsState = uiState.appState, + recordState = uiState.recordState, + deleteApp = { onAction(AppAction.DeleteApp(it)) }, + deleteDevice = { onAction(AppAction.DeleteDevice(it)) }, + onDeviceSelected = { onAction(AppAction.SelectDevice(it)) }, + onAppSelected = { onAction(AppAction.SelectApp(it)) }, + onRecordClicked = { onAction(AppAction.Record) }, + onRestartClicked = { onAction(AppAction.Restart) }, + onTakeScreenshotClicked = { onAction(AppAction.Screenshoot) } + ) + } ) - .then(SinglePaneSceneStrategy()), + ), modifier = Modifier .fillMaxSize() .background(FloconTheme.colorPalette.surface) diff --git a/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/app/MenuScene.kt b/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/app/MenuScene.kt index 36f8e7d35..aa7b29228 100644 --- a/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/app/MenuScene.kt +++ b/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/app/MenuScene.kt @@ -32,6 +32,8 @@ import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp import androidx.navigation3.runtime.NavEntry import androidx.navigation3.scene.Scene +import androidx.navigation3.scene.SceneDecoratorStrategy +import androidx.navigation3.scene.SceneDecoratorStrategyScope import androidx.navigation3.scene.SceneStrategy import androidx.navigation3.scene.SceneStrategyScope import io.github.openflocon.flocondesktop.app.ui.view.leftpannel.PanelMaxWidth @@ -43,14 +45,13 @@ import io.github.openflocon.navigation.FloconRoute @Immutable data class MenuScene( - override val entries: List>, - override val previousEntries: List>, - val entry: NavEntry, - val menuContent: @Composable (expanded: Boolean) -> Unit, + val scene: Scene, + val menuContent: @Composable ((expanded: Boolean) -> Unit), val topBarContent: @Composable (() -> Unit)? ) : Scene { - override val key: Any - get() = Unit + override val key: Any = Unit + override val entries: List> = scene.entries + override val previousEntries: List> = scene.previousEntries override val content: @Composable (() -> Unit) = { var expanded by remember { mutableStateOf(true) } @@ -84,7 +85,7 @@ data class MenuScene( ) { menuContent(expanded) } - entry.Content() + scene.content() } } Box( @@ -113,22 +114,18 @@ data class MenuScene( class MenuSceneStrategy( private val menuContent: @Composable (expanded: Boolean) -> Unit, private val topBarContent: @Composable (() -> Unit)? = null -) : SceneStrategy { +) : SceneDecoratorStrategy { - override fun SceneStrategyScope.calculateScene(entries: List>): Scene? { - val entry = entries.lastOrNull() ?: return null - - if (entry.metadata.containsKey(MENU_KEY)) { + override fun SceneDecoratorStrategyScope.decorateScene(scene: Scene): Scene { + if (scene.metadata.containsKey(MENU_KEY)) { return MenuScene( - entries = listOf(entry), - previousEntries = entries.dropLast(1), - entry = entry, + scene = scene, menuContent = menuContent, topBarContent = topBarContent ) } - return null + return scene } companion object { diff --git a/FloconDesktop/gradle/libs.versions.toml b/FloconDesktop/gradle/libs.versions.toml index c9f089e98..8853e4cad 100644 --- a/FloconDesktop/gradle/libs.versions.toml +++ b/FloconDesktop/gradle/libs.versions.toml @@ -14,7 +14,7 @@ androidx-testExt = "1.3.0" buildconfig = "5.6.8" coil = "3.4.0" compose-hot-reload = "1.0.0" -compose-multiplatform = "1.10.1" +compose-multiplatform = "1.11.0-alpha04" core = "1.7.0" junit = "4.13.2" kermit = "2.0.8" @@ -23,14 +23,13 @@ kotlin = "2.3.10" kotlinx-coroutines = "1.10.2" kotlinx-datetime = "0.7.1" kotlinx-serialization = "1.9.0" -kotlinx-serialization-core = "1.8.1" ksp = "2.3.6" ktlint = "14.0.1" ktor = "3.4.1" logback = "1.5.18" material3-adaptive = "1.0.0-alpha03" multiplatform-settings = "1.3.0" -navigation3 = "1.0.0-alpha04+dev3147" +navigation3 = "1.1.0-alpha04" opencsv = "5.9" other-jsontree = "2.6.0" paging = "3.3.2" @@ -92,7 +91,7 @@ kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" } kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" } -kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization-core" } +kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } # Ktor diff --git a/FloconDesktop/navigation/src/commonMain/kotlin/io/github/openflocon/navigation/FloconNavigation.kt b/FloconDesktop/navigation/src/commonMain/kotlin/io/github/openflocon/navigation/FloconNavigation.kt index 4d1e4aef6..db856b293 100644 --- a/FloconDesktop/navigation/src/commonMain/kotlin/io/github/openflocon/navigation/FloconNavigation.kt +++ b/FloconDesktop/navigation/src/commonMain/kotlin/io/github/openflocon/navigation/FloconNavigation.kt @@ -9,15 +9,18 @@ import androidx.lifecycle.viewmodel.navigation3.rememberViewModelStoreNavEntryDe import androidx.navigation3.runtime.EntryProviderScope import androidx.navigation3.runtime.entryProvider import androidx.navigation3.runtime.rememberSaveableStateHolderNavEntryDecorator +import androidx.navigation3.scene.SceneDecoratorStrategy import androidx.navigation3.scene.SceneStrategy import androidx.navigation3.scene.SinglePaneSceneStrategy import androidx.navigation3.ui.NavDisplay +import kotlin.collections.listOf @Composable fun FloconNavigation( navigationState: FloconNavigationState, modifier: Modifier = Modifier, - sceneStrategy: SceneStrategy = SinglePaneSceneStrategy(), + sceneStrategies: List> = listOf(SinglePaneSceneStrategy()), + sceneDecoratorStrategies: List> = emptyList(), builder: EntryProviderScope.() -> Unit ) { NavDisplay( @@ -29,7 +32,8 @@ fun FloconNavigation( rememberSaveableStateHolderNavEntryDecorator(), rememberViewModelStoreNavEntryDecorator() ), - sceneStrategy = sceneStrategy, + sceneStrategies = sceneStrategies, + sceneDecoratorStrategies = sceneDecoratorStrategies, onBack = { navigationState.back(1) }, // TODO entryProvider = entryProvider { builder()