StaveTheme.kt
92 lines · 3.0 KB
Changed in: 0.5.0
| 1 | package dev.stave.ui.theme |
| 2 | |
| 3 | import androidx.compose.foundation.shape.RoundedCornerShape |
| 4 | import androidx.compose.material3.MaterialTheme |
| 5 | import androidx.compose.material3.Shapes |
| 6 | import androidx.compose.material3.darkColorScheme |
| 7 | import androidx.compose.runtime.Composable |
| 8 | import androidx.compose.ui.graphics.Color |
| 9 | import androidx.compose.ui.unit.dp |
| 10 | |
| 11 | /** |
| 12 | * Desktop + mobile version of StaveTheme. Uses standard compose.material3 so it renders |
| 13 | * on Compose Multiplatform Desktop and on Android non-TV. |
| 14 | * |
| 15 | * Android TV flavor has its own StaveTheme wrapper around androidx.tv.material3. |
| 16 | */ |
| 17 | private val StaveColorScheme = darkColorScheme( |
| 18 | primary = AccentAmber, |
| 19 | onPrimary = OnAmber, |
| 20 | primaryContainer = AccentAmberSoft, |
| 21 | onPrimaryContainer = OnPrimary, |
| 22 | |
| 23 | secondary = AccentSage, |
| 24 | onSecondary = SurfaceBase, |
| 25 | secondaryContainer = SurfaceHover, |
| 26 | onSecondaryContainer = OnPrimary, |
| 27 | |
| 28 | tertiary = AccentRose, |
| 29 | onTertiary = SurfaceBase, |
| 30 | tertiaryContainer = AccentRoseSoft, |
| 31 | onTertiaryContainer = OnPrimary, |
| 32 | |
| 33 | background = SurfaceBase, |
| 34 | onBackground = OnPrimary, |
| 35 | |
| 36 | surface = SurfaceBase, |
| 37 | onSurface = OnPrimary, |
| 38 | surfaceVariant = SurfaceRaised, |
| 39 | onSurfaceVariant = OnMuted, |
| 40 | |
| 41 | // outline is an input boundary (text fields, checkbox/radio, outlined |
| 42 | // buttons, slider track) and needs 3:1; outlineVariant stays the |
| 43 | // decorative divider. |
| 44 | outline = OutlineStrong, |
| 45 | outlineVariant = SurfaceDivider, |
| 46 | |
| 47 | // Every slot below was left to darkColorScheme()'s Material baseline, |
| 48 | // which is purple-grey (#211F26 / #2B2930), a lavender inverse surface and |
| 49 | // a pink error. Material3 1.2+ draws DropdownMenu on surfaceContainer, |
| 50 | // AlertDialog on surfaceContainerHigh and Snackbar on inverseSurface, so |
| 51 | // menus, dialogs and every toast came out lavender on a warm-brown app. |
| 52 | surfaceContainerLowest = SurfaceLowest, |
| 53 | surfaceContainerLow = SurfaceBase, |
| 54 | surfaceContainer = SurfaceRaised, |
| 55 | surfaceContainerHigh = SurfaceHover, |
| 56 | surfaceContainerHighest = SurfaceHighest, |
| 57 | surfaceBright = SurfaceBright, |
| 58 | surfaceDim = SurfaceBase, |
| 59 | surfaceTint = AccentAmber, |
| 60 | |
| 61 | inverseSurface = OnPrimary, |
| 62 | inverseOnSurface = SurfaceBase, |
| 63 | inversePrimary = Color(0xFF8A5A14), // 4.81:1 on the inverse surface |
| 64 | |
| 65 | error = AccentRose, |
| 66 | onError = SurfaceBase, |
| 67 | errorContainer = AccentRoseSoft, |
| 68 | onErrorContainer = OnPrimary, |
| 69 | |
| 70 | scrim = Color.Black, |
| 71 | ) |
| 72 | |
| 73 | val StaveShapes = Shapes( |
| 74 | extraSmall = RoundedCornerShape(4.dp), |
| 75 | small = RoundedCornerShape(8.dp), |
| 76 | medium = RoundedCornerShape(12.dp), |
| 77 | large = RoundedCornerShape(20.dp), |
| 78 | extraLarge = RoundedCornerShape(28.dp), |
| 79 | ) |
| 80 | |
| 81 | @Composable |
| 82 | fun StaveTheme( |
| 83 | typography: androidx.compose.material3.Typography = StaveTypography, |
| 84 | content: @Composable () -> Unit, |
| 85 | ) { |
| 86 | MaterialTheme( |
| 87 | colorScheme = StaveColorScheme, |
| 88 | typography = typography, |
| 89 | shapes = StaveShapes, |
| 90 | content = content, |
| 91 | ) |
| 92 | } |


