mirror of
https://github.com/kalarina-bit/Matewave.git
synced 2026-11-22 08:06:09 +00:00
Release v1.0.47
This commit is contained in:
@@ -56,7 +56,7 @@ private object BackgroundAssetCache {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AppBackgroundImage(modifier: Modifier = Modifier.fillMaxSize()) {
|
||||
fun AppBackgroundImage() {
|
||||
val context = LocalContext.current
|
||||
|
||||
var bitmap by remember { mutableStateOf(BackgroundAssetCache.cached()) }
|
||||
@@ -72,10 +72,10 @@ fun AppBackgroundImage(modifier: Modifier = Modifier.fillMaxSize()) {
|
||||
Image(
|
||||
bitmap = image,
|
||||
contentDescription = null,
|
||||
modifier = modifier,
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentScale = ContentScale.Crop
|
||||
)
|
||||
} else {
|
||||
Box(modifier = modifier.background(Color(0xFF101413)))
|
||||
Box(modifier = Modifier.fillMaxSize().background(Color(0xFF101413)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,7 @@ package cc.skysparkle.matewave.ui.components
|
||||
|
||||
import cc.skysparkle.matewave.ui.theme.ink
|
||||
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -54,48 +51,51 @@ fun AppBottomBar(
|
||||
.padding(vertical = 6.dp),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
NavItem(iconRes = R.drawable.ic_home, label = stringResource(R.string.nav_home), active = current == BottomTab.HOME, onClick = onHomeClick)
|
||||
|
||||
NavItem(iconRes = R.drawable.ic_friends, label = stringResource(R.string.nav_friends), active = current == BottomTab.FRIENDS, onClick = onFriendsClick)
|
||||
NavItem(iconRes = R.drawable.ic_settings, label = stringResource(R.string.nav_settings), active = current == BottomTab.SETTINGS, onClick = onSettingsClick)
|
||||
|
||||
AccountNavItem(
|
||||
avatarBase64 = accountAvatarBase64,
|
||||
active = current == BottomTab.ACCOUNT,
|
||||
onClick = onAccountClick
|
||||
)
|
||||
NavItem(stringResource(R.string.nav_home), current == BottomTab.HOME, onHomeClick) { tint ->
|
||||
NavIcon(R.drawable.ic_home, tint)
|
||||
}
|
||||
NavItem(stringResource(R.string.nav_friends), current == BottomTab.FRIENDS, onFriendsClick) { tint ->
|
||||
NavIcon(R.drawable.ic_friends, tint)
|
||||
}
|
||||
NavItem(stringResource(R.string.nav_settings), current == BottomTab.SETTINGS, onSettingsClick) { tint ->
|
||||
NavIcon(R.drawable.ic_settings, tint)
|
||||
}
|
||||
NavItem(stringResource(R.string.account_title), current == BottomTab.ACCOUNT, onAccountClick) { tint ->
|
||||
val bitmap = rememberChatImage(accountAvatarBase64, AVATAR_MAX_DIMENSION_PX)
|
||||
if (bitmap != null) {
|
||||
Image(
|
||||
bitmap = bitmap,
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier.size(24.dp).clip(CircleShape)
|
||||
)
|
||||
} else {
|
||||
NavIcon(R.drawable.ic_default_avatar, tint)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Every screen has its own bar, so a tab never changes between active and inactive while shown. */
|
||||
@Composable
|
||||
private fun RowScope.NavItem(iconRes: Int, label: String, active: Boolean, onClick: () -> Unit) {
|
||||
private fun RowScope.NavItem(
|
||||
label: String,
|
||||
active: Boolean,
|
||||
onClick: () -> Unit,
|
||||
icon: @Composable (tint: Color) -> Unit
|
||||
) {
|
||||
val shape = RoundedCornerShape(UiCornerRadius)
|
||||
|
||||
val highlight by animateColorAsState(
|
||||
if (active) ink.copy(alpha = 0.14f) else ink.copy(alpha = 0f),
|
||||
animationSpec = tween(220),
|
||||
label = "navHighlight"
|
||||
)
|
||||
val itemColor by animateColorAsState(
|
||||
if (active) ink else ink.copy(alpha = 0.7f),
|
||||
animationSpec = tween(220),
|
||||
label = "navColor"
|
||||
)
|
||||
val itemColor = if (active) ink else ink.copy(alpha = 0.7f)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.clip(shape)
|
||||
.background(highlight, shape)
|
||||
.background(if (active) ink.copy(alpha = 0.14f) else ink.copy(alpha = 0f), shape)
|
||||
.clickable(onClick = onClick)
|
||||
.padding(vertical = 8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(iconRes),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(itemColor),
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
icon(itemColor)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
label,
|
||||
@@ -106,48 +106,11 @@ private fun RowScope.NavItem(iconRes: Int, label: String, active: Boolean, onCli
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun RowScope.AccountNavItem(avatarBase64: String?, active: Boolean, onClick: () -> Unit) {
|
||||
val shape = RoundedCornerShape(UiCornerRadius)
|
||||
val bitmap = rememberChatImage(avatarBase64, AVATAR_MAX_DIMENSION_PX)
|
||||
val highlight by animateColorAsState(
|
||||
if (active) ink.copy(alpha = 0.14f) else ink.copy(alpha = 0f),
|
||||
animationSpec = tween(220),
|
||||
label = "navHighlight"
|
||||
private fun NavIcon(iconRes: Int, tint: Color) {
|
||||
Image(
|
||||
painter = painterResource(iconRes),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(tint),
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
val itemColor by animateColorAsState(
|
||||
if (active) ink else ink.copy(alpha = 0.7f),
|
||||
animationSpec = tween(220),
|
||||
label = "navColor"
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.clip(shape)
|
||||
.background(highlight, shape)
|
||||
.clickable(onClick = onClick)
|
||||
.padding(vertical = 8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
if (bitmap != null) {
|
||||
Image(
|
||||
bitmap = bitmap,
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
modifier = Modifier.size(24.dp).clip(CircleShape)
|
||||
)
|
||||
} else {
|
||||
Image(
|
||||
painter = painterResource(R.drawable.ic_default_avatar),
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(itemColor),
|
||||
modifier = Modifier.size(24.dp)
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
stringResource(R.string.account_title),
|
||||
color = if (active) itemColor else Color.Transparent,
|
||||
style = MaterialTheme.typography.labelMedium
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,12 +156,11 @@ fun AppDialog(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun DialogText(text: String, modifier: Modifier = Modifier) {
|
||||
fun DialogText(text: String) {
|
||||
Text(
|
||||
text,
|
||||
color = ink.copy(alpha = 0.78f),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
modifier = modifier
|
||||
style = MaterialTheme.typography.bodyLarge
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,8 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cc.skysparkle.matewave.engine.Piece
|
||||
import cc.skysparkle.matewave.engine.PieceColor
|
||||
import cc.skysparkle.matewave.engine.PieceType
|
||||
|
||||
@@ -25,11 +24,11 @@ import cc.skysparkle.matewave.engine.PieceType
|
||||
fun CapturedPiecesRow(
|
||||
captured: List<PieceType>,
|
||||
capturedColor: PieceColor,
|
||||
advantage: Int,
|
||||
modifier: Modifier = Modifier
|
||||
advantage: Int
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
Row(
|
||||
modifier = modifier.fillMaxWidth().height(22.dp),
|
||||
modifier = Modifier.fillMaxWidth().height(22.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(3.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
@@ -37,7 +36,7 @@ fun CapturedPiecesRow(
|
||||
Row(horizontalArrangement = Arrangement.spacedBy((-10).dp)) {
|
||||
repeat(group.size) {
|
||||
Image(
|
||||
painter = painterResource(Piece(type, capturedColor).drawableRes()),
|
||||
bitmap = PieceImages.of(context, type, capturedColor),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
|
||||
@@ -109,7 +109,7 @@ fun ChatDialog(
|
||||
},
|
||||
enabled = text.isNotBlank()
|
||||
) {
|
||||
AppIcon(R.drawable.ic_arrow_forward, size = 20.dp)
|
||||
AppIcon(R.drawable.ic_send, size = 20.dp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Typeface
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -16,6 +16,7 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawWithCache
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -43,7 +44,8 @@ import cc.skysparkle.matewave.ui.theme.HighlightMove
|
||||
import kotlin.math.floor
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
private object PieceImages {
|
||||
/** The twelve piece pictures, decoded once and shared by the board and the other piece views. */
|
||||
internal object PieceImages {
|
||||
@Volatile private var cache: Array<ImageBitmap>? = null
|
||||
|
||||
fun get(context: Context): Array<ImageBitmap> {
|
||||
@@ -51,9 +53,9 @@ private object PieceImages {
|
||||
synchronized(this) {
|
||||
cache?.let { return it }
|
||||
val options = BitmapFactory.Options().apply { inScaled = false }
|
||||
val types = PieceType.values()
|
||||
val loaded = Array(PieceColor.values().size * types.size) { i ->
|
||||
val piece = Piece(types[i % types.size], PieceColor.values()[i / types.size])
|
||||
val types = PieceType.entries
|
||||
val loaded = Array(PieceColor.entries.size * types.size) { i ->
|
||||
val piece = Piece(types[i % types.size], PieceColor.entries[i / types.size])
|
||||
BitmapFactory.decodeResource(context.resources, piece.drawableRes(), options).asImageBitmap()
|
||||
}
|
||||
cache = loaded
|
||||
@@ -61,7 +63,9 @@ private object PieceImages {
|
||||
}
|
||||
}
|
||||
|
||||
fun indexOf(piece: Piece): Int = piece.color.ordinal * PieceType.values().size + piece.type.ordinal
|
||||
fun of(context: Context, type: PieceType, color: PieceColor): ImageBitmap = get(context)[indexOf(type, color)]
|
||||
|
||||
fun indexOf(type: PieceType, color: PieceColor): Int = color.ordinal * PieceType.entries.size + type.ordinal
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -83,12 +87,14 @@ fun ChessBoardView(
|
||||
highlightLastMove: Boolean? = null
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
// Read once: the appearance changes only in settings, while no board is on screen.
|
||||
val appearance = remember { BoardAppearance(context) }
|
||||
val theme = appearance.theme
|
||||
val showCoords = appearance.showCoordinates
|
||||
val imagePieces = appearance.useImagePieces
|
||||
val showLastMove = highlightLastMove ?: appearance.showLastMove
|
||||
val showCheck = appearance.showCheckHighlight
|
||||
val theme = remember { appearance.theme }
|
||||
val showCoords = remember { appearance.showCoordinates }
|
||||
val imagePieces = remember { appearance.useImagePieces }
|
||||
val lastMoveSetting = remember { appearance.showLastMove }
|
||||
val showLastMove = highlightLastMove ?: lastMoveSetting
|
||||
val showCheck = remember { appearance.showCheckHighlight }
|
||||
|
||||
val pieceImages = if (imagePieces) remember(context) { PieceImages.get(context) } else null
|
||||
|
||||
@@ -113,7 +119,7 @@ fun ChessBoardView(
|
||||
var dragSquare by remember { mutableStateOf<Int?>(null) }
|
||||
var dragPos by remember { mutableStateOf<Offset?>(null) }
|
||||
|
||||
Canvas(
|
||||
Spacer(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.aspectRatio(1f)
|
||||
@@ -169,151 +175,161 @@ fun ChessBoardView(
|
||||
)
|
||||
}
|
||||
}
|
||||
) {
|
||||
val cell = size.width / 8f
|
||||
val lastFrom = if (showLastMove) (lastMove?.from ?: -1) else -1
|
||||
val lastTo = if (showLastMove) (lastMove?.to ?: -1) else -1
|
||||
val selected = selectedSquare ?: -1
|
||||
val checkSquare = if (showCheck) (kingInCheckSquare ?: -1) else -1
|
||||
val hint = hintSquare ?: -1
|
||||
val flash = flashSquare ?: -1
|
||||
|
||||
val dSq = dragSquare
|
||||
val dPos = dragPos
|
||||
val liftedSq = if (dSq != null && dPos != null && selected == dSq) dSq else -1
|
||||
val liftedAt: Offset? = if (liftedSq >= 0) dPos else null
|
||||
|
||||
for (row in 0 until 8) {
|
||||
for (col in 0 until 8) {
|
||||
val displayRank = if (flipped) row else 7 - row
|
||||
val displayFile = if (flipped) 7 - col else col
|
||||
val sqIndex = displayRank * 8 + displayFile
|
||||
val isLight = (displayRank + displayFile) % 2 == 1
|
||||
var color = if (isLight) theme.light else theme.dark
|
||||
if (sqIndex == lastFrom || sqIndex == lastTo) color = HighlightLastMove
|
||||
if (sqIndex == hint) color = HighlightHint
|
||||
if (sqIndex == selected) color = HighlightMove
|
||||
if (sqIndex == checkSquare) color = HighlightCheck
|
||||
drawRect(
|
||||
color = color,
|
||||
topLeft = Offset(col * cell, row * cell),
|
||||
size = Size(cell, cell)
|
||||
)
|
||||
if (sqIndex == flash) {
|
||||
drawRect(color = flashColor, topLeft = Offset(col * cell, row * cell), size = Size(cell, cell))
|
||||
}
|
||||
|
||||
if (showCoords) {
|
||||
val labelColor = if (isLight) theme.dark else theme.light
|
||||
if (row == 7) {
|
||||
drawCoordinate(
|
||||
('a' + displayFile).toString(),
|
||||
Offset(col * cell + cell * 0.78f, row * cell + cell * 0.80f),
|
||||
cell, labelColor, coordPaint
|
||||
)
|
||||
}
|
||||
if (col == 0) {
|
||||
drawCoordinate(
|
||||
(displayRank + 1).toString(),
|
||||
Offset(col * cell + cell * 0.10f, row * cell + cell * 0.22f),
|
||||
cell, labelColor, coordPaint
|
||||
)
|
||||
}
|
||||
}
|
||||
if ((targetMask shr sqIndex) and 1L != 0L) {
|
||||
drawCircle(
|
||||
color = HighlightMove,
|
||||
radius = cell * 0.14f,
|
||||
center = Offset(col * cell + cell / 2, row * cell + cell / 2)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val pieceSize = cell * 0.86f
|
||||
val inset = (cell - pieceSize) / 2f
|
||||
val pieceDst = IntSize(pieceSize.roundToInt(), pieceSize.roundToInt())
|
||||
if (pieceImages == null) {
|
||||
glyphPaint.textSize = cell * 0.62f
|
||||
glyphPaint.color = GLYPH_COLOR
|
||||
}
|
||||
for (row in 0 until 8) {
|
||||
for (col in 0 until 8) {
|
||||
val displayRank = if (flipped) row else 7 - row
|
||||
val displayFile = if (flipped) 7 - col else col
|
||||
val pieceSq = displayRank * 8 + displayFile
|
||||
if (pieceSq == liftedSq) continue
|
||||
val piece = board.pieceAt(pieceSq) ?: continue
|
||||
if (pieceImages != null) {
|
||||
drawImage(
|
||||
image = pieceImages[PieceImages.indexOf(piece)],
|
||||
dstOffset = IntOffset(
|
||||
(col * cell + inset).roundToInt(),
|
||||
(row * cell + inset).roundToInt()
|
||||
),
|
||||
dstSize = pieceDst,
|
||||
filterQuality = FilterQuality.Medium
|
||||
)
|
||||
} else {
|
||||
val metrics = glyphPaint.fontMetrics
|
||||
drawContext.canvas.nativeCanvas.drawText(
|
||||
piece.unicode(),
|
||||
col * cell + cell / 2f,
|
||||
row * cell + cell / 2f - (metrics.ascent + metrics.descent) / 2f,
|
||||
glyphPaint
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (liftedAt != null) {
|
||||
val liftedPiece = board.pieceAt(liftedSq)
|
||||
if (liftedPiece != null) {
|
||||
val hover = squareAt(liftedAt.x, liftedAt.y, size.width, flipped)
|
||||
if (hover >= 0 && ((targetMask shr hover) and 1L) != 0L) {
|
||||
val hRank = hover / 8
|
||||
val hFile = hover % 8
|
||||
val hRow = if (flipped) hRank else 7 - hRank
|
||||
val hCol = if (flipped) 7 - hFile else hFile
|
||||
drawRect(
|
||||
color = Color.White.copy(alpha = 0.75f),
|
||||
topLeft = Offset(hCol * cell, hRow * cell),
|
||||
size = Size(cell, cell),
|
||||
style = Stroke(width = cell * 0.07f)
|
||||
)
|
||||
}
|
||||
.drawWithCache {
|
||||
// Sizes and text metrics change only with the board size.
|
||||
val cell = size.width / 8f
|
||||
val pieceSize = cell * 0.86f
|
||||
val inset = (cell - pieceSize) / 2f
|
||||
val pieceDst = IntSize(pieceSize.roundToInt(), pieceSize.roundToInt())
|
||||
val liftedSize = pieceSize * LIFT_SCALE
|
||||
val cx = liftedAt.x
|
||||
val cy = liftedAt.y - cell * 0.55f
|
||||
drawOval(
|
||||
color = Color.Black.copy(alpha = 0.30f),
|
||||
topLeft = Offset(liftedAt.x - liftedSize * 0.36f, liftedAt.y + cell * 0.05f),
|
||||
size = Size(liftedSize * 0.72f, liftedSize * 0.28f)
|
||||
)
|
||||
if (pieceImages != null) {
|
||||
val liftedDst = IntSize(liftedSize.roundToInt(), liftedSize.roundToInt())
|
||||
drawImage(
|
||||
image = pieceImages[PieceImages.indexOf(liftedPiece)],
|
||||
dstOffset = IntOffset(
|
||||
(cx - liftedSize / 2f).roundToInt(),
|
||||
(cy - liftedSize / 2f).roundToInt()
|
||||
),
|
||||
dstSize = liftedDst,
|
||||
filterQuality = FilterQuality.Medium
|
||||
)
|
||||
} else {
|
||||
glyphPaint.textSize = cell * 0.62f * LIFT_SCALE
|
||||
val metrics = glyphPaint.fontMetrics
|
||||
drawContext.canvas.nativeCanvas.drawText(
|
||||
liftedPiece.unicode(),
|
||||
cx,
|
||||
cy - (metrics.ascent + metrics.descent) / 2f,
|
||||
glyphPaint
|
||||
)
|
||||
val liftedDst = IntSize(liftedSize.roundToInt(), liftedSize.roundToInt())
|
||||
val hoverStroke = Stroke(width = cell * 0.07f)
|
||||
val glyphSize = cell * 0.62f
|
||||
glyphPaint.textSize = glyphSize
|
||||
val glyphMetrics = glyphPaint.fontMetrics
|
||||
val glyphShift = (glyphMetrics.ascent + glyphMetrics.descent) / 2f
|
||||
glyphPaint.textSize = glyphSize * LIFT_SCALE
|
||||
val liftedMetrics = glyphPaint.fontMetrics
|
||||
val liftedGlyphShift = (liftedMetrics.ascent + liftedMetrics.descent) / 2f
|
||||
onDrawBehind {
|
||||
val lastFrom = if (showLastMove) (lastMove?.from ?: -1) else -1
|
||||
val lastTo = if (showLastMove) (lastMove?.to ?: -1) else -1
|
||||
val selected = selectedSquare ?: -1
|
||||
val checkSquare = if (showCheck) (kingInCheckSquare ?: -1) else -1
|
||||
val hint = hintSquare ?: -1
|
||||
val flash = flashSquare ?: -1
|
||||
|
||||
val dSq = dragSquare
|
||||
val dPos = dragPos
|
||||
val liftedSq = if (dSq != null && dPos != null && selected == dSq) dSq else -1
|
||||
val liftedAt: Offset? = if (liftedSq >= 0) dPos else null
|
||||
|
||||
for (row in 0 until 8) {
|
||||
for (col in 0 until 8) {
|
||||
val displayRank = if (flipped) row else 7 - row
|
||||
val displayFile = if (flipped) 7 - col else col
|
||||
val sqIndex = displayRank * 8 + displayFile
|
||||
val isLight = (displayRank + displayFile) % 2 == 1
|
||||
var color = if (isLight) theme.light else theme.dark
|
||||
if (sqIndex == lastFrom || sqIndex == lastTo) color = HighlightLastMove
|
||||
if (sqIndex == hint) color = HighlightHint
|
||||
if (sqIndex == selected) color = HighlightMove
|
||||
if (sqIndex == checkSquare) color = HighlightCheck
|
||||
drawRect(
|
||||
color = color,
|
||||
topLeft = Offset(col * cell, row * cell),
|
||||
size = Size(cell, cell)
|
||||
)
|
||||
if (sqIndex == flash) {
|
||||
drawRect(color = flashColor, topLeft = Offset(col * cell, row * cell), size = Size(cell, cell))
|
||||
}
|
||||
|
||||
if (showCoords) {
|
||||
val labelColor = if (isLight) theme.dark else theme.light
|
||||
if (row == 7) {
|
||||
drawCoordinate(
|
||||
FILE_LABELS[displayFile],
|
||||
Offset(col * cell + cell * 0.78f, row * cell + cell * 0.80f),
|
||||
cell, labelColor, coordPaint
|
||||
)
|
||||
}
|
||||
if (col == 0) {
|
||||
drawCoordinate(
|
||||
RANK_LABELS[displayRank],
|
||||
Offset(col * cell + cell * 0.10f, row * cell + cell * 0.22f),
|
||||
cell, labelColor, coordPaint
|
||||
)
|
||||
}
|
||||
}
|
||||
if ((targetMask shr sqIndex) and 1L != 0L) {
|
||||
drawCircle(
|
||||
color = HighlightMove,
|
||||
radius = cell * 0.14f,
|
||||
center = Offset(col * cell + cell / 2, row * cell + cell / 2)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pieceImages == null) {
|
||||
glyphPaint.textSize = glyphSize
|
||||
glyphPaint.color = GLYPH_COLOR
|
||||
}
|
||||
for (row in 0 until 8) {
|
||||
for (col in 0 until 8) {
|
||||
val displayRank = if (flipped) row else 7 - row
|
||||
val displayFile = if (flipped) 7 - col else col
|
||||
val pieceSq = displayRank * 8 + displayFile
|
||||
if (pieceSq == liftedSq) continue
|
||||
val piece = board.pieceAt(pieceSq) ?: continue
|
||||
if (pieceImages != null) {
|
||||
drawImage(
|
||||
image = pieceImages[PieceImages.indexOf(piece.type, piece.color)],
|
||||
dstOffset = IntOffset(
|
||||
(col * cell + inset).roundToInt(),
|
||||
(row * cell + inset).roundToInt()
|
||||
),
|
||||
dstSize = pieceDst,
|
||||
filterQuality = FilterQuality.Medium
|
||||
)
|
||||
} else {
|
||||
drawContext.canvas.nativeCanvas.drawText(
|
||||
piece.unicode(),
|
||||
col * cell + cell / 2f,
|
||||
row * cell + cell / 2f - glyphShift,
|
||||
glyphPaint
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (liftedAt != null) {
|
||||
val liftedPiece = board.pieceAt(liftedSq)
|
||||
if (liftedPiece != null) {
|
||||
val hover = squareAt(liftedAt.x, liftedAt.y, size.width, flipped)
|
||||
if (hover >= 0 && ((targetMask shr hover) and 1L) != 0L) {
|
||||
val hRank = hover / 8
|
||||
val hFile = hover % 8
|
||||
val hRow = if (flipped) hRank else 7 - hRank
|
||||
val hCol = if (flipped) 7 - hFile else hFile
|
||||
drawRect(
|
||||
color = Color.White.copy(alpha = 0.75f),
|
||||
topLeft = Offset(hCol * cell, hRow * cell),
|
||||
size = Size(cell, cell),
|
||||
style = hoverStroke
|
||||
)
|
||||
}
|
||||
val cx = liftedAt.x
|
||||
val cy = liftedAt.y - cell * 0.55f
|
||||
drawOval(
|
||||
color = Color.Black.copy(alpha = 0.30f),
|
||||
topLeft = Offset(liftedAt.x - liftedSize * 0.36f, liftedAt.y + cell * 0.05f),
|
||||
size = Size(liftedSize * 0.72f, liftedSize * 0.28f)
|
||||
)
|
||||
if (pieceImages != null) {
|
||||
drawImage(
|
||||
image = pieceImages[PieceImages.indexOf(liftedPiece.type, liftedPiece.color)],
|
||||
dstOffset = IntOffset(
|
||||
(cx - liftedSize / 2f).roundToInt(),
|
||||
(cy - liftedSize / 2f).roundToInt()
|
||||
),
|
||||
dstSize = liftedDst,
|
||||
filterQuality = FilterQuality.Medium
|
||||
)
|
||||
} else {
|
||||
glyphPaint.textSize = glyphSize * LIFT_SCALE
|
||||
drawContext.canvas.nativeCanvas.drawText(
|
||||
liftedPiece.unicode(),
|
||||
cx,
|
||||
cy - liftedGlyphShift,
|
||||
glyphPaint
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private const val LIFT_SCALE = 1.6f
|
||||
@@ -330,6 +346,9 @@ private fun squareAt(x: Float, y: Float, boardPx: Float, flipped: Boolean): Int
|
||||
|
||||
private val GLYPH_COLOR = Color(0xFF1B1B1B).toArgb()
|
||||
|
||||
private val FILE_LABELS = Array(8) { ('a' + it).toString() }
|
||||
private val RANK_LABELS = Array(8) { (it + 1).toString() }
|
||||
|
||||
private fun DrawScope.drawCoordinate(
|
||||
text: String,
|
||||
position: Offset,
|
||||
|
||||
@@ -7,11 +7,9 @@ import androidx.compose.animation.core.spring
|
||||
import androidx.compose.foundation.LocalIndication
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.interaction.collectIsPressedAsState
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import cc.skysparkle.matewave.ui.theme.LocalInk
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -30,7 +28,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -41,82 +38,74 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cc.skysparkle.matewave.R
|
||||
import cc.skysparkle.matewave.ui.theme.ChessGreen
|
||||
import cc.skysparkle.matewave.ui.theme.GlassShape
|
||||
import cc.skysparkle.matewave.ui.theme.PanelBorder
|
||||
import cc.skysparkle.matewave.ui.theme.PanelFill
|
||||
import cc.skysparkle.matewave.ui.theme.TabletMaxContentWidth
|
||||
import cc.skysparkle.matewave.ui.theme.UiCornerRadius
|
||||
import cc.skysparkle.matewave.ui.theme.glass
|
||||
|
||||
private val UiShape: Shape = RoundedCornerShape(UiCornerRadius)
|
||||
|
||||
@Composable
|
||||
fun GlassScaffold(
|
||||
title: String,
|
||||
onBack: (() -> Unit)? = null,
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
scrollable: Boolean = true,
|
||||
|
||||
bottomBar: (@Composable () -> Unit)? = null,
|
||||
/** Replaces the plain title, e.g. with the opening name and its status badge. */
|
||||
titleContent: (@Composable RowScope.() -> Unit)? = null,
|
||||
content: @Composable ColumnScope.() -> Unit
|
||||
) {
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
|
||||
Column(modifier = Modifier.fillMaxSize().widthIn(max = TabletMaxContentWidth)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().statusBarsPadding().padding(horizontal = 4.dp, vertical = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (onBack != null) {
|
||||
IconButton(onClick = onBack) {
|
||||
AppIcon(
|
||||
R.drawable.ic_arrow_back,
|
||||
size = 24.dp,
|
||||
contentDescription = stringResource(R.string.back)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Spacer(Modifier.width(48.dp))
|
||||
}
|
||||
if (titleContent != null) {
|
||||
Row(modifier = Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically, content = titleContent)
|
||||
} else {
|
||||
Text(
|
||||
title,
|
||||
color = ink,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
modifier = Modifier.weight(1f)
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
|
||||
Column(modifier = Modifier.fillMaxSize().widthIn(max = TabletMaxContentWidth)) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth().statusBarsPadding().padding(horizontal = 4.dp, vertical = 4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (onBack != null) {
|
||||
IconButton(onClick = onBack) {
|
||||
AppIcon(
|
||||
R.drawable.ic_arrow_back,
|
||||
size = 24.dp,
|
||||
contentDescription = stringResource(R.string.back)
|
||||
)
|
||||
}
|
||||
actions()
|
||||
} else {
|
||||
Spacer(Modifier.width(48.dp))
|
||||
}
|
||||
|
||||
val scrollState = rememberScrollState()
|
||||
|
||||
val contentModifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
.padding(horizontal = 16.dp)
|
||||
.then(if (scrollable) Modifier.verticalScroll(scrollState) else Modifier)
|
||||
.then(if (bottomBar == null) Modifier.navigationBarsPadding() else Modifier)
|
||||
.padding(bottom = 16.dp)
|
||||
|
||||
Column(
|
||||
modifier = contentModifier,
|
||||
verticalArrangement = Arrangement.spacedBy(14.dp),
|
||||
content = content
|
||||
)
|
||||
|
||||
if (bottomBar != null) {
|
||||
Box(modifier = Modifier.navigationBarsPadding()) { bottomBar() }
|
||||
if (titleContent != null) {
|
||||
Row(modifier = Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically, content = titleContent)
|
||||
} else {
|
||||
Text(
|
||||
title,
|
||||
color = ink,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
actions()
|
||||
}
|
||||
|
||||
val scrollState = rememberScrollState()
|
||||
|
||||
val contentModifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
.padding(horizontal = 16.dp)
|
||||
.verticalScroll(scrollState)
|
||||
.then(if (bottomBar == null) Modifier.navigationBarsPadding() else Modifier)
|
||||
.padding(bottom = 16.dp)
|
||||
|
||||
Column(
|
||||
modifier = contentModifier,
|
||||
verticalArrangement = Arrangement.spacedBy(14.dp),
|
||||
content = content
|
||||
)
|
||||
|
||||
if (bottomBar != null) {
|
||||
Box(modifier = Modifier.navigationBarsPadding()) { bottomBar() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,44 +130,12 @@ fun GlassButton(
|
||||
content: @Composable RowScope.() -> Unit
|
||||
) {
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
|
||||
CompositionLocalProvider(LocalInk provides Color.White) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.pressScale(interaction)
|
||||
.alpha(if (enabled) 1f else 0.4f)
|
||||
.clip(UiShape)
|
||||
.background(ChessGreen)
|
||||
.then(
|
||||
if (enabled) Modifier.clickable(
|
||||
interactionSource = interaction,
|
||||
indication = LocalIndication.current,
|
||||
onClick = onClick
|
||||
) else Modifier
|
||||
)
|
||||
.padding(horizontal = 20.dp, vertical = 14.dp),
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GlassOutlinedButton(
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
content: @Composable RowScope.() -> Unit
|
||||
) {
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
Row(
|
||||
modifier = modifier
|
||||
.pressScale(interaction)
|
||||
.alpha(if (enabled) 1f else 0.4f)
|
||||
.clip(UiShape)
|
||||
.background(PanelFill)
|
||||
.border(1.dp, PanelBorder, UiShape)
|
||||
.clip(GlassShape)
|
||||
.background(ChessGreen)
|
||||
.then(
|
||||
if (enabled) Modifier.clickable(
|
||||
interactionSource = interaction,
|
||||
@@ -194,11 +151,40 @@ fun GlassOutlinedButton(
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GlassCard(modifier: Modifier = Modifier, shape: Shape = UiShape, content: @Composable ColumnScope.() -> Unit) {
|
||||
fun GlassOutlinedButton(
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
content: @Composable RowScope.() -> Unit
|
||||
) {
|
||||
val interaction = remember { MutableInteractionSource() }
|
||||
Row(
|
||||
modifier = modifier
|
||||
.pressScale(interaction)
|
||||
.alpha(if (enabled) 1f else 0.4f)
|
||||
.clip(GlassShape)
|
||||
.background(PanelFill)
|
||||
.border(1.dp, PanelBorder, GlassShape)
|
||||
.then(
|
||||
if (enabled) Modifier.clickable(
|
||||
interactionSource = interaction,
|
||||
indication = LocalIndication.current,
|
||||
onClick = onClick
|
||||
) else Modifier
|
||||
)
|
||||
.padding(horizontal = 20.dp, vertical = 14.dp),
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GlassCard(modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.glass(shape)
|
||||
.border(1.dp, PanelBorder, shape)
|
||||
.glass()
|
||||
.border(1.dp, PanelBorder, GlassShape)
|
||||
.padding(14.dp),
|
||||
content = content
|
||||
)
|
||||
|
||||
@@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -22,28 +21,22 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cc.skysparkle.matewave.R
|
||||
import cc.skysparkle.matewave.ui.theme.UiCornerRadius
|
||||
import cc.skysparkle.matewave.ui.theme.glass
|
||||
import cc.skysparkle.matewave.ui.theme.ink
|
||||
|
||||
/** Small uppercase caption above a group. */
|
||||
@Composable
|
||||
fun SectionCaption(text: String, modifier: Modifier = Modifier) {
|
||||
Text(
|
||||
text.uppercase(),
|
||||
color = ink.copy(alpha = 0.5f),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
modifier = modifier.padding(start = 4.dp, top = 6.dp)
|
||||
)
|
||||
fun SectionCaption(text: String) {
|
||||
SetupSectionLabel(text, Modifier.padding(start = 4.dp, top = 6.dp))
|
||||
}
|
||||
|
||||
/** Rows of one kind in a single block, instead of a card per row. Separate rows with [ListDivider]. */
|
||||
@Composable
|
||||
fun ListGroup(modifier: Modifier = Modifier, content: @Composable ColumnScope.() -> Unit) {
|
||||
fun ListGroup(content: @Composable ColumnScope.() -> Unit) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.glass(RoundedCornerShape(UiCornerRadius))
|
||||
.glass()
|
||||
.padding(vertical = 2.dp),
|
||||
content = content
|
||||
)
|
||||
@@ -67,11 +60,9 @@ fun ListDivider(inset: Int = 52) {
|
||||
@Composable
|
||||
fun ListRow(
|
||||
title: String,
|
||||
modifier: Modifier = Modifier,
|
||||
subtitle: String? = null,
|
||||
icon: Int? = null,
|
||||
iconTint: Color = ink,
|
||||
titleColor: Color = ink,
|
||||
subtitleColor: Color = ink.copy(alpha = 0.6f),
|
||||
value: String? = null,
|
||||
valueColor: Color = ink.copy(alpha = 0.55f),
|
||||
@@ -81,7 +72,7 @@ fun ListRow(
|
||||
onClick: (() -> Unit)? = null
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.then(if (onClick != null) Modifier.clickable(onClick = onClick) else Modifier)
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
@@ -92,7 +83,7 @@ fun ListRow(
|
||||
icon != null -> { AppIcon(icon, size = 22.dp, tint = iconTint); Spacer(Modifier.width(14.dp)) }
|
||||
}
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(title, color = titleColor, style = MaterialTheme.typography.bodyLarge, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
||||
Text(title, color = ink, style = MaterialTheme.typography.bodyLarge, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
||||
if (subtitle != null) {
|
||||
Text(subtitle, color = subtitleColor, style = MaterialTheme.typography.bodySmall, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
@@ -107,7 +98,7 @@ fun ListRow(
|
||||
}
|
||||
if (chevron) {
|
||||
Spacer(Modifier.width(8.dp))
|
||||
AppIcon(R.drawable.ic_arrow_forward, size = 16.dp, tint = ink.copy(alpha = 0.5f))
|
||||
AppIcon(R.drawable.ic_arrow_forward, size = 20.dp, tint = ink.copy(alpha = 0.7f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package cc.skysparkle.matewave.ui.components
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -10,7 +9,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -34,25 +33,15 @@ import cc.skysparkle.matewave.ui.theme.ink
|
||||
private data class MoveToken(val text: String, val moveIndex: Int?)
|
||||
|
||||
private val BookTint = androidx.compose.ui.graphics.Color(0xFF93DBA3)
|
||||
private val OutOfBookTint = androidx.compose.ui.graphics.Color(0xFFFFB86B)
|
||||
|
||||
/**
|
||||
* Compact move list that scrolls to the current move, with the opening name underneath.
|
||||
* [currentIndex] is the number of moves played to reach the shown position.
|
||||
*/
|
||||
/** Compact move list that scrolls to the last move, with the opening name underneath. */
|
||||
@Composable
|
||||
fun MovesBar(
|
||||
sans: List<String>,
|
||||
startBoard: Board,
|
||||
currentIndex: Int,
|
||||
opening: OpeningName?,
|
||||
modifier: Modifier = Modifier,
|
||||
/** Leading moves that are opening theory; they are tinted in the list. */
|
||||
bookPlies: Int = 0,
|
||||
/** "Theory" or "Out of book from move N"; null hides the status. */
|
||||
bookStatus: String? = null,
|
||||
inBook: Boolean = true,
|
||||
onMoveClick: ((Int) -> Unit)? = null
|
||||
bookPlies: Int = 0
|
||||
) {
|
||||
if (sans.isEmpty() && opening == null) return
|
||||
val tokens = remember(sans, startBoard) {
|
||||
@@ -67,15 +56,15 @@ fun MovesBar(
|
||||
}
|
||||
}
|
||||
val listState = rememberLazyListState()
|
||||
LaunchedEffect(currentIndex, tokens.size) {
|
||||
val target = tokens.indexOfFirst { it.moveIndex == currentIndex - 1 }
|
||||
LaunchedEffect(sans.size, tokens.size) {
|
||||
val target = tokens.indexOfFirst { it.moveIndex == sans.size - 1 }
|
||||
if (target >= 0) listState.animateScrollToItem(maxOf(0, target - 3))
|
||||
}
|
||||
|
||||
Column(modifier = modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
Column(modifier = Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||
if (sans.isNotEmpty()) {
|
||||
LazyRow(state = listState, horizontalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
itemsIndexed(tokens) { _, token ->
|
||||
items(tokens) { token ->
|
||||
val index = token.moveIndex
|
||||
if (index == null) {
|
||||
Text(
|
||||
@@ -85,7 +74,7 @@ fun MovesBar(
|
||||
modifier = Modifier.padding(start = 6.dp, top = 4.dp, bottom = 4.dp)
|
||||
)
|
||||
} else {
|
||||
val current = index == currentIndex - 1
|
||||
val current = index == sans.size - 1
|
||||
Text(
|
||||
token.text,
|
||||
color = if (index < bookPlies) BookTint else ink,
|
||||
@@ -94,38 +83,24 @@ fun MovesBar(
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.then(if (current) Modifier.background(ChessGreen.copy(alpha = 0.45f)) else Modifier)
|
||||
.then(if (onMoveClick != null) Modifier.clickable { onMoveClick(index + 1) } else Modifier)
|
||||
.padding(horizontal = 6.dp, vertical = 4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (opening != null || bookStatus != null) {
|
||||
if (opening != null) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
AppIcon(R.drawable.ic_book, size = 14.dp, tint = if (inBook) BookTint else ink.copy(alpha = 0.5f))
|
||||
AppIcon(R.drawable.ic_book, size = 16.dp, tint = BookTint)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text(
|
||||
opening?.let { "${it.eco} · ${it.name}" } ?: "",
|
||||
"${opening.eco} · ${opening.name}",
|
||||
color = ink.copy(alpha = 0.85f),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f, fill = false)
|
||||
)
|
||||
if (bookStatus != null) {
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(
|
||||
bookStatus,
|
||||
color = if (inBook) BookTint else OutOfBookTint,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
maxLines = 1,
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(6.dp))
|
||||
.background((if (inBook) BookTint else OutOfBookTint).copy(alpha = 0.15f))
|
||||
.padding(horizontal = 6.dp, vertical = 2.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,13 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cc.skysparkle.matewave.R
|
||||
import cc.skysparkle.matewave.engine.Piece
|
||||
import cc.skysparkle.matewave.engine.PieceColor
|
||||
import cc.skysparkle.matewave.engine.PieceType
|
||||
import cc.skysparkle.matewave.ui.theme.PanelBorder
|
||||
@@ -32,6 +31,7 @@ import cc.skysparkle.matewave.ui.theme.ink
|
||||
/** The four promotion pieces, drawn with the same images as the board. */
|
||||
@Composable
|
||||
fun PromotionDialog(color: PieceColor, onChoose: (PieceType) -> Unit, onDismiss: () -> Unit) {
|
||||
val context = LocalContext.current
|
||||
AppDialog(
|
||||
onDismissRequest = onDismiss,
|
||||
title = stringResource(R.string.promotion_title),
|
||||
@@ -63,7 +63,7 @@ fun PromotionDialog(color: PieceColor, onChoose: (PieceType) -> Unit, onDismiss:
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(Piece(type, color).drawableRes()),
|
||||
bitmap = PieceImages.of(context, type, color),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.fillMaxWidth().aspectRatio(1f)
|
||||
)
|
||||
|
||||
@@ -20,10 +20,10 @@ import cc.skysparkle.matewave.ui.theme.ink
|
||||
|
||||
/** Small, quiet spectator counter for the top bar: an eye and "7" or "7/20". */
|
||||
@Composable
|
||||
fun SpectatorBadge(count: Int, max: Int? = null, modifier: Modifier = Modifier) {
|
||||
fun SpectatorBadge(count: Int, max: Int? = null) {
|
||||
val description = stringResource(R.string.spectators_description, count)
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.padding(end = 12.dp)
|
||||
.clip(RoundedCornerShape(50))
|
||||
.background(ink.copy(alpha = 0.10f))
|
||||
|
||||
@@ -59,6 +59,7 @@ import cc.skysparkle.matewave.ui.components.AppBottomBar
|
||||
import cc.skysparkle.matewave.ui.components.BottomTab
|
||||
import cc.skysparkle.matewave.data.ProfileStore
|
||||
import cc.skysparkle.matewave.ui.components.AppIcon
|
||||
import cc.skysparkle.matewave.ui.components.ButtonIcon
|
||||
import cc.skysparkle.matewave.ui.components.GlassOutlinedButton
|
||||
import cc.skysparkle.matewave.ui.components.GlassScaffold
|
||||
import cc.skysparkle.matewave.ui.components.rememberChatImage
|
||||
@@ -136,7 +137,6 @@ fun AccountScreen(
|
||||
)
|
||||
}
|
||||
) {
|
||||
androidx.compose.runtime.CompositionLocalProvider(cc.skysparkle.matewave.ui.theme.LocalInk provides Color.White) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@@ -239,7 +239,6 @@ fun AccountScreen(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.avatarBase64 != null || profile.backgroundBase64 != null) {
|
||||
Text(
|
||||
@@ -247,7 +246,7 @@ fun AccountScreen(
|
||||
color = ink.copy(alpha = 0.55f),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.clickable {
|
||||
ProfileStore.resetAvatarToDefault()
|
||||
ProfileStore.setAvatar(null)
|
||||
ProfileStore.setBackground(null)
|
||||
profile = ProfileStore.get()
|
||||
}
|
||||
@@ -256,6 +255,7 @@ fun AccountScreen(
|
||||
|
||||
if (!profile.levelChosen) {
|
||||
GlassOutlinedButton(onClick = { showLevelPicker = true }, modifier = Modifier.fillMaxWidth()) {
|
||||
ButtonIcon(R.drawable.ic_speed)
|
||||
Text(stringResource(R.string.account_choose_level), color = ink)
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ fun AccountScreen(
|
||||
val curve = remember(profile.elo) { cc.skysparkle.matewave.stats.Stats.ratingCurve(profile.elo) }
|
||||
ListRow(
|
||||
title = stringResource(R.string.account_rating_row),
|
||||
icon = R.drawable.ic_license,
|
||||
icon = R.drawable.ic_rating,
|
||||
iconTint = ChessGreen,
|
||||
value = "${profile.elo}",
|
||||
valueColor = ink,
|
||||
@@ -277,7 +277,7 @@ fun AccountScreen(
|
||||
ListDivider()
|
||||
ListRow(
|
||||
title = stringResource(R.string.study_title),
|
||||
icon = R.drawable.ic_crown,
|
||||
icon = R.drawable.ic_study,
|
||||
value = "${study.learnedCount}/${study.courses.size} · ★${study.masteredCount}",
|
||||
chevron = true,
|
||||
onClick = onStudyClick
|
||||
|
||||
@@ -36,7 +36,7 @@ import cc.skysparkle.matewave.settings.BoardAppearance
|
||||
import cc.skysparkle.matewave.settings.BoardTheme
|
||||
import cc.skysparkle.matewave.ui.components.GlassCard
|
||||
import cc.skysparkle.matewave.ui.components.GlassScaffold
|
||||
import cc.skysparkle.matewave.ui.theme.GlassBorder
|
||||
import cc.skysparkle.matewave.ui.theme.PanelBorder
|
||||
|
||||
@Composable
|
||||
fun AppearanceScreen(onBack: () -> Unit) {
|
||||
@@ -125,7 +125,7 @@ fun AppearanceScreen(onBack: () -> Unit) {
|
||||
@Composable
|
||||
private fun ThemePreview(theme: BoardTheme, showPieces: Boolean) {
|
||||
val shape = RoundedCornerShape(6.dp)
|
||||
Column(modifier = Modifier.size(56.dp).clip(shape).border(1.dp, GlassBorder, shape)) {
|
||||
Column(modifier = Modifier.size(56.dp).clip(shape).border(1.dp, PanelBorder, shape)) {
|
||||
repeat(2) { row ->
|
||||
Row(modifier = Modifier.weight(1f)) {
|
||||
repeat(2) { col ->
|
||||
|
||||
@@ -37,6 +37,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawWithCache
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@@ -175,7 +176,8 @@ fun ConnectionScreen(
|
||||
Text(stringResource(R.string.nearby_create), color = ink, style = MaterialTheme.typography.titleMedium, maxLines = 1)
|
||||
}
|
||||
GlassOutlinedButton(onClick = { pickTime = true }) {
|
||||
Text(timeControl.shortLabel() + " ▾", color = ink, maxLines = 1)
|
||||
Text(timeControl.shortLabel(), color = ink, maxLines = 1)
|
||||
AppIcon(R.drawable.ic_expand, size = 20.dp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,18 +296,26 @@ private fun SearchPulse() {
|
||||
)
|
||||
Column(modifier = Modifier.fillMaxWidth().padding(top = 8.dp), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Box(modifier = Modifier.size(120.dp), contentAlignment = Alignment.Center) {
|
||||
androidx.compose.foundation.Canvas(modifier = Modifier.size(120.dp)) {
|
||||
for (k in 0 until 3) {
|
||||
val p = (phase + k / 3f) % 1f
|
||||
drawCircle(
|
||||
color = ChessGreen.copy(alpha = (1f - p) * 0.45f),
|
||||
radius = size.minDimension / 2f * (0.3f + 0.7f * p),
|
||||
style = androidx.compose.ui.graphics.drawscope.Stroke(width = 2.dp.toPx())
|
||||
)
|
||||
Spacer(
|
||||
modifier = Modifier.size(120.dp).drawWithCache {
|
||||
val ring = androidx.compose.ui.graphics.drawscope.Stroke(width = 2.dp.toPx())
|
||||
// The phase is read while drawing: the pulse redraws without recomposing.
|
||||
onDrawBehind {
|
||||
for (k in 0 until 3) {
|
||||
val p = (phase + k / 3f) % 1f
|
||||
drawCircle(
|
||||
color = ChessGreen.copy(alpha = (1f - p) * 0.45f),
|
||||
radius = size.minDimension / 2f * (0.3f + 0.7f * p),
|
||||
style = ring
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
androidx.compose.foundation.Image(
|
||||
painter = androidx.compose.ui.res.painterResource(R.drawable.piece_white_knight),
|
||||
bitmap = cc.skysparkle.matewave.ui.components.PieceImages.of(
|
||||
LocalContext.current, cc.skysparkle.matewave.engine.PieceType.KNIGHT, cc.skysparkle.matewave.engine.PieceColor.WHITE
|
||||
),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(40.dp)
|
||||
)
|
||||
|
||||
@@ -43,6 +43,7 @@ import cc.skysparkle.matewave.data.FriendsStore
|
||||
import cc.skysparkle.matewave.presence.LocalPresence
|
||||
import cc.skysparkle.matewave.ui.components.AppBottomBar
|
||||
import cc.skysparkle.matewave.ui.components.AppIcon
|
||||
import cc.skysparkle.matewave.ui.components.ButtonIcon
|
||||
import cc.skysparkle.matewave.ui.components.BottomTab
|
||||
import cc.skysparkle.matewave.ui.components.GlassScaffold
|
||||
import cc.skysparkle.matewave.ui.theme.ChessGreen
|
||||
@@ -128,6 +129,7 @@ fun FriendsScreen(
|
||||
Text(stringResource(R.string.friends_nobody_title), color = ink, style = MaterialTheme.typography.titleMedium)
|
||||
Text(stringResource(R.string.friends_nobody_hint), color = ink.copy(alpha = 0.65f), style = MaterialTheme.typography.bodyMedium)
|
||||
GlassButton(onClick = onPlay, modifier = Modifier.fillMaxWidth()) {
|
||||
ButtonIcon(R.drawable.ic_play)
|
||||
Text(stringResource(R.string.friends_play_nearby), color = ink)
|
||||
}
|
||||
return@GlassScaffold
|
||||
@@ -250,7 +252,6 @@ private fun FriendCard(friend: FriendEntry, status: PresenceStatus, onDismiss: (
|
||||
.clip(cc.skysparkle.matewave.ui.components.DialogShape)
|
||||
.background(cc.skysparkle.matewave.ui.components.DialogSurface)
|
||||
) {
|
||||
androidx.compose.runtime.CompositionLocalProvider(cc.skysparkle.matewave.ui.theme.LocalInk provides Color.White) {
|
||||
Box(modifier = Modifier.fillMaxWidth().height(150.dp)) {
|
||||
val bg = cc.skysparkle.matewave.ui.components.rememberChatImage(friend.backgroundBase64)
|
||||
if (bg != null) {
|
||||
@@ -292,7 +293,6 @@ private fun FriendCard(friend: FriendEntry, status: PresenceStatus, onDismiss: (
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
Text(
|
||||
statusText(status, maxOf(friend.lastPlayedMs, friend.lastSeenMs)),
|
||||
|
||||
@@ -33,6 +33,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import cc.skysparkle.matewave.R
|
||||
import cc.skysparkle.matewave.clock.ClockState
|
||||
import cc.skysparkle.matewave.ui.components.DialogText
|
||||
import cc.skysparkle.matewave.ui.components.DialogAction
|
||||
import cc.skysparkle.matewave.ui.components.AppDialog
|
||||
@@ -51,6 +52,7 @@ import cc.skysparkle.matewave.ui.theme.ChessGreen
|
||||
import cc.skysparkle.matewave.viewmodel.GameMode
|
||||
import cc.skysparkle.matewave.viewmodel.GameUiState
|
||||
import cc.skysparkle.matewave.viewmodel.GameViewModel
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
@Composable
|
||||
fun GameScreen(viewModel: GameViewModel, onExit: () -> Unit) {
|
||||
@@ -116,11 +118,9 @@ fun GameScreen(viewModel: GameViewModel, onExit: () -> Unit) {
|
||||
val material = remember(state.board) { cc.skysparkle.matewave.engine.Material.balance(state.board) }
|
||||
val bottomColor = state.myColor
|
||||
val topColor = if (bottomColor == PieceColor.WHITE) PieceColor.BLACK else PieceColor.WHITE
|
||||
val kingInCheckSquare = if (ChessEngine.isInCheck(state.board, state.board.sideToMove)) {
|
||||
state.board.kingSquare(state.board.sideToMove)
|
||||
} else null
|
||||
val kingInCheckSquare = remember(state.board) { ChessEngine.checkedKingSquare(state.board) }
|
||||
|
||||
PlayerRow(state, topColor, isMe = false, material = material)
|
||||
PlayerRow(state, topColor, isMe = false, material = material, clock = viewModel.clockState)
|
||||
|
||||
ChessBoardView(
|
||||
board = state.board,
|
||||
@@ -136,14 +136,13 @@ fun GameScreen(viewModel: GameViewModel, onExit: () -> Unit) {
|
||||
state.handshake == cc.skysparkle.matewave.viewmodel.HandshakeState.PLAYING))
|
||||
)
|
||||
|
||||
PlayerRow(state, bottomColor, isMe = true, material = material)
|
||||
PlayerRow(state, bottomColor, isMe = true, material = material, clock = viewModel.clockState)
|
||||
|
||||
// The move ribbon: only moves here, the opening name lives in the top bar.
|
||||
if (showOpening) {
|
||||
cc.skysparkle.matewave.ui.components.MovesBar(
|
||||
sans = sans,
|
||||
startBoard = start,
|
||||
currentIndex = sans.size,
|
||||
opening = null,
|
||||
bookPlies = bookPlies
|
||||
)
|
||||
@@ -174,6 +173,7 @@ fun GameScreen(viewModel: GameViewModel, onExit: () -> Unit) {
|
||||
modifier = Modifier.weight(1f),
|
||||
enabled = !state.drawOfferSentByMe
|
||||
) {
|
||||
ButtonIcon(R.drawable.ic_draw)
|
||||
Text(
|
||||
if (state.drawOfferSentByMe) stringResource(R.string.draw_offer_waiting) else stringResource(R.string.offer_draw),
|
||||
color = ink,
|
||||
@@ -181,6 +181,7 @@ fun GameScreen(viewModel: GameViewModel, onExit: () -> Unit) {
|
||||
)
|
||||
}
|
||||
GlassOutlinedButton(onClick = { confirmResign = true }, modifier = Modifier.weight(1f)) {
|
||||
ButtonIcon(R.drawable.ic_flag)
|
||||
Text(stringResource(R.string.resign), color = ink, maxLines = 1)
|
||||
}
|
||||
}
|
||||
@@ -193,6 +194,7 @@ fun GameScreen(viewModel: GameViewModel, onExit: () -> Unit) {
|
||||
// The result dialog was closed to look at the board: one tap brings it back.
|
||||
if (state.status != GameStatus.ONGOING && gameOverHidden) {
|
||||
GlassOutlinedButton(onClick = { gameOverHidden = false }, modifier = Modifier.fillMaxWidth()) {
|
||||
ButtonIcon(R.drawable.ic_trophy)
|
||||
Text(stringResource(R.string.game_over_title), color = ink, maxLines = 1)
|
||||
}
|
||||
}
|
||||
@@ -439,7 +441,8 @@ private fun PlayerRow(
|
||||
state: GameUiState,
|
||||
side: PieceColor,
|
||||
isMe: Boolean,
|
||||
material: cc.skysparkle.matewave.engine.MaterialBalance
|
||||
material: cc.skysparkle.matewave.engine.MaterialBalance,
|
||||
clock: StateFlow<ClockState?>
|
||||
) {
|
||||
val active = state.status == GameStatus.ONGOING && state.board.sideToMove == side
|
||||
// Re-read after the game: the rating changes when it ends.
|
||||
@@ -488,9 +491,16 @@ private fun PlayerRow(
|
||||
}
|
||||
SideCaptured(material, side)
|
||||
}
|
||||
state.clockState?.let { cs ->
|
||||
BigClock(if (side == PieceColor.WHITE) cs.whiteMillis else cs.blackMillis, active)
|
||||
}
|
||||
PlayerClock(clock, side, active)
|
||||
}
|
||||
}
|
||||
|
||||
/** Collects the clock here, so its ticks recompose only the clock. */
|
||||
@Composable
|
||||
private fun PlayerClock(clock: StateFlow<ClockState?>, side: PieceColor, active: Boolean) {
|
||||
val clockState by clock.collectAsState()
|
||||
clockState?.let { cs ->
|
||||
BigClock(if (side == PieceColor.WHITE) cs.whiteMillis else cs.blackMillis, active)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ private fun LicenseCard(entry: LicenseEntry, onClick: () -> Unit) {
|
||||
)
|
||||
}
|
||||
}
|
||||
AppIcon(R.drawable.ic_arrow_forward, size = 16.dp, tint = ink.copy(alpha = 0.6f))
|
||||
AppIcon(R.drawable.ic_arrow_forward, size = 20.dp, tint = ink.copy(alpha = 0.7f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import cc.skysparkle.matewave.ui.components.SectionCaption
|
||||
|
||||
import cc.skysparkle.matewave.ui.theme.ink
|
||||
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -42,6 +41,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawWithCache
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -63,7 +63,7 @@ import cc.skysparkle.matewave.ui.components.AppBottomBar
|
||||
import cc.skysparkle.matewave.ui.components.BottomTab
|
||||
import cc.skysparkle.matewave.ui.theme.ChessGreen
|
||||
import cc.skysparkle.matewave.ui.theme.TabletMaxContentWidth
|
||||
import cc.skysparkle.matewave.ui.theme.UiCornerRadius
|
||||
import cc.skysparkle.matewave.ui.theme.GlassShape
|
||||
import cc.skysparkle.matewave.ui.theme.glass
|
||||
import cc.skysparkle.matewave.viewmodel.GameViewModel
|
||||
import cc.skysparkle.matewave.viewmodel.ResumeInfo
|
||||
@@ -142,7 +142,7 @@ fun MainMenuScreen(
|
||||
onClick = { if (profile.levelChosen) onVsAiClick() else showRatingGate = true }
|
||||
)
|
||||
ModeTile(
|
||||
iconRes = R.drawable.ic_profile_photo,
|
||||
iconRes = R.drawable.ic_versus,
|
||||
title = stringResource(R.string.mode_online_title),
|
||||
subtitle = stringResource(R.string.mode_online_subtitle),
|
||||
modifier = Modifier.weight(1f),
|
||||
@@ -180,7 +180,7 @@ fun MainMenuScreen(
|
||||
ListRow(
|
||||
title = stringResource(R.string.study_title),
|
||||
subtitle = stringResource(R.string.study_menu_subtitle),
|
||||
icon = R.drawable.ic_crown,
|
||||
icon = R.drawable.ic_study,
|
||||
chevron = true,
|
||||
onClick = onStudyClick
|
||||
)
|
||||
@@ -248,8 +248,8 @@ private fun ContinueCard(info: ResumeInfo, onClick: () -> Unit) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.glass(RoundedCornerShape(UiCornerRadius))
|
||||
.border(1.dp, ChessGreen.copy(alpha = 0.6f), RoundedCornerShape(UiCornerRadius))
|
||||
.glass()
|
||||
.border(1.dp, ChessGreen.copy(alpha = 0.6f), GlassShape)
|
||||
.clickable(onClick = onClick)
|
||||
.padding(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
@@ -272,7 +272,7 @@ private fun ContinueCard(info: ResumeInfo, onClick: () -> Unit) {
|
||||
private fun ModeTile(iconRes: Int, title: String, subtitle: String, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.glass(RoundedCornerShape(UiCornerRadius))
|
||||
.glass()
|
||||
.clickable(onClick = onClick)
|
||||
.padding(14.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
@@ -328,44 +328,49 @@ internal fun StatsDialog(onDismiss: () -> Unit) {
|
||||
@Composable
|
||||
internal fun MiniRatingGraph(points: List<Int>, modifier: Modifier = Modifier) {
|
||||
val lineInk = ink
|
||||
Canvas(modifier = modifier) {
|
||||
if (points.size < 2) return@Canvas
|
||||
val minV = points.min().toFloat()
|
||||
val maxV = points.max().toFloat()
|
||||
val range = (maxV - minV).coerceAtLeast(1f)
|
||||
val stepX = size.width / (points.size - 1)
|
||||
// Paths, gradient and stroke are built once per size and reused by every redraw.
|
||||
Spacer(
|
||||
modifier = modifier.drawWithCache {
|
||||
if (points.size < 2) return@drawWithCache onDrawBehind {}
|
||||
val minV = points.min().toFloat()
|
||||
val maxV = points.max().toFloat()
|
||||
val range = (maxV - minV).coerceAtLeast(1f)
|
||||
val stepX = size.width / (points.size - 1)
|
||||
|
||||
fun yOf(v: Int) = size.height - ((v - minV) / range) * size.height
|
||||
fun yOf(v: Int) = size.height - ((v - minV) / range) * size.height
|
||||
|
||||
val gridLines = 4
|
||||
for (i in 0..gridLines) {
|
||||
val y = size.height / gridLines * i
|
||||
drawLine(lineInk.copy(alpha = 0.08f), Offset(0f, y), Offset(size.width, y), strokeWidth = 1f)
|
||||
}
|
||||
// Reference line: the rating at the start of the shown history.
|
||||
val zeroY = yOf(points.first())
|
||||
drawLine(lineInk.copy(alpha = 0.3f), Offset(0f, zeroY), Offset(size.width, zeroY), strokeWidth = 1.5f)
|
||||
// Reference line: the rating at the start of the shown history.
|
||||
val zeroY = yOf(points.first())
|
||||
val line = Path().apply {
|
||||
moveTo(0f, yOf(points[0]))
|
||||
points.forEachIndexed { i, v -> if (i > 0) lineTo(i * stepX, yOf(v)) }
|
||||
}
|
||||
val fill = Path().apply {
|
||||
addPath(line)
|
||||
lineTo(size.width, size.height)
|
||||
lineTo(0f, size.height)
|
||||
close()
|
||||
}
|
||||
val fillBrush = Brush.verticalGradient(listOf(ChessGreen.copy(alpha = 0.35f), ChessGreen.copy(alpha = 0f)))
|
||||
val lineStroke = Stroke(width = 4f, cap = StrokeCap.Round)
|
||||
|
||||
val line = Path().apply {
|
||||
moveTo(0f, yOf(points[0]))
|
||||
points.forEachIndexed { i, v -> if (i > 0) lineTo(i * stepX, yOf(v)) }
|
||||
}
|
||||
val fill = Path().apply {
|
||||
addPath(line)
|
||||
lineTo(size.width, size.height)
|
||||
lineTo(0f, size.height)
|
||||
close()
|
||||
}
|
||||
drawPath(
|
||||
fill,
|
||||
brush = Brush.verticalGradient(listOf(ChessGreen.copy(alpha = 0.35f), ChessGreen.copy(alpha = 0f)))
|
||||
)
|
||||
drawPath(line, color = ChessGreen, style = Stroke(width = 4f, cap = StrokeCap.Round))
|
||||
onDrawBehind {
|
||||
val gridLines = 4
|
||||
for (i in 0..gridLines) {
|
||||
val y = size.height / gridLines * i
|
||||
drawLine(lineInk.copy(alpha = 0.08f), Offset(0f, y), Offset(size.width, y), strokeWidth = 1f)
|
||||
}
|
||||
drawLine(lineInk.copy(alpha = 0.3f), Offset(0f, zeroY), Offset(size.width, zeroY), strokeWidth = 1.5f)
|
||||
|
||||
points.forEachIndexed { i, v ->
|
||||
val center = Offset(i * stepX, yOf(v))
|
||||
drawCircle(color = lineInk, radius = 5f, center = center)
|
||||
drawCircle(color = ChessGreen, radius = 3f, center = center)
|
||||
drawPath(fill, brush = fillBrush)
|
||||
drawPath(line, color = ChessGreen, style = lineStroke)
|
||||
|
||||
points.forEachIndexed { i, v ->
|
||||
val center = Offset(i * stepX, yOf(v))
|
||||
drawCircle(color = lineInk, radius = 5f, center = center)
|
||||
drawCircle(color = ChessGreen, radius = 3f, center = center)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import cc.skysparkle.matewave.openings.CourseInfo
|
||||
import cc.skysparkle.matewave.openings.CourseStatus
|
||||
import cc.skysparkle.matewave.openings.artRes
|
||||
import cc.skysparkle.matewave.ui.components.AppIcon
|
||||
import cc.skysparkle.matewave.ui.components.ButtonIcon
|
||||
import cc.skysparkle.matewave.ui.components.GlassButton
|
||||
import cc.skysparkle.matewave.ui.components.GlassScaffold
|
||||
import cc.skysparkle.matewave.ui.components.SetupSegmented
|
||||
@@ -148,7 +149,7 @@ private fun NextAction(overview: StudyOverview, viewModel: OpeningStudyViewModel
|
||||
button = stringResource(R.string.study_start_button)
|
||||
) { if (viewModel.open(firstNew.course)) onOpenTrainer() }
|
||||
nextDueAt != null -> Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
AppIcon(R.drawable.ic_review, size = 16.dp, tint = ink.copy(alpha = 0.55f))
|
||||
AppIcon(R.drawable.ic_review, size = 16.dp, tint = ink.copy(alpha = 0.7f))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(stringResource(R.string.study_next_review, formatDueIn(nextDueAt)), color = ink.copy(alpha = 0.65f), style = MaterialTheme.typography.bodyMedium)
|
||||
}
|
||||
@@ -160,7 +161,7 @@ private fun ActionCard(icon: Int, title: String, subtitle: String?, button: Stri
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.glass(RoundedCornerShape(UiCornerRadius))
|
||||
.glass()
|
||||
.padding(horizontal = 14.dp, vertical = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
@@ -177,7 +178,10 @@ private fun ActionCard(icon: Int, title: String, subtitle: String?, button: Stri
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.width(12.dp))
|
||||
GlassButton(onClick = onClick) { Text(button, color = ink, maxLines = 1) }
|
||||
GlassButton(onClick = onClick) {
|
||||
ButtonIcon(R.drawable.ic_play)
|
||||
Text(button, color = ink, maxLines = 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,7 +234,7 @@ private fun CourseCard(info: CourseInfo, modifier: Modifier, onClick: () -> Unit
|
||||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
AppIcon(R.drawable.ic_timer, size = 12.dp, tint = ink.copy(alpha = 0.55f))
|
||||
AppIcon(R.drawable.ic_timer, size = 14.dp, tint = ink.copy(alpha = 0.7f))
|
||||
Spacer(Modifier.width(4.dp))
|
||||
Text(
|
||||
LocalContext.current.resources.getQuantityString(R.plurals.study_moves_count, info.total, info.total),
|
||||
@@ -266,7 +270,7 @@ private fun CourseCard(info: CourseInfo, modifier: Modifier, onClick: () -> Unit
|
||||
fun Stars(count: Int, size: androidx.compose.ui.unit.Dp = 16.dp) {
|
||||
Row {
|
||||
repeat(3) { i ->
|
||||
AppIcon(R.drawable.ic_star, size = size, tint = if (i < count) StarGold else ink.copy(alpha = 0.2f))
|
||||
AppIcon(R.drawable.ic_star, size = size, tint = if (i < count) StarGold else ink.copy(alpha = 0.3f))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ fun OpeningTrainerScreen(viewModel: OpeningStudyViewModel, onBack: () -> Unit) {
|
||||
}
|
||||
ProgressBar(state.answered.toFloat() / state.asked.size.coerceAtLeast(1))
|
||||
|
||||
MovesBar(sans = sans, startBoard = startBoard, currentIndex = sans.size, opening = opening)
|
||||
MovesBar(sans = sans, startBoard = startBoard, opening = opening)
|
||||
|
||||
ChessBoardView(
|
||||
board = state.board,
|
||||
@@ -142,9 +142,11 @@ fun OpeningTrainerScreen(viewModel: OpeningStudyViewModel, onBack: () -> Unit) {
|
||||
}
|
||||
Row(modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
GlassOutlinedButton(onClick = { viewModel.practiceAgain() }, modifier = Modifier.weight(1f)) {
|
||||
ButtonIcon(R.drawable.ic_replay)
|
||||
Text(stringResource(R.string.study_again), color = ink, maxLines = 1)
|
||||
}
|
||||
GlassButton(onClick = { if (!viewModel.continueStudy()) onBack() }, modifier = Modifier.weight(1f)) {
|
||||
ButtonIcon(R.drawable.ic_next)
|
||||
Text(stringResource(R.string.study_next), color = ink, maxLines = 1)
|
||||
}
|
||||
}
|
||||
@@ -166,6 +168,7 @@ fun OpeningTrainerScreen(viewModel: OpeningStudyViewModel, onBack: () -> Unit) {
|
||||
// A review is not restarted: it would only replay the moves still due.
|
||||
if (state.mode != SessionMode.REVIEW) {
|
||||
GlassOutlinedButton(onClick = { viewModel.restart() }, modifier = Modifier.weight(1f)) {
|
||||
ButtonIcon(R.drawable.ic_restart)
|
||||
Text(stringResource(R.string.study_restart), color = ink, maxLines = 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,6 +287,7 @@ private fun PermissionItem(
|
||||
Text(subtitle, color = ink.copy(alpha = 0.75f), style = MaterialTheme.typography.bodySmall)
|
||||
if (!granted) {
|
||||
GlassOutlinedButton(onClick = onGrant, modifier = Modifier.fillMaxWidth()) {
|
||||
cc.skysparkle.matewave.ui.components.ButtonIcon(R.drawable.ic_approve)
|
||||
Text(stringResource(R.string.perm_grant), color = ink)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import cc.skysparkle.matewave.puzzles.PuzzleRepository
|
||||
import cc.skysparkle.matewave.puzzles.themeTitleRes
|
||||
import cc.skysparkle.matewave.stats.Stats
|
||||
import cc.skysparkle.matewave.ui.components.ButtonIcon
|
||||
import cc.skysparkle.matewave.ui.components.AppIcon
|
||||
import cc.skysparkle.matewave.ui.components.ChessBoardView
|
||||
import cc.skysparkle.matewave.ui.components.GlassButton
|
||||
import cc.skysparkle.matewave.ui.components.GlassOutlinedButton
|
||||
@@ -94,9 +95,7 @@ fun PuzzleSolveScreen(viewModel: GameViewModel, onBack: () -> Unit, onNextPuzzle
|
||||
board = state.board,
|
||||
selectedSquare = state.selectedSquare,
|
||||
legalTargets = state.legalTargetsFromSelected,
|
||||
kingInCheckSquare = if (ChessEngine.isInCheck(state.board, state.board.sideToMove)) {
|
||||
state.board.kingSquare(state.board.sideToMove)
|
||||
} else null,
|
||||
kingInCheckSquare = remember(state.board) { ChessEngine.checkedKingSquare(state.board) },
|
||||
flipped = state.myColor == PieceColor.BLACK,
|
||||
onSquareClick = viewModel::onSquareClicked,
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally).widthIn(max = 560.dp),
|
||||
@@ -109,20 +108,30 @@ fun PuzzleSolveScreen(viewModel: GameViewModel, onBack: () -> Unit, onNextPuzzle
|
||||
|
||||
// The task, in the same format as the status in a game: a dot in the side's colour.
|
||||
val (text, color) = when {
|
||||
state.puzzleSolved -> "✓ " + stringResource(R.string.puzzle_solved) to ChessGreen
|
||||
state.puzzleFailedAttempt -> "✗ " + stringResource(R.string.puzzle_wrong_move) to WrongRed
|
||||
state.puzzleSolved -> stringResource(R.string.puzzle_solved) to ChessGreen
|
||||
state.puzzleFailedAttempt -> stringResource(R.string.puzzle_wrong_move) to WrongRed
|
||||
state.puzzleAutoMoving -> stringResource(R.string.opponent_turn) to ink.copy(alpha = 0.7f)
|
||||
state.myColor == PieceColor.WHITE -> stringResource(R.string.puzzle_find_best_white) to ink
|
||||
else -> stringResource(R.string.puzzle_find_best_black) to ink
|
||||
}
|
||||
// Solved and wrong show a mark instead of the dot
|
||||
val mark = when {
|
||||
state.puzzleSolved -> R.drawable.ic_approve
|
||||
state.puzzleFailedAttempt -> R.drawable.ic_cancel
|
||||
else -> null
|
||||
}
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(
|
||||
Modifier
|
||||
.size(10.dp)
|
||||
.clip(CircleShape)
|
||||
.background(if (state.myColor == PieceColor.WHITE) Color(0xFFF0F0F0) else Color(0xFF222222))
|
||||
.border(1.dp, ink.copy(alpha = 0.5f), CircleShape)
|
||||
)
|
||||
if (mark != null) {
|
||||
AppIcon(mark, size = 20.dp, tint = color)
|
||||
} else {
|
||||
Box(
|
||||
Modifier
|
||||
.size(10.dp)
|
||||
.clip(CircleShape)
|
||||
.background(if (state.myColor == PieceColor.WHITE) Color(0xFFF0F0F0) else Color(0xFF222222))
|
||||
.border(1.dp, ink.copy(alpha = 0.5f), CircleShape)
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(10.dp))
|
||||
Text(text, color = color, style = MaterialTheme.typography.titleMedium)
|
||||
}
|
||||
@@ -174,6 +183,7 @@ fun PuzzleSolveScreen(viewModel: GameViewModel, onBack: () -> Unit, onNextPuzzle
|
||||
}
|
||||
if (next != null) {
|
||||
GlassButton(onClick = { onNextPuzzle(next) }, modifier = Modifier.fillMaxWidth()) {
|
||||
ButtonIcon(R.drawable.ic_next)
|
||||
Text(stringResource(R.string.puzzle_next), color = ink, style = MaterialTheme.typography.titleMedium)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ fun SettingsScreen(
|
||||
ListRow(
|
||||
title = stringResource(R.string.appearance_title),
|
||||
subtitle = stringResource(R.string.appearance_subtitle),
|
||||
icon = R.drawable.ic_board_view,
|
||||
icon = R.drawable.ic_palette,
|
||||
chevron = true,
|
||||
onClick = onOpenAppearance
|
||||
)
|
||||
@@ -260,7 +260,7 @@ private fun AboutRow(iconRes: Int, title: String, subtitle: String, onClick: ()
|
||||
Text(subtitle, color = ink.copy(alpha = 0.65f), style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
cc.skysparkle.matewave.ui.components.AppIcon(
|
||||
R.drawable.ic_arrow_forward, size = 16.dp, tint = ink.copy(alpha = 0.6f)
|
||||
R.drawable.ic_arrow_forward, size = 20.dp, tint = ink.copy(alpha = 0.7f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +101,7 @@ fun SpectatorScreen(target: SpectateTarget, onBackToFriends: () -> Unit) {
|
||||
|
||||
val bottom = if (state.flipped) PieceColor.BLACK else PieceColor.WHITE
|
||||
val material = remember(view.board) { Material.balance(view.board) }
|
||||
val checkSquare = if (ChessEngine.isInCheck(view.board, view.board.sideToMove)) {
|
||||
view.board.kingSquare(view.board.sideToMove)
|
||||
} else null
|
||||
val checkSquare = remember(view.board) { ChessEngine.checkedKingSquare(view.board) }
|
||||
|
||||
SpectatorPlayerRow(view, bottom.opposite(), state, material)
|
||||
ChessBoardView(
|
||||
@@ -123,18 +121,18 @@ fun SpectatorScreen(target: SpectateTarget, onBackToFriends: () -> Unit) {
|
||||
MovesBar(
|
||||
sans = view.moveSans,
|
||||
startBoard = view.startBoard,
|
||||
currentIndex = view.moveSans.size,
|
||||
opening = null,
|
||||
bookPlies = bookPlies
|
||||
)
|
||||
|
||||
GlassOutlinedButton(onClick = viewModel::flip, modifier = Modifier.fillMaxWidth()) {
|
||||
ButtonIcon(R.drawable.ic_board_view)
|
||||
ButtonIcon(R.drawable.ic_flip)
|
||||
Text(stringResource(R.string.spectate_flip), color = ink, maxLines = 1)
|
||||
}
|
||||
|
||||
if (state.phase == SpectatePhase.ENDED && resultHidden) {
|
||||
GlassOutlinedButton(onClick = { resultHidden = false }, modifier = Modifier.fillMaxWidth()) {
|
||||
ButtonIcon(R.drawable.ic_trophy)
|
||||
Text(stringResource(R.string.game_over_title), color = ink, maxLines = 1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import cc.skysparkle.matewave.ui.components.AppIcon
|
||||
import cc.skysparkle.matewave.ui.components.ButtonIcon
|
||||
import cc.skysparkle.matewave.ui.components.SectionCaption
|
||||
import cc.skysparkle.matewave.ui.components.TimeControlGrid
|
||||
import cc.skysparkle.matewave.ui.components.displayName
|
||||
@@ -35,6 +36,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import cc.skysparkle.matewave.ui.components.SetupSegmented
|
||||
import cc.skysparkle.matewave.ui.theme.ChessGreen
|
||||
import cc.skysparkle.matewave.ui.theme.PanelBorder
|
||||
@@ -75,6 +77,7 @@ fun VsAiSetupScreen(
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
ButtonIcon(R.drawable.ic_play)
|
||||
Text(
|
||||
stringResource(R.string.vsai_play_summary, difficultyLabel(difficulty), timeControl.displayName()),
|
||||
color = ink,
|
||||
@@ -124,8 +127,8 @@ fun VsAiSetupScreen(
|
||||
|
||||
SectionCaption(stringResource(R.string.your_color))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
ColorChip(R.drawable.ic_white_colour, stringResource(R.string.color_white), color == PieceColor.WHITE) { color = PieceColor.WHITE }
|
||||
ColorChip(R.drawable.ic_black_colour, stringResource(R.string.color_black), color == PieceColor.BLACK) { color = PieceColor.BLACK }
|
||||
ColorChip(R.drawable.piece_white_king, stringResource(R.string.color_white), color == PieceColor.WHITE) { color = PieceColor.WHITE }
|
||||
ColorChip(R.drawable.piece_black_king, stringResource(R.string.color_black), color == PieceColor.BLACK) { color = PieceColor.BLACK }
|
||||
ColorChip(R.drawable.ic_random_colour, stringResource(R.string.color_random), color == null) { color = null }
|
||||
}
|
||||
|
||||
@@ -154,11 +157,20 @@ private fun ColorChip(iconRes: Int, text: String, selected: Boolean, onClick: ()
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(iconRes),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp)
|
||||
)
|
||||
// The king from the board's own piece set; random is half white, half black
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(26.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color(0xFF9AA0A8)),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(iconRes),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
}
|
||||
Text(text, color = ink, style = MaterialTheme.typography.bodySmall)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,10 @@ val GlassShape: Shape = RoundedCornerShape(UiCornerRadius)
|
||||
|
||||
val TabletMaxContentWidth = 600.dp
|
||||
|
||||
fun Modifier.glass(shape: Shape = GlassShape): Modifier = this
|
||||
.clip(shape)
|
||||
fun Modifier.glass(): Modifier = this
|
||||
.clip(GlassShape)
|
||||
.background(PanelFill)
|
||||
|
||||
val GlassBorder = PanelBorder
|
||||
|
||||
val PhotoScrim = Brush.verticalGradient(
|
||||
0.00f to Color.Black.copy(alpha = 0.84f),
|
||||
0.10f to Color.Black.copy(alpha = 0.72f),
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
package cc.skysparkle.matewave.ui.theme
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.ReadOnlyComposable
|
||||
import androidx.compose.runtime.compositionLocalOf
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val LocalInk = compositionLocalOf { Color.White }
|
||||
|
||||
val ink: Color
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
get() = LocalInk.current
|
||||
/** Colour of text and icons on the app's dark background. */
|
||||
val ink = Color.White
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cc.skysparkle.matewave.ui.theme
|
||||
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextFieldDefaults
|
||||
import androidx.compose.material3.darkColorScheme
|
||||
@@ -25,7 +26,8 @@ private val DarkScheme = darkColorScheme(
|
||||
@Composable
|
||||
fun MatewaveTheme(content: @Composable () -> Unit) {
|
||||
MaterialTheme(colorScheme = DarkScheme) {
|
||||
CompositionLocalProvider(LocalInk provides Color.White, content = content)
|
||||
// Text and icons without their own colour are light, so nothing turns black on the dark background
|
||||
CompositionLocalProvider(LocalContentColor provides Color.White, content = content)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user