From 627eff3b0af03bc139e9dd21c4c3d72650376948 Mon Sep 17 00:00:00 2001 From: Antoine Jaury Date: Thu, 11 Jun 2026 18:06:16 +0200 Subject: [PATCH] new: add theme support with GwenedegTheme to take dark mode into account --- androidApp/src/main/AndroidManifest.xml | 2 +- .../kotlin/fr/ajaury/gwenedeg/App.kt | 4 ++-- .../kotlin/fr/ajaury/gwenedeg/theme/Theme.kt | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/theme/Theme.kt diff --git a/androidApp/src/main/AndroidManifest.xml b/androidApp/src/main/AndroidManifest.xml index 3499af4..36dfc9b 100644 --- a/androidApp/src/main/AndroidManifest.xml +++ b/androidApp/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" - android:theme="@android:style/Theme.Material.Light.NoActionBar"> + android:theme="@android:style/Theme.Material.NoActionBar"> diff --git a/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/App.kt b/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/App.kt index 8b78f58..8532d0d 100644 --- a/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/App.kt +++ b/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/App.kt @@ -1,6 +1,5 @@ package fr.ajaury.gwenedeg -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.saveable.rememberSerializable @@ -12,6 +11,7 @@ import fr.ajaury.gwenedeg.di.appModule import fr.ajaury.gwenedeg.navigation.Route import fr.ajaury.gwenedeg.player.ui.PlayerScreen import fr.ajaury.gwenedeg.records.ui.RecordsScreen +import fr.ajaury.gwenedeg.theme.GwenedegTheme import org.koin.compose.KoinApplication import org.koin.dsl.koinConfiguration @@ -28,7 +28,7 @@ fun App() { mutableStateListOf(Route.Records) } - MaterialTheme { + GwenedegTheme { NavDisplay( backStack = backStack, onBack = { backStack.removeLastOrNull() }, diff --git a/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/theme/Theme.kt b/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/theme/Theme.kt new file mode 100644 index 0000000..dc32e34 --- /dev/null +++ b/shared/src/commonMain/kotlin/fr/ajaury/gwenedeg/theme/Theme.kt @@ -0,0 +1,23 @@ +package fr.ajaury.gwenedeg.theme + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable + +private val DarkColorScheme = darkColorScheme() +private val LightColorScheme = lightColorScheme() + +@Composable +fun GwenedegTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + content: @Composable () -> Unit, +) { + val colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme + + MaterialTheme( + colorScheme = colorScheme, + content = content, + ) +}