refactor(theme): centralize colors and typography in AppColors and AppTypography
- Replaced hardcoded color values in `LightColorScheme` and `DarkColorScheme` with `AppColors`. - Updated `AppTypography` references in `AppMaterialTypography`. - Upgraded Kotlin, Compose Multiplatform, and Ktor to latest versions in `libs.versions.toml`. - Added `uiToolingPreview` dependency in `meldestelle-portal` build script. - Refactored config loading to include `RequestInit`. Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
parent
2eb88430f1
commit
ac3bfcad3c
|
|
@ -1,56 +1,47 @@
|
||||||
package at.mocode.frontend.core.designsystem.theme
|
package at.mocode.frontend.core.designsystem.theme
|
||||||
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.darkColorScheme
|
|
||||||
import androidx.compose.material3.lightColorScheme
|
|
||||||
import androidx.compose.material3.Shapes
|
|
||||||
import androidx.compose.material3.Typography
|
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.text.TextStyle
|
|
||||||
import androidx.compose.ui.text.font.FontFamily
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
|
|
||||||
// --- 1. Farben (Palette) ---
|
// --- 1. Farben (Palette) ---
|
||||||
// wir definieren eine professionelle, kontrastreiche Palette.
|
// wir definieren eine professionelle, kontrastreiche Palette.
|
||||||
// Blau steht für Aktion/Information, Grau für Struktur.
|
// Blau steht für Aktion/Information, Grau für Struktur.
|
||||||
|
|
||||||
private val LightColorScheme = lightColorScheme(
|
private val LightColorScheme = lightColorScheme(
|
||||||
primary = Color(0xFF0052CC), // Enterprise Blue (stark)
|
primary = AppColors.Primary,
|
||||||
onPrimary = Color.White,
|
onPrimary = AppColors.OnPrimary,
|
||||||
primaryContainer = Color(0xFFDEEBFF),
|
primaryContainer = AppColors.PrimaryContainer,
|
||||||
onPrimaryContainer = Color(0xFF0052CC),
|
onPrimaryContainer = AppColors.OnPrimaryContainer,
|
||||||
|
|
||||||
secondary = Color(0xFF2684FF), // Helleres Blau für Akzente
|
secondary = AppColors.Secondary,
|
||||||
onSecondary = Color.White,
|
onSecondary = AppColors.OnSecondary,
|
||||||
|
|
||||||
background = Color(0xFFF4F5F7), // Helles Grau (nicht hartes Weiß)
|
background = AppColors.BackgroundLight,
|
||||||
surface = Color.White,
|
surface = AppColors.SurfaceLight,
|
||||||
onBackground = Color(0xFF172B4D), // Fast Schwarz (besser lesbar als #000)
|
onBackground = AppColors.OnBackgroundLight,
|
||||||
onSurface = Color(0xFF172B4D),
|
onSurface = AppColors.OnBackgroundLight,
|
||||||
|
|
||||||
error = Color(0xFFDE350B),
|
error = AppColors.Error,
|
||||||
onError = Color.White
|
onError = AppColors.OnError
|
||||||
)
|
)
|
||||||
|
|
||||||
private val DarkColorScheme = darkColorScheme(
|
private val DarkColorScheme = darkColorScheme(
|
||||||
primary = Color(0xFF4C9AFF), // Helleres Blau auf Dunkel
|
primary = AppColors.Secondary, // Helleres Blau auf Dunkel
|
||||||
onPrimary = Color(0xFF091E42),
|
onPrimary = AppColors.BackgroundDark,
|
||||||
primaryContainer = Color(0xFF0052CC),
|
primaryContainer = AppColors.Primary,
|
||||||
onPrimaryContainer = Color.White,
|
onPrimaryContainer = AppColors.OnPrimary,
|
||||||
|
|
||||||
secondary = Color(0xFF2684FF),
|
secondary = AppColors.Secondary,
|
||||||
onSecondary = Color.White,
|
onSecondary = AppColors.OnSecondary,
|
||||||
|
|
||||||
background = Color(0xFF1E1E1E), // Dunkles Grau (angenehmer als #000)
|
background = AppColors.BackgroundDark,
|
||||||
surface = Color(0xFF2C2C2C), // Panels heben sich leicht ab
|
surface = AppColors.SurfaceDark,
|
||||||
onBackground = Color(0xFFEBECF0),
|
onBackground = AppColors.OnBackgroundDark,
|
||||||
onSurface = Color(0xFFEBECF0),
|
onSurface = AppColors.OnBackgroundDark,
|
||||||
|
|
||||||
error = Color(0xFFFF5630),
|
error = AppColors.Error,
|
||||||
onError = Color.Black
|
onError = AppColors.OnError
|
||||||
)
|
)
|
||||||
|
|
||||||
// --- 2. Formen (Shapes) ---
|
// --- 2. Formen (Shapes) ---
|
||||||
|
|
@ -63,31 +54,11 @@ private val AppShapes = Shapes(
|
||||||
|
|
||||||
// --- 3. Typografie ---
|
// --- 3. Typografie ---
|
||||||
// wir setzen auf klare Hierarchie.
|
// wir setzen auf klare Hierarchie.
|
||||||
private val AppTypography = Typography(
|
private val AppMaterialTypography = Typography(
|
||||||
titleLarge = TextStyle(
|
titleLarge = AppTypography.TitleLarge,
|
||||||
fontFamily = FontFamily.Default,
|
titleMedium = AppTypography.TitleMedium,
|
||||||
fontWeight = FontWeight.Bold,
|
bodyMedium = AppTypography.BodyMedium,
|
||||||
fontSize = 22.sp,
|
labelSmall = AppTypography.LabelSmall
|
||||||
lineHeight = 28.sp
|
|
||||||
),
|
|
||||||
titleMedium = TextStyle(
|
|
||||||
fontFamily = FontFamily.Default,
|
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
fontSize = 16.sp,
|
|
||||||
lineHeight = 24.sp
|
|
||||||
),
|
|
||||||
bodyMedium = TextStyle( // Standard Text
|
|
||||||
fontFamily = FontFamily.Default,
|
|
||||||
fontWeight = FontWeight.Normal,
|
|
||||||
fontSize = 14.sp,
|
|
||||||
lineHeight = 20.sp
|
|
||||||
),
|
|
||||||
labelSmall = TextStyle( // Für dichte Tabellen/Labels
|
|
||||||
fontFamily = FontFamily.Default,
|
|
||||||
fontWeight = FontWeight.Medium,
|
|
||||||
fontSize = 11.sp,
|
|
||||||
lineHeight = 16.sp
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -100,7 +71,7 @@ fun AppTheme(
|
||||||
MaterialTheme(
|
MaterialTheme(
|
||||||
colorScheme = colorScheme,
|
colorScheme = colorScheme,
|
||||||
shapes = AppShapes,
|
shapes = AppShapes,
|
||||||
typography = AppTypography,
|
typography = AppMaterialTypography,
|
||||||
content = content
|
content = content
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ kotlin {
|
||||||
implementation(compose.ui)
|
implementation(compose.ui)
|
||||||
implementation(compose.components.resources)
|
implementation(compose.components.resources)
|
||||||
implementation(compose.materialIconsExtended)
|
implementation(compose.materialIconsExtended)
|
||||||
|
implementation(compose.components.uiToolingPreview)
|
||||||
|
|
||||||
// Bundles
|
// Bundles
|
||||||
implementation(libs.bundles.kmp.common) // Coroutines, Serialization, DateTime
|
implementation(libs.bundles.kmp.common) // Coroutines, Serialization, DateTime
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import kotlinx.browser.window
|
||||||
import kotlinx.coroutines.await
|
import kotlinx.coroutines.await
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
import org.w3c.fetch.RequestInit
|
||||||
|
|
||||||
private val AppJson = Json { ignoreUnknownKeys = true }
|
private val AppJson = Json { ignoreUnknownKeys = true }
|
||||||
|
|
||||||
|
|
@ -14,7 +15,7 @@ data class AppConfig(
|
||||||
suspend fun loadAppConfig(): AppConfig {
|
suspend fun loadAppConfig(): AppConfig {
|
||||||
return try {
|
return try {
|
||||||
// ?_nocache erzwingt einen SW-bypassing Request (SW sieht andere URL → Cache-Miss → Netzwerk)
|
// ?_nocache erzwingt einen SW-bypassing Request (SW sieht andere URL → Cache-Miss → Netzwerk)
|
||||||
val response = window.fetch("/config.json?_nocache=1").await()
|
val response = window.fetch("/config.json?_nocache=1", RequestInit()).await()
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.warn("[Config] Failed to load config.json, falling back to globalThis")
|
console.warn("[Config] Failed to load config.json, falling back to globalThis")
|
||||||
return fallbackFromGlobal()
|
return fallbackFromGlobal()
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# === FRONTEND & KMP CORE ===
|
# === FRONTEND & KMP CORE ===
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Kotlin & Tooling
|
# Kotlin & Tooling
|
||||||
kotlin = "2.3.0"
|
kotlin = "2.3.20"
|
||||||
ksp = "2.3.4"
|
ksp = "2.3.4"
|
||||||
|
|
||||||
# KotlinX (Core Libraries)
|
# KotlinX (Core Libraries)
|
||||||
|
|
@ -17,14 +17,14 @@ kotlinx-datetime = "0.7.1"
|
||||||
|
|
||||||
# UI: Compose Multiplatform
|
# UI: Compose Multiplatform
|
||||||
# Aligned with Kotlin 2.3.0
|
# Aligned with Kotlin 2.3.0
|
||||||
composeMultiplatform = "1.10.0"
|
composeMultiplatform = "1.11.0-alpha04"
|
||||||
composeHotReload = "1.0.0"
|
composeHotReload = "1.0.0"
|
||||||
androidx-lifecycle = "2.9.6"
|
androidx-lifecycle = "2.9.6"
|
||||||
uiDesktop = "1.7.0"
|
uiDesktop = "1.7.0"
|
||||||
|
|
||||||
# Network: Ktor (Client & Server)
|
# Network: Ktor (Client & Server)
|
||||||
# Align with Kotlin 2.3.0 – upgrade to 3.4.0 (runtime OpenAPI + lifecycle improvements)
|
# Align with Kotlin 2.3.0 – upgrade to 3.4.0 (runtime OpenAPI + lifecycle improvements)
|
||||||
ktor = "3.4.0"
|
ktor = "3.4.1"
|
||||||
|
|
||||||
# Dependency Injection
|
# Dependency Injection
|
||||||
koin = "4.1.1"
|
koin = "4.1.1"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user