Release 1.0.50

- Rename Board appearance to Appearance and add app color styles:
  Matewave, pastel Lavender, Peach, Mint, Sky and Device (Material You)
- Rating chip on the home screen no longer opens statistics
- Draw and resign button labels no longer cut off
This commit is contained in:
2026-11-11 08:55:51 +02:00
parent c2ee9f2c02
commit 77c438ff66
23 changed files with 355 additions and 46 deletions
@@ -73,6 +73,7 @@ class MainActivity : ComponentActivity() {
runCatching { cc.skysparkle.matewave.puzzles.PuzzleRepository.load(appContext) }
}
cc.skysparkle.matewave.ui.theme.AppThemeState.load(this)
setContent {
MatewaveTheme {
androidx.compose.foundation.layout.Box(
@@ -24,6 +24,7 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import cc.skysparkle.matewave.R
import cc.skysparkle.matewave.ui.theme.AppBackground
import cc.skysparkle.matewave.ui.theme.AppThemeState
import cc.skysparkle.matewave.ui.theme.ChessGreen
import cc.skysparkle.matewave.ui.theme.Lime
import kotlinx.coroutines.Dispatchers
@@ -73,6 +74,9 @@ private val ForestTint = ColorFilter.colorMatrix(
)
)
/** For the other styles the forest turns almost grey, so it never fights their colours. */
private val NeutralForestTint = ColorFilter.colorMatrix(ColorMatrix().apply { setToSaturation(0.12f) })
/**
* The misty forest artwork, deeply darkened so it reads as texture: the mist stays
* visible behind the headings at the top and fades into near-black lower down.
@@ -95,7 +99,7 @@ fun AppBackdrop() {
contentDescription = null,
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
colorFilter = ForestTint
colorFilter = if (AppThemeState.palette.greenBackdrop) ForestTint else NeutralForestTint
)
}
Box(
@@ -50,8 +50,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
val DialogSurface = cc.skysparkle.matewave.ui.theme.Surface1
val DialogAccent = cc.skysparkle.matewave.ui.theme.ChessGreen
val DialogSurface: Color get() = cc.skysparkle.matewave.ui.theme.Surface1
val DialogAccent: Color get() = cc.skysparkle.matewave.ui.theme.ChessGreen
val DialogShape = RoundedCornerShape(28.dp)
@Composable
@@ -156,7 +156,7 @@ fun GlassButton(
onClick = onClick
) else Modifier
)
.padding(horizontal = 22.dp, vertical = 15.dp),
.padding(horizontal = 16.dp, vertical = 15.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
content = content
@@ -186,7 +186,7 @@ fun GlassOutlinedButton(
onClick = onClick
) else Modifier
)
.padding(horizontal = 22.dp, vertical = 15.dp),
.padding(horizontal = 16.dp, vertical = 15.dp),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
content = content
@@ -12,6 +12,13 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.ui.text.style.TextOverflow
import cc.skysparkle.matewave.ui.theme.AppPalette
import cc.skysparkle.matewave.ui.theme.AppStyle
import cc.skysparkle.matewave.ui.theme.AppThemeState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Switch
@@ -25,7 +32,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
@@ -51,6 +57,13 @@ fun AppearanceScreen(onBack: () -> Unit) {
var openingBar by remember { mutableStateOf(appearance.showOpening) }
GlassScaffold(title = stringResource(R.string.appearance_title), onBack = onBack) {
Text(
stringResource(R.string.app_style_title),
color = ink,
style = MaterialTheme.typography.titleMedium
)
StylePicker()
Text(
stringResource(R.string.appearance_board_theme),
color = ink,
@@ -77,7 +90,7 @@ fun AppearanceScreen(onBack: () -> Unit) {
)
if (candidate == theme) {
cc.skysparkle.matewave.ui.components.AppIcon(
R.drawable.ic_check_box, size = 20.dp, tint = Color(0xFF7BE495)
R.drawable.ic_check_box, size = 20.dp, tint = cc.skysparkle.matewave.ui.theme.ChessGreen
)
}
}
@@ -127,6 +140,85 @@ fun AppearanceScreen(onBack: () -> Unit) {
}
}
/** App colour styles as swatches, three per row; the device style follows the wallpaper. */
@Composable
private fun StylePicker() {
val context = LocalContext.current
val selected = AppThemeState.style
val styles = remember { AppStyle.available }
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
styles.chunked(3).forEach { row ->
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
row.forEach { style ->
StyleSwatch(
style = style,
palette = remember(style) { AppThemeState.paletteFor(context, style) },
selected = style == selected,
modifier = Modifier.weight(1f),
onClick = { AppThemeState.select(context, style) }
)
}
repeat(3 - row.size) { Spacer(Modifier.weight(1f)) }
}
}
if (selected == AppStyle.DEVICE) {
Text(
stringResource(R.string.app_style_device_hint),
color = ink.copy(alpha = 0.6f),
style = MaterialTheme.typography.bodySmall
)
}
}
}
@Composable
private fun StyleSwatch(
style: AppStyle,
palette: AppPalette,
selected: Boolean,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
val shape = RoundedCornerShape(18.dp)
Column(
modifier = modifier
.clip(shape)
.background(palette.surface1)
.border(if (selected) 2.dp else 1.dp, if (selected) palette.accent else PanelBorder, shape)
.clickable(onClick = onClick)
.padding(vertical = 12.dp, horizontal = 6.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Box(contentAlignment = Alignment.BottomEnd) {
Box(
modifier = Modifier.size(44.dp).clip(CircleShape).background(palette.accent),
contentAlignment = Alignment.Center
) {
if (selected) {
cc.skysparkle.matewave.ui.components.AppIcon(
R.drawable.ic_check_box, size = 20.dp, tint = palette.onAccent
)
}
}
Box(
modifier = Modifier
.size(20.dp)
.clip(CircleShape)
.background(palette.action)
.border(2.dp, palette.surface1, CircleShape)
)
}
Spacer(Modifier.height(8.dp))
Text(
stringResource(style.titleRes),
color = ink,
style = MaterialTheme.typography.labelLarge,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
@Composable
private fun ThemePreview(theme: BoardTheme, showPieces: Boolean) {
val shape = RoundedCornerShape(6.dp)
@@ -179,12 +179,14 @@ fun GameScreen(viewModel: GameViewModel, onExit: () -> Unit) {
Text(
if (state.drawOfferSentByMe) stringResource(R.string.draw_offer_waiting) else stringResource(R.string.offer_draw),
color = ink,
maxLines = 1
style = MaterialTheme.typography.labelLarge,
maxLines = 1,
overflow = androidx.compose.ui.text.style.TextOverflow.Ellipsis
)
}
GlassOutlinedButton(onClick = { confirmResign = true }, modifier = Modifier.weight(1f)) {
ButtonIcon(R.drawable.ic_flag)
Text(stringResource(R.string.resign), color = ink, maxLines = 1)
Text(stringResource(R.string.resign), color = ink, style = MaterialTheme.typography.labelLarge, maxLines = 1)
}
}
ChatButton(
@@ -130,7 +130,6 @@ fun MainMenuScreen(
modifier = Modifier
.clip(RoundedCornerShape(50))
.background(Surface2)
.clickable { showStats = true }
.padding(start = 10.dp, end = 14.dp, top = 8.dp, bottom = 8.dp),
verticalAlignment = Alignment.CenterVertically
) {
@@ -0,0 +1,144 @@
package cc.skysparkle.matewave.ui.theme
import android.content.Context
import android.os.Build
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import cc.skysparkle.matewave.R
/** The colours every screen is drawn with. The app stays dark in every style. */
data class AppPalette(
/** Highlights, selected states, progress. */
val accent: Color,
/** The one main action on a screen. */
val action: Color,
/** Text and icons on top of [accent] or [action]. */
val onAccent: Color,
val background: Color,
val surface1: Color,
val surface2: Color,
/** The forest backdrop keeps its green cast only with the original colours. */
val greenBackdrop: Boolean = false
)
enum class AppStyle(val titleRes: Int) {
MATEWAVE(R.string.app_style_matewave),
LAVENDER(R.string.app_style_lavender),
PEACH(R.string.app_style_peach),
MINT(R.string.app_style_mint),
SKY(R.string.app_style_sky),
DEVICE(R.string.app_style_device);
companion object {
/** Wallpaper colours exist from Android 12. */
val deviceSupported: Boolean get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
val available: List<AppStyle> get() = entries.filter { it != DEVICE || deviceSupported }
}
}
private val MatewavePalette = AppPalette(
accent = Color(0xFF35E07E),
action = Color(0xFFE3F84B),
onAccent = Color(0xFF0B1610),
background = Color(0xFF0C0F0E),
surface1 = Color(0xFF161B19),
surface2 = Color(0xFF1F2623),
greenBackdrop = true
)
private val LavenderPalette = AppPalette(
accent = Color(0xFFC8B6FF),
action = Color(0xFFFFC6E5),
onAccent = Color(0xFF1E1630),
background = Color(0xFF0F0E14),
surface1 = Color(0xFF1A1822),
surface2 = Color(0xFF25222F)
)
private val PeachPalette = AppPalette(
accent = Color(0xFFFFB59E),
action = Color(0xFFFFE08A),
onAccent = Color(0xFF2A1710),
background = Color(0xFF12100E),
surface1 = Color(0xFF1D1A17),
surface2 = Color(0xFF28231F)
)
private val MintPalette = AppPalette(
accent = Color(0xFF9EE7C8),
action = Color(0xFFD8F5A8),
onAccent = Color(0xFF0F231B),
background = Color(0xFF0D110F),
surface1 = Color(0xFF171C1A),
surface2 = Color(0xFF202724)
)
private val SkyPalette = AppPalette(
accent = Color(0xFFA5CBFF),
action = Color(0xFFB8F1EE),
onAccent = Color(0xFF0F1A2A),
background = Color(0xFF0D1014),
surface1 = Color(0xFF171B21),
surface2 = Color(0xFF20252D)
)
/** The selected style, kept in compose state so every screen recolours at once. */
object AppThemeState {
private const val PREFS = "app_theme"
private const val KEY_STYLE = "style"
var style by mutableStateOf(AppStyle.MATEWAVE)
private set
var palette by mutableStateOf(MatewavePalette)
private set
/** Reads the saved style; call once before the first frame. */
fun load(context: Context) {
val saved = context.applicationContext
.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
.getString(KEY_STYLE, null)
val style = AppStyle.entries.firstOrNull { it.name == saved } ?: AppStyle.MATEWAVE
applyStyle(context, style)
}
fun select(context: Context, style: AppStyle) {
context.applicationContext
.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
.edit().putString(KEY_STYLE, style.name).apply()
applyStyle(context, style)
}
private fun applyStyle(context: Context, requested: AppStyle) {
val style = if (requested == AppStyle.DEVICE && !AppStyle.deviceSupported) AppStyle.MATEWAVE else requested
this.style = style
palette = paletteFor(context, style)
}
/** Preview colours for the style picker. */
fun paletteFor(context: Context, style: AppStyle): AppPalette = when (style) {
AppStyle.MATEWAVE -> MatewavePalette
AppStyle.LAVENDER -> LavenderPalette
AppStyle.PEACH -> PeachPalette
AppStyle.MINT -> MintPalette
AppStyle.SKY -> SkyPalette
AppStyle.DEVICE -> devicePalette(context)
}
private fun devicePalette(context: Context): AppPalette {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return MatewavePalette
val scheme = dynamicDarkColorScheme(context)
return AppPalette(
accent = scheme.primary,
action = scheme.tertiary,
onAccent = scheme.onPrimary,
background = scheme.background,
surface1 = scheme.surfaceContainer,
surface2 = scheme.surfaceContainerHigh
)
}
}
@@ -8,7 +8,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.dp
val PanelFill = Surface1
val PanelFill: Color get() = Surface1
val PanelBorder = Color.White.copy(alpha = 0.06f)
val UiCornerRadius = 22.dp
@@ -22,4 +22,4 @@ fun Modifier.glass(): Modifier = this
val DialogScrimColor = Color.Black.copy(alpha = 0.70f)
val FloatingBarFill = Surface2
val FloatingBarFill: Color get() = Surface2
@@ -15,35 +15,27 @@ import androidx.compose.ui.text.font.FontWeight
import cc.skysparkle.matewave.R
import androidx.compose.ui.unit.sp
/** Neon green: the brand accent for highlights, selected states and progress. */
val ChessGreen = Color(0xFF35E07E)
val ChessGreenDark = Color(0xFF123D25)
// The interface colours follow the selected style (see AppPalette); reading them in
// composition subscribes the screen, so a new style recolours everything at once.
/** Lime: the one colour for the main action on a screen. */
val Lime = Color(0xFFE3F84B)
/** Accent: highlights, selected states and progress. Neon green in the original style. */
val ChessGreen: Color get() = AppThemeState.palette.accent
/** The one colour for the main action on a screen. Lime in the original style. */
val Lime: Color get() = AppThemeState.palette.action
/** Text and icons on top of [ChessGreen] or [Lime]. */
val OnAccent = Color(0xFF0B1610)
val OnAccent: Color get() = AppThemeState.palette.onAccent
val AppBackground = Color(0xFF0C0F0E)
val Surface1 = Color(0xFF161B19)
val Surface2 = Color(0xFF1F2623)
val AppBackground: Color get() = AppThemeState.palette.background
val Surface1: Color get() = AppThemeState.palette.surface1
val Surface2: Color get() = AppThemeState.palette.surface2
val HighlightMove = Color(0x8858A6FF)
val HighlightCheck = Color(0x88E53935)
val HighlightLastMove = Color(0x664FC3F7)
val HighlightHint = Color(0x88FFC107)
private val DarkScheme = darkColorScheme(
primary = ChessGreen,
onPrimary = OnAccent,
secondary = Lime,
onSecondary = OnAccent,
background = AppBackground,
surface = Surface1,
surfaceVariant = Surface2
)
/** Wide display face for the big headings: the brand voice of the app. */
val DisplayFont = FontFamily(
Font(R.font.unbounded_semibold, FontWeight.SemiBold),
@@ -95,7 +87,16 @@ val HeroTextStyle = TextStyle(
/** The app has a single dark theme; system bars are set up in MainActivity. */
@Composable
fun MatewaveTheme(content: @Composable () -> Unit) {
MaterialTheme(colorScheme = DarkScheme, typography = AppTypography) {
val scheme = darkColorScheme(
primary = ChessGreen,
onPrimary = OnAccent,
secondary = Lime,
onSecondary = OnAccent,
background = AppBackground,
surface = Surface1,
surfaceVariant = Surface2
)
MaterialTheme(colorScheme = scheme, typography = AppTypography) {
// Text and icons without their own colour are light, so nothing turns black on the dark background
CompositionLocalProvider(LocalContentColor provides Color.White, content = content)
}