From 1aeb59cfe5d133ed23ce801af22f4e14cc2a48bb Mon Sep 17 00:00:00 2001 From: doTTTTT Date: Wed, 8 Apr 2026 19:23:39 +0200 Subject: [PATCH] fix: Mocks dialog --- .../features/network/Navigation.kt | 6 +- .../mock/list/view/NetworkMocksScreen.kt | 7 +- .../designsystem/components/FloconDialog.kt | 25 ++++--- .../navigation/scene/BigDialogScene.kt | 68 +++++++++++-------- 4 files changed, 63 insertions(+), 43 deletions(-) diff --git a/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/features/network/Navigation.kt b/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/features/network/Navigation.kt index 834a5bbf8..0196f5819 100644 --- a/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/features/network/Navigation.kt +++ b/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/features/network/Navigation.kt @@ -17,6 +17,8 @@ import io.github.openflocon.flocondesktop.features.network.search.view.NetworkSe import io.github.openflocon.navigation.FloconRoute import io.github.openflocon.navigation.PanelRoute import io.github.openflocon.navigation.WindowRoute +import io.github.openflocon.navigation.scene.BigDialogProperties +import io.github.openflocon.navigation.scene.BigDialogSceneStrategy import io.github.openflocon.navigation.scene.PanelSceneStrategy import io.github.openflocon.navigation.scene.WindowSceneStrategy import kotlinx.serialization.Serializable @@ -76,7 +78,9 @@ fun EntryProviderScope.networkRoutes() { NetworkDetailScreen(requestId = it.requestId) } entry( - metadata = DialogSceneStrategy.dialog() + metadata = BigDialogSceneStrategy.bigDialog( + BigDialogProperties(title = "Mocks") + ) ) { NetworkMocksWindow( fromNetworkCallId = it.id diff --git a/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/features/network/mock/list/view/NetworkMocksScreen.kt b/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/features/network/mock/list/view/NetworkMocksScreen.kt index 318043af4..627b8bcc2 100644 --- a/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/features/network/mock/list/view/NetworkMocksScreen.kt +++ b/FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/features/network/mock/list/view/NetworkMocksScreen.kt @@ -77,7 +77,7 @@ private fun NetworkMocksContent( ) { Column(modifier = modifier) { FloconDialogHeader( - title = "Mocks", + title = null, modifier = Modifier.fillMaxWidth(), trailingContent = { FloconButton( @@ -127,7 +127,10 @@ private fun NetworkMocksContent( }, modifier = Modifier.fillMaxWidth(), ) - HorizontalDivider(Modifier.fillMaxWidth(), color = MaterialTheme.colorScheme.outline) + HorizontalDivider( + Modifier.fillMaxWidth(), + color = MaterialTheme.colorScheme.outline + ) } } } diff --git a/FloconDesktop/library/designsystem/src/commonMain/kotlin/io/github/openflocon/library/designsystem/components/FloconDialog.kt b/FloconDesktop/library/designsystem/src/commonMain/kotlin/io/github/openflocon/library/designsystem/components/FloconDialog.kt index adb2f4c85..3a0217047 100644 --- a/FloconDesktop/library/designsystem/src/commonMain/kotlin/io/github/openflocon/library/designsystem/components/FloconDialog.kt +++ b/FloconDesktop/library/designsystem/src/commonMain/kotlin/io/github/openflocon/library/designsystem/components/FloconDialog.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight @@ -49,7 +50,7 @@ fun FloconDialog( @Composable fun FloconDialogHeader( - title: String, + title: String?, modifier: Modifier = Modifier, trailingContent: @Composable RowScope.() -> Unit = {}, ) { @@ -59,15 +60,19 @@ fun FloconDialogHeader( .padding(horizontal = 12.dp, vertical = 4.dp), verticalAlignment = Alignment.CenterVertically, ) { - Text( - text = title, - modifier = Modifier - .padding(vertical = 12.dp) - .padding(start = 4.dp) - .weight(1f), - style = FloconTheme.typography.titleMedium, - color = FloconTheme.colorPalette.onPrimary, - ) + if (title != null) { + Text( + text = title, + modifier = Modifier + .padding(vertical = 12.dp) + .padding(start = 4.dp) + .weight(1f), + style = FloconTheme.typography.titleMedium, + color = FloconTheme.colorPalette.onPrimary, + ) + } else { + Spacer(Modifier.weight(1f)) + } Row( verticalAlignment = Alignment.CenterVertically, ) { diff --git a/FloconDesktop/navigation/src/commonMain/kotlin/io/github/openflocon/navigation/scene/BigDialogScene.kt b/FloconDesktop/navigation/src/commonMain/kotlin/io/github/openflocon/navigation/scene/BigDialogScene.kt index 26b71f137..1ade93d99 100644 --- a/FloconDesktop/navigation/src/commonMain/kotlin/io/github/openflocon/navigation/scene/BigDialogScene.kt +++ b/FloconDesktop/navigation/src/commonMain/kotlin/io/github/openflocon/navigation/scene/BigDialogScene.kt @@ -4,16 +4,22 @@ package io.github.openflocon.navigation.scene import androidx.compose.foundation.background import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Close import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar -import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.runtime.Immutable import androidx.compose.ui.Modifier @@ -29,7 +35,6 @@ import androidx.navigation3.scene.SceneStrategyScope import io.github.openflocon.library.designsystem.FloconTheme import io.github.openflocon.library.designsystem.components.FloconIcon import io.github.openflocon.library.designsystem.components.FloconIconButton -import io.github.openflocon.library.designsystem.components.FloconScaffold import io.github.openflocon.navigation.FloconRoute @Immutable @@ -40,34 +45,15 @@ private data class BigDialogScene( override val overlaidEntries: List>, private val onBack: () -> Unit, ) : OverlayScene { + override val key: Any = BigDialogSceneStrategy.BIG_DIALOG override val entries: List> = listOf(entry) override val content: @Composable (() -> Unit) = { - FloconScaffold( - topBar = { - TopAppBar( - title = { - Text(properties.title) - }, - actions = { - FloconIconButton( - onClick = onBack - ) { - FloconIcon( - imageVector = Icons.Default.Close - ) - } - }, - colors = TopAppBarDefaults.topAppBarColors( - containerColor = FloconTheme.colorPalette.primary, - titleContentColor = FloconTheme.colorPalette.onPrimary, - actionIconContentColor = FloconTheme.colorPalette.onPrimary - ) - ) - }, - containerColor = FloconTheme.colorPalette.primary.copy(alpha = 0.5f), + + Column( modifier = Modifier .fillMaxSize() + .background(FloconTheme.colorPalette.primary.copy(alpha = 0.7f)) .clickable( onClick = onBack, indication = null, @@ -78,17 +64,38 @@ private data class BigDialogScene( shape = RoundedCornerShape(12.dp), shadow = Shadow( radius = 4.dp, - color = FloconTheme.colorPalette.onAccent + color = FloconTheme.colorPalette.onAccent.copy(alpha = 0.5f) ) ) .clip(RoundedCornerShape(12.dp)) .background(FloconTheme.colorPalette.primary) .padding(16.dp) ) { + Row( + horizontalArrangement = Arrangement.SpaceBetween, + modifier = Modifier.fillMaxWidth() + ) { + Text( + text = properties.title, + color = FloconTheme.colorPalette.onPrimary, + style = FloconTheme.typography.headlineSmall + ) + FloconIconButton( + onClick = onBack + ) { + FloconIcon( + imageVector = Icons.Default.Close, + tint = FloconTheme.colorPalette.onPrimary + ) + } + } + Spacer(Modifier.height(8.dp)) + HorizontalDivider() + Spacer(Modifier.height(8.dp)) Box( - modifier = Modifier + Modifier .fillMaxSize() - .padding(it) + .clickable(onClick = {}, indication = null, interactionSource = null) ) { entry.Content() } @@ -121,7 +128,8 @@ class BigDialogSceneStrategy : SceneStrategy { companion object { const val BIG_DIALOG = "BIG_DIALOG" - fun bigDialog(properties: BigDialogProperties): Map = mapOf(BIG_DIALOG to properties) + fun bigDialog(properties: BigDialogProperties): Map = + mapOf(BIG_DIALOG to properties) } }