mirror of
https://github.com/bleackstorm/satiea.git
synced 2026-12-03 07:41:56 +01:00
Set up Android project configuration, Gradle build scripts, typography, and default resource assets.
88 lines
2.8 KiB
Kotlin
88 lines
2.8 KiB
Kotlin
package com.example.ui.theme
|
|
|
|
import android.os.Build
|
|
import androidx.compose.foundation.isSystemInDarkTheme
|
|
import androidx.compose.material3.MaterialTheme
|
|
import androidx.compose.material3.darkColorScheme
|
|
import androidx.compose.material3.dynamicDarkColorScheme
|
|
import androidx.compose.material3.dynamicLightColorScheme
|
|
import androidx.compose.material3.lightColorScheme
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
enum class AppThemeMode(val displayName: String) {
|
|
DARK("Sombre élégant (défaut)"),
|
|
LIGHT("Clair lin & forêt"),
|
|
SYSTEM("Suivre le système")
|
|
}
|
|
|
|
private val DarkColorScheme = darkColorScheme(
|
|
primary = DarkPrimary,
|
|
onPrimary = DarkOnPrimary,
|
|
primaryContainer = DarkPrimaryContainer,
|
|
onPrimaryContainer = DarkOnPrimaryContainer,
|
|
secondary = DarkSecondary,
|
|
onSecondary = DarkOnSecondary,
|
|
secondaryContainer = DarkSecondaryContainer,
|
|
onSecondaryContainer = DarkOnSecondaryContainer,
|
|
tertiary = DarkTertiary,
|
|
onTertiary = DarkOnTertiary,
|
|
background = DarkBackground,
|
|
onBackground = DarkOnBackground,
|
|
surface = DarkSurface,
|
|
onSurface = DarkOnSurface,
|
|
surfaceVariant = DarkSurfaceVariant,
|
|
onSurfaceVariant = DarkOnSurfaceVariant,
|
|
outline = DarkOutline,
|
|
outlineVariant = DarkOutlineVariant
|
|
)
|
|
|
|
private val LightColorScheme = lightColorScheme(
|
|
primary = LightPrimary,
|
|
onPrimary = LightOnPrimary,
|
|
primaryContainer = LightPrimaryContainer,
|
|
onPrimaryContainer = LightOnPrimaryContainer,
|
|
secondary = LightSecondary,
|
|
onSecondary = LightOnSecondary,
|
|
secondaryContainer = LightSecondaryContainer,
|
|
onSecondaryContainer = LightOnSecondaryContainer,
|
|
tertiary = LightTertiary,
|
|
onTertiary = LightOnTertiary,
|
|
background = LightBackground,
|
|
onBackground = LightOnBackground,
|
|
surface = LightSurface,
|
|
onSurface = LightOnSurface,
|
|
surfaceVariant = LightSurfaceVariant,
|
|
onSurfaceVariant = LightOnSurfaceVariant,
|
|
outline = LightOutline,
|
|
outlineVariant = LightOutlineVariant
|
|
)
|
|
|
|
@Composable
|
|
fun SatieaTheme(
|
|
themeMode: AppThemeMode = AppThemeMode.DARK,
|
|
dynamicColor: Boolean = false,
|
|
content: @Composable () -> Unit
|
|
) {
|
|
val darkTheme = when (themeMode) {
|
|
AppThemeMode.DARK -> true
|
|
AppThemeMode.LIGHT -> false
|
|
AppThemeMode.SYSTEM -> isSystemInDarkTheme()
|
|
}
|
|
|
|
val colorScheme = when {
|
|
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
|
val context = LocalContext.current
|
|
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
|
}
|
|
darkTheme -> DarkColorScheme
|
|
else -> LightColorScheme
|
|
}
|
|
|
|
MaterialTheme(
|
|
colorScheme = colorScheme,
|
|
typography = Typography,
|
|
content = content
|
|
)
|
|
}
|