Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,14 +45,13 @@ import io.github.openflocon.navigation.FloconRoute

@Immutable
data class MenuScene(
override val entries: List<NavEntry<FloconRoute>>,
override val previousEntries: List<NavEntry<FloconRoute>>,
val entry: NavEntry<FloconRoute>,
val menuContent: @Composable (expanded: Boolean) -> Unit,
val scene: Scene<FloconRoute>,
val menuContent: @Composable ((expanded: Boolean) -> Unit),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The extra parentheses around the function type for menuContent are redundant. For consistency with other function type declarations in this file, such as topBarContent on the next line and menuContent in the MenuSceneStrategy constructor, it's recommended to remove them to improve readability.

Suggested change
val menuContent: @Composable ((expanded: Boolean) -> Unit),
val menuContent: @Composable (expanded: Boolean) -> Unit,

val topBarContent: @Composable (() -> Unit)?
) : Scene<FloconRoute> {
override val key: Any
get() = Unit
override val key: Any = Unit
override val entries: List<NavEntry<FloconRoute>> = scene.entries
override val previousEntries: List<NavEntry<FloconRoute>> = scene.previousEntries

override val content: @Composable (() -> Unit) = {
var expanded by remember { mutableStateOf(true) }
Expand Down Expand Up @@ -84,7 +85,7 @@ data class MenuScene(
) {
menuContent(expanded)
}
entry.Content()
scene.content()
}
}
Box(
Expand Down Expand Up @@ -113,22 +114,18 @@ data class MenuScene(
class MenuSceneStrategy(
private val menuContent: @Composable (expanded: Boolean) -> Unit,
private val topBarContent: @Composable (() -> Unit)? = null
) : SceneStrategy<FloconRoute> {
) : SceneDecoratorStrategy<FloconRoute> {

override fun SceneStrategyScope<FloconRoute>.calculateScene(entries: List<NavEntry<FloconRoute>>): Scene<FloconRoute>? {
val entry = entries.lastOrNull() ?: return null

if (entry.metadata.containsKey(MENU_KEY)) {
override fun SceneDecoratorStrategyScope<FloconRoute>.decorateScene(scene: Scene<FloconRoute>): Scene<FloconRoute> {
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 {
Expand Down
7 changes: 3 additions & 4 deletions FloconDesktop/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T : Any> FloconNavigation(
navigationState: FloconNavigationState<T>,
modifier: Modifier = Modifier,
sceneStrategy: SceneStrategy<T> = SinglePaneSceneStrategy(),
sceneStrategies: List<SceneStrategy<T>> = listOf(SinglePaneSceneStrategy()),
sceneDecoratorStrategies: List<SceneDecoratorStrategy<T>> = emptyList(),
builder: EntryProviderScope<T>.() -> Unit
) {
NavDisplay(
Expand All @@ -29,7 +32,8 @@ fun <T : Any> FloconNavigation(
rememberSaveableStateHolderNavEntryDecorator(),
rememberViewModelStoreNavEntryDecorator()
),
sceneStrategy = sceneStrategy,
sceneStrategies = sceneStrategies,
sceneDecoratorStrategies = sceneDecoratorStrategies,
onBack = { navigationState.back(1) }, // TODO
entryProvider = entryProvider {
builder()
Expand Down