new: add theme support with GwenedegTheme to take dark mode into account

This commit is contained in:
2026-06-11 18:06:16 +02:00
parent 0c6e620c3f
commit 627eff3b0a
3 changed files with 26 additions and 3 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar"> android:theme="@android:style/Theme.Material.NoActionBar">
<activity <activity
android:exported="true" android:exported="true"
android:name=".MainActivity"> android:name=".MainActivity">
@@ -1,6 +1,5 @@
package fr.ajaury.gwenedeg package fr.ajaury.gwenedeg
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.saveable.rememberSerializable 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.navigation.Route
import fr.ajaury.gwenedeg.player.ui.PlayerScreen import fr.ajaury.gwenedeg.player.ui.PlayerScreen
import fr.ajaury.gwenedeg.records.ui.RecordsScreen import fr.ajaury.gwenedeg.records.ui.RecordsScreen
import fr.ajaury.gwenedeg.theme.GwenedegTheme
import org.koin.compose.KoinApplication import org.koin.compose.KoinApplication
import org.koin.dsl.koinConfiguration import org.koin.dsl.koinConfiguration
@@ -28,7 +28,7 @@ fun App() {
mutableStateListOf(Route.Records) mutableStateListOf(Route.Records)
} }
MaterialTheme { GwenedegTheme {
NavDisplay( NavDisplay(
backStack = backStack, backStack = backStack,
onBack = { backStack.removeLastOrNull() }, onBack = { backStack.removeLastOrNull() },
@@ -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,
)
}