feat(theme): allow dynamic colors to override preset theme and disable preset selector when active (#684)

* feat(theme): allow dynamic colors to override non-default theme presets

* feat(settings): disable theme preset selector when dynamic colors is enabled

* feat(theme): align Catppuccin preset with official Latte and Mocha style guide
This commit is contained in:
M57
2026-07-22 22:49:36 +03:00
committed by GitHub
parent 06ba3e8399
commit 34ba93901b
4 changed files with 96 additions and 95 deletions
@@ -64,8 +64,8 @@ private fun resolveStatusColors(preset: ThemePreset, darkTheme: Boolean) = when
} }
``` ```
Dynamic (Material You) color on API 31+ overrides the DEFAULT scheme when Dynamic (Material You) color on API 31+ overrides the preset scheme when
`useDynamicColors = true` and `themePreset == ThemePreset.DEFAULT`. `useDynamicColors = true`.
## DEFAULT uses design tokens — that's intentional ## DEFAULT uses design tokens — that's intentional
@@ -96,7 +96,7 @@ fun HermesControlTheme(
val context = LocalContext.current val context = LocalContext.current
val dynamicAvailable = val dynamicAvailable =
useDynamicColors && themePreset == ThemePreset.DEFAULT && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S useDynamicColors && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
val colorScheme = val colorScheme =
if (dynamicAvailable) { if (dynamicAvailable) {
if (darkTheme) { if (darkTheme) {
@@ -8,111 +8,111 @@ import com.m57.hermescontrol.theme.HermesStatusColors
/** Catppuccin color scheme (dark). */ /** Catppuccin color scheme (dark). */
val CatppuccinDarkColorScheme = val CatppuccinDarkColorScheme =
darkColorScheme( darkColorScheme(
primary = Color(0xFFCBA6F7), primary = Color(0xFFCBA6F7), // Mauve
onPrimary = Color(0xFF11111B), onPrimary = Color(0xFF11111B), // Crust
primaryContainer = Color(0xFF585B70), primaryContainer = Color(0xFF45475A), // Surface 1
onPrimaryContainer = Color(0xFFF5E0DC), onPrimaryContainer = Color(0xFFCDD6F4), // Text
inversePrimary = Color(0xFF8839EF), inversePrimary = Color(0xFF8839EF), // Latte Mauve
secondary = Color(0xFF89B4FA), secondary = Color(0xFF89B4FA), // Blue
onSecondary = Color(0xFF11111B), onSecondary = Color(0xFF11111B), // Crust
secondaryContainer = Color(0xFF313244), secondaryContainer = Color(0xFF313244), // Surface 0
onSecondaryContainer = Color(0xFFBAC2DE), onSecondaryContainer = Color(0xFFBAC2DE), // Subtext 1
tertiary = Color(0xFFF5C2E7), tertiary = Color(0xFFF5C2E7), // Pink
onTertiary = Color(0xFF11111B), onTertiary = Color(0xFF11111B), // Crust
tertiaryContainer = Color(0xFF45475A), tertiaryContainer = Color(0xFF45475A), // Surface 1
onTertiaryContainer = Color(0xFFF5E0DC), onTertiaryContainer = Color(0xFFCDD6F4), // Text
background = Color(0xFF1E1E2E), background = Color(0xFF1E1E2E), // Base
onBackground = Color(0xFFCDD6F4), onBackground = Color(0xFFCDD6F4), // Text
surface = Color(0xFF252538), surface = Color(0xFF1E1E2E), // Base
onSurface = Color(0xFFCDD6F4), onSurface = Color(0xFFCDD6F4), // Text
surfaceVariant = Color(0xFF313244), surfaceVariant = Color(0xFF313244), // Surface 0
onSurfaceVariant = Color(0xFFA6ADC8), onSurfaceVariant = Color(0xFFA6ADC8), // Subtext 0
surfaceTint = Color(0xFFCBA6F7), surfaceTint = Color(0xFFCBA6F7), // Mauve
surfaceContainerLowest = Color(0xFF11111B), surfaceContainerLowest = Color(0xFF11111B), // Crust
surfaceContainerLow = Color(0xFF181825), surfaceContainerLow = Color(0xFF181825), // Mantle
surfaceContainer = Color(0xFF1E1E2E), surfaceContainer = Color(0xFF1E1E2E), // Base
surfaceContainerHigh = Color(0xFF252538), surfaceContainerHigh = Color(0xFF313244), // Surface 0
surfaceContainerHighest = Color(0xFF313244), surfaceContainerHighest = Color(0xFF45475A), // Surface 1
inverseSurface = Color(0xFFCDD6F4), inverseSurface = Color(0xFFCDD6F4), // Text
inverseOnSurface = Color(0xFF1E1E2E), inverseOnSurface = Color(0xFF1E1E2E), // Base
error = Color(0xFFF38BA8), error = Color(0xFFF38BA8), // Red
onError = Color(0xFF11111B), onError = Color(0xFF11111B), // Crust
errorContainer = Color(0xFF45475A), errorContainer = Color(0xFF313244), // Surface 0
onErrorContainer = Color(0xFFF38BA8), onErrorContainer = Color(0xFFF38BA8), // Red
outline = Color(0xFF585B70), outline = Color(0xFF6C7086), // Overlay 0
outlineVariant = Color(0xFF45475A), outlineVariant = Color(0xFF45475A), // Surface 1
scrim = Color(0xFF11111B), scrim = Color(0xFF11111B), // Crust
) )
/** Catppuccin color scheme (light). */ /** Catppuccin color scheme (light). */
val CatppuccinLightColorScheme = val CatppuccinLightColorScheme =
lightColorScheme( lightColorScheme(
primary = Color(0xFF8839EF), primary = Color(0xFF8839EF), // Mauve
onPrimary = Color(0xFFEFF1F5), onPrimary = Color(0xFFEFF1F5), // Base
primaryContainer = Color(0xFFCCD0DA), primaryContainer = Color(0xFFCCD0DA), // Surface 0
onPrimaryContainer = Color(0xFF4C4F69), onPrimaryContainer = Color(0xFF4C4F69), // Text
inversePrimary = Color(0xFFCBA6F7), inversePrimary = Color(0xFFCBA6F7), // Mocha Mauve
secondary = Color(0xFF1E66F5), secondary = Color(0xFF1E66F5), // Blue
onSecondary = Color(0xFFEFF1F5), onSecondary = Color(0xFFEFF1F5), // Base
secondaryContainer = Color(0xFFE6E9EF), secondaryContainer = Color(0xFFE6E9EF), // Mantle
onSecondaryContainer = Color(0xFF4C4F69), onSecondaryContainer = Color(0xFF4C4F69), // Text
tertiary = Color(0xFFEA76CB), tertiary = Color(0xFFEA76CB), // Pink
onTertiary = Color(0xFFEFF1F5), onTertiary = Color(0xFFEFF1F5), // Base
tertiaryContainer = Color(0xFFBCC0CC), tertiaryContainer = Color(0xFFBCC0CC), // Surface 1
onTertiaryContainer = Color(0xFF4C4F69), onTertiaryContainer = Color(0xFF4C4F69), // Text
background = Color(0xFFEFF1F5), background = Color(0xFFEFF1F5), // Base
onBackground = Color(0xFF4C4F69), onBackground = Color(0xFF4C4F69), // Text
surface = Color(0xFFE6E9EF), surface = Color(0xFFEFF1F5), // Base
onSurface = Color(0xFF4C4F69), onSurface = Color(0xFF4C4F69), // Text
surfaceVariant = Color(0xFFCCD0DA), surfaceVariant = Color(0xFFCCD0DA), // Surface 0
onSurfaceVariant = Color(0xFF6C6F85), onSurfaceVariant = Color(0xFF6C6F85), // Subtext 0
surfaceTint = Color(0xFF8839EF), surfaceTint = Color(0xFF8839EF), // Mauve
surfaceContainerLowest = Color(0xFFFFFFFF), surfaceContainerLowest = Color(0xFFDCE0E8), // Crust
surfaceContainerLow = Color(0xFFE6E9EF), surfaceContainerLow = Color(0xFFE6E9EF), // Mantle
surfaceContainer = Color(0xFFEFF1F5), surfaceContainer = Color(0xFFEFF1F5), // Base
surfaceContainerHigh = Color(0xFFE6E9EF), surfaceContainerHigh = Color(0xFFCCD0DA), // Surface 0
surfaceContainerHighest = Color(0xFFCCD0DA), surfaceContainerHighest = Color(0xFFBCC0CC), // Surface 1
inverseSurface = Color(0xFF4C4F69), inverseSurface = Color(0xFF4C4F69), // Text
inverseOnSurface = Color(0xFFEFF1F5), inverseOnSurface = Color(0xFFEFF1F5), // Base
error = Color(0xFFD20F39), error = Color(0xFFD20F39), // Red
onError = Color(0xFFEFF1F5), onError = Color(0xFFEFF1F5), // Base
errorContainer = Color(0xFFF2D5CF), errorContainer = Color(0xFFCCD0DA), // Surface 0
onErrorContainer = Color(0xFFD20F39), onErrorContainer = Color(0xFFD20F39), // Red
outline = Color(0xFF9CA0B0), outline = Color(0xFF9CA0B0), // Overlay 0
outlineVariant = Color(0xFFBCC0CC), outlineVariant = Color(0xFFBCC0CC), // Surface 1
scrim = Color(0xFFDCE0E8), scrim = Color(0xFFDCE0E8), // Crust
) )
/** Catppuccin status colors (dark). */ /** Catppuccin status colors (dark). */
val CatppuccinDarkStatusColors = val CatppuccinDarkStatusColors =
HermesStatusColors( HermesStatusColors(
success = Color(0xFFA6E3A1), success = Color(0xFFA6E3A1), // Green
successContainer = Color(0xFF313244), successContainer = Color(0xFF313244), // Surface 0
onSuccess = Color(0xFF11111B), onSuccess = Color(0xFF11111B), // Crust
warning = Color(0xFFF9E2AF), warning = Color(0xFFF9E2AF), // Yellow
warningContainer = Color(0xFF313244), warningContainer = Color(0xFF313244), // Surface 0
onWarning = Color(0xFF11111B), onWarning = Color(0xFF11111B), // Crust
error = Color(0xFFF38BA8), error = Color(0xFFF38BA8), // Red
errorContainer = Color(0xFF313244), errorContainer = Color(0xFF313244), // Surface 0
onError = Color(0xFF11111B), onError = Color(0xFF11111B), // Crust
info = Color(0xFF89B4FA), info = Color(0xFF89B4FA), // Blue
infoContainer = Color(0xFF313244), infoContainer = Color(0xFF313244), // Surface 0
onInfo = Color(0xFF11111B), onInfo = Color(0xFF11111B), // Crust
) )
/** Catppuccin status colors (light). */ /** Catppuccin status colors (light). */
val CatppuccinLightStatusColors = val CatppuccinLightStatusColors =
HermesStatusColors( HermesStatusColors(
success = Color(0xFF40A02B), success = Color(0xFF40A02B), // Green
successContainer = Color(0xFFE6E9EF), successContainer = Color(0xFFCCD0DA), // Surface 0
onSuccess = Color(0xFFE6E9EF), onSuccess = Color(0xFFEFF1F5), // Base
warning = Color(0xFFDF8E1D), warning = Color(0xFFDF8E1D), // Yellow
warningContainer = Color(0xFFE6E9EF), warningContainer = Color(0xFFCCD0DA), // Surface 0
onWarning = Color(0xFFE6E9EF), onWarning = Color(0xFFEFF1F5), // Base
error = Color(0xFFD20F39), error = Color(0xFFD20F39), // Red
errorContainer = Color(0xFFE6E9EF), errorContainer = Color(0xFFCCD0DA), // Surface 0
onError = Color(0xFFE6E9EF), onError = Color(0xFFEFF1F5), // Base
info = Color(0xFF1E66F5), info = Color(0xFF1E66F5), // Blue
infoContainer = Color(0xFFE6E9EF), infoContainer = Color(0xFFCCD0DA), // Surface 0
onInfo = Color(0xFFE6E9EF), onInfo = Color(0xFFEFF1F5), // Base
) )
@@ -119,6 +119,7 @@ internal fun AppearanceSection(
Box(modifier = Modifier.fillMaxWidth()) { Box(modifier = Modifier.fillMaxWidth()) {
OutlinedButton( OutlinedButton(
onClick = { presetsExpanded = true }, onClick = { presetsExpanded = true },
enabled = !useDynamicColors,
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
) { ) {
Text( Text(