Android: designer's review (wrong-move flash seen on dark squares, result card buttons fit, Maia's bar without a doubled rating, «You», titles never a bare year, no menu during a game, «Viewing · back to the game» strip, trainer's count beside its message)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ed7d040bad
commit
8e7eb7863f
14 changed files with 87 additions and 16 deletions
|
|
@ -306,7 +306,13 @@ fun Board(
|
|||
if (i == from || i == to) drawRect(colors.lastMove, cell(i), Size(sq, sq))
|
||||
}
|
||||
alert?.let { (a, b) ->
|
||||
for (sqName in listOf(a, b)) squareIndex(sqName)?.let { drawRect(Color(220, 40, 40, 115), cell(it), Size(sq, sq)) }
|
||||
// A fill and a ring: seen on dark squares of every board too.
|
||||
for (sqName in listOf(a, b)) squareIndex(sqName)?.let {
|
||||
val c = cell(it)
|
||||
drawRect(Color(220, 40, 40, 153), c, Size(sq, sq))
|
||||
val w = with(density) { 3.dp.toPx() }
|
||||
drawRect(Color(186, 26, 26), c + Offset(w / 2, w / 2), Size(sq - w, sq - w), style = Stroke(width = w))
|
||||
}
|
||||
}
|
||||
val chosen = selected
|
||||
if (chosen != null) drawRect(colors.lastMove.copy(alpha = 0.5f), cell(chosen), Size(sq, sq))
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ fun PlayerLine(
|
|||
}
|
||||
if (status != null) {
|
||||
androidx.compose.material3.CircularProgressIndicator(Modifier.size(14.dp), strokeWidth = 2.dp)
|
||||
Text(status, Modifier.padding(start = 6.dp), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1)
|
||||
Text(status, Modifier.padding(start = 6.dp), style = MaterialTheme.typography.labelMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, maxLines = 1, softWrap = false)
|
||||
}
|
||||
Text(
|
||||
result ?: "",
|
||||
|
|
|
|||
|
|
@ -677,6 +677,18 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
val end = lineEnd(g)
|
||||
val endDepth = depth(g, end)
|
||||
val floor = run.meta.floor
|
||||
Column(modifier) {
|
||||
// Looking back during the game: a strip leads back to it (§31.3).
|
||||
if (current != end) {
|
||||
val n = g.nodes[current]
|
||||
val label = if (current == 0) stringResource(R.string.start_position) else (if (n.white) "${n.moveNumber}." else "${n.moveNumber}…") + san(n.san).text
|
||||
Row(
|
||||
Modifier.fillMaxWidth().height(48.dp).background(MaterialTheme.colorScheme.primaryContainer).clickable { go(end) }.padding(horizontal = 16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(stringResource(R.string.play_viewing, label), color = MaterialTheme.colorScheme.onPrimaryContainer, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
}
|
||||
PlayControls(
|
||||
// While Maia thinks the last move is the user's; else hers and the user's before.
|
||||
canTakeBack = if (runThinking) endDepth > floor else endDepth - 1 > floor,
|
||||
|
|
@ -693,6 +705,7 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
onBack = ::back,
|
||||
onForward = ::forward,
|
||||
)
|
||||
}
|
||||
} else Column(modifier) {
|
||||
val p = preview
|
||||
if (p == null && node != null && nodes != null && node.children.size > 1) {
|
||||
|
|
@ -915,14 +928,18 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
} else if (newGame && held.savedTo == null) {
|
||||
stringResource(R.string.new_game)
|
||||
} else {
|
||||
joinKnown(tag("Event"), year(tag("Date"))).ifEmpty { joinKnown(tag("Site")) }
|
||||
.ifEmpty { dbEntry?.let { displayName(it) } ?: "" }
|
||||
// No event: the site, else the database; a year alone is no title.
|
||||
joinKnown(tag("Event")).let { e -> if (e.isEmpty()) e else joinKnown(e, year(tag("Date"))) }
|
||||
.ifEmpty { joinKnown(tag("Site")) }
|
||||
.ifEmpty { (held.savedTo?.first?.let { app.library.entry(it) } ?: dbEntry)?.let { displayName(it) } ?: "" }
|
||||
}
|
||||
val yearInLine = if (joinKnown(tag("Event")).isEmpty()) year(tag("Date")) else ""
|
||||
val round = tag("Round").trim().takeIf { it.isNotEmpty() && it != "?" && it != "-" }
|
||||
val placeLine = if (playGame && run != null) {
|
||||
stringResource(R.string.play_adjourned_sub, stringResource(if (run.meta.userWhite) R.string.play_as_white else R.string.play_as_black), stringResource(R.string.play_untimed))
|
||||
} else joinKnown(
|
||||
if (total > 0 && held.savedTo == null) stringResource(R.string.game_of, place + 1, total) else "",
|
||||
yearInLine,
|
||||
round?.let { stringResource(R.string.tag_round).lowercase() + " " + it } ?: "",
|
||||
)
|
||||
Column(
|
||||
|
|
@ -965,7 +982,8 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
Icon(Icons.Rounded.ChevronRight, stringResource(R.string.next_game))
|
||||
}
|
||||
}
|
||||
Box {
|
||||
// No menu during a game against Maia (§31.3): its moves go by its own buttons.
|
||||
if (!gameOn) Box {
|
||||
IconButton(onClick = { menu = true }) { Icon(Icons.Rounded.MoreVert, stringResource(R.string.menu)) }
|
||||
DropdownMenu(expanded = menu, onDismissRequest = { menu = false }) {
|
||||
// First, and only when there is something to take back (§29.6).
|
||||
|
|
@ -1048,11 +1066,16 @@ fun GameScreen(db: String, startPlace: Int, query: String, onBack: () -> Unit, o
|
|||
// In a game: «thinking…» on Maia's bar while she computes (§31.3).
|
||||
val thinkingText = stringResource(R.string.play_thinking)
|
||||
val maiaThinks = { white: Boolean -> if (gameOn && runThinking && run?.meta?.userWhite != white) thinkingText else null }
|
||||
// In a game against Maia: the user without a name is «You»; Maia's rating is in her name.
|
||||
val youText = stringResource(R.string.play_you)
|
||||
val playName = { white: Boolean ->
|
||||
if (playGame && run?.meta?.userWhite == white && (if (white) whiteName else blackName) == null) youText else null
|
||||
}
|
||||
val whiteBar: @Composable () -> Unit = {
|
||||
PlayerBar(whiteName ?: whiteLabel, elo(tag("WhiteElo")), true, sideResult(result, true), known = whiteName != null, abbreviate = !study, status = maiaThinks(true))
|
||||
PlayerBar(playName(true) ?: whiteName ?: whiteLabel, if (playGame) "" else elo(tag("WhiteElo")), true, sideResult(result, true), known = whiteName != null || playGame, abbreviate = !study, status = maiaThinks(true))
|
||||
}
|
||||
val blackBar: @Composable () -> Unit = {
|
||||
PlayerBar(blackName ?: blackLabel, elo(tag("BlackElo")), false, sideResult(result, false), known = blackName != null, status = maiaThinks(false))
|
||||
PlayerBar(playName(false) ?: blackName ?: blackLabel, if (playGame) "" else elo(tag("BlackElo")), false, sideResult(result, false), known = blackName != null || playGame, status = maiaThinks(false))
|
||||
}
|
||||
val topBar = if (flipped) whiteBar else blackBar
|
||||
val bottomBar = if (flipped) blackBar else whiteBar
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ fun OfferCard(onAccept: () -> Unit, onPlayOn: () -> Unit) {
|
|||
Text(stringResource(R.string.play_her_position_lost), style = MaterialTheme.typography.bodyMedium)
|
||||
Row(Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(onClick = onAccept, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_accept_win)) }
|
||||
OutlinedButton(onClick = onPlayOn, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_to_end)) }
|
||||
OutlinedButton(onClick = onPlayOn, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_on_short)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -164,17 +164,20 @@ fun ResultCard(over: PlayOver, saved: Boolean, onAnalyse: () -> Unit, onRematch:
|
|||
Card {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text(
|
||||
(if (over.result == "1/2-1/2") "½-½" else over.result) + " " + stringResource(over.heading) + (over.detail?.let { " · " + stringResource(it) } ?: ""),
|
||||
(if (over.result == "1/2-1/2") "½-½" else over.result) + " · " + stringResource(over.heading) + (over.detail?.let { " · " + stringResource(it) } ?: ""),
|
||||
Modifier.weight(1f),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
)
|
||||
IconButton(onClick = onClose) { Icon(Icons.Rounded.Close, stringResource(R.string.close)) }
|
||||
}
|
||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(onClick = onAnalyse, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_analyse), maxLines = 1) }
|
||||
OutlinedButton(onClick = onRematch, modifier = Modifier.weight(1f)) { Text(stringResource(R.string.play_rematch).removePrefix("↻ "), maxLines = 1) }
|
||||
OutlinedButton(onClick = onSave, enabled = !saved, modifier = Modifier.weight(1f)) {
|
||||
Text(stringResource(if (saved) R.string.play_saved else R.string.play_save), maxLines = 1)
|
||||
val pad = androidx.compose.foundation.layout.PaddingValues(horizontal = 8.dp)
|
||||
Button(onClick = onAnalyse, modifier = Modifier.weight(1f), contentPadding = pad) { Text(stringResource(R.string.play_analyse_short), maxLines = 1, overflow = TextOverflow.Ellipsis) }
|
||||
OutlinedButton(onClick = onRematch, modifier = Modifier.weight(1f), contentPadding = pad) {
|
||||
Text(stringResource(R.string.play_rematch).removePrefix("↻ "), maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
OutlinedButton(onClick = onSave, enabled = !saved, modifier = Modifier.weight(1f), contentPadding = pad) {
|
||||
Text(stringResource(if (saved) R.string.play_saved else R.string.play_save), maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,8 +202,10 @@ fun TrainScreen(trainer: Trainer, ply0: Int, startFlipped: Boolean, onPly: (Int)
|
|||
changes++
|
||||
}) { Text(stringResource(R.string.train_show)) }
|
||||
} else if (ply > 0 || st.mistakes > 0u) {
|
||||
// With the message of a wrong move, the count stays in sight.
|
||||
Text(
|
||||
stringResource(R.string.train_run, (st.before.runs + 1u).toString()),
|
||||
if (missed && st.hint == null) stringResource(R.string.train_mistakes, st.mistakes.toString())
|
||||
else stringResource(R.string.train_run, (st.before.runs + 1u).toString()),
|
||||
Modifier.padding(end = 12.dp),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
|
|
@ -270,8 +272,9 @@ private fun Result(st: uniffi.mobile_api.TrainState, onAgain: () -> Unit, onExit
|
|||
Text(stringResource(R.string.train_recent, runs), style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
}
|
||||
Row(Modifier.fillMaxWidth().padding(top = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Button(onClick = onAgain, modifier = Modifier.weight(1f).height(48.dp)) { Text(stringResource(R.string.train_again)) }
|
||||
OutlinedButton(onClick = onExit, modifier = Modifier.weight(1f).height(48.dp)) { Text(stringResource(R.string.train_back)) }
|
||||
// The desktop's texts carry their signs; here the buttons are the signs.
|
||||
Button(onClick = onAgain, modifier = Modifier.weight(1f).height(48.dp)) { Text(stringResource(R.string.train_again).removePrefix("↻ "), maxLines = 1) }
|
||||
OutlinedButton(onClick = onExit, modifier = Modifier.weight(1f).height(48.dp)) { Text(stringResource(R.string.train_back).removePrefix("⬅ "), maxLines = 1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -517,4 +517,8 @@
|
|||
<string name="undo_menu">Rückgängig</string>
|
||||
<string name="made_main">Jetzt die Hauptvariante</string>
|
||||
<string name="elo">Elo</string>
|
||||
<string name="play_analyse_short">Analyse</string>
|
||||
<string name="play_on_short">Weiterspielen</string>
|
||||
<string name="play_viewing">Ansicht %1$s · zurück zur Partie ›</string>
|
||||
<string name="start_position">die Ausgangsstellung</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -525,4 +525,8 @@
|
|||
<string name="undo_menu">Deshacer</string>
|
||||
<string name="made_main">Ahora es la línea principal</string>
|
||||
<string name="elo">Elo</string>
|
||||
<string name="play_analyse_short">Analizar</string>
|
||||
<string name="play_on_short">Seguir</string>
|
||||
<string name="play_viewing">Viendo %1$s · volver a la partida ›</string>
|
||||
<string name="start_position">la posición inicial</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -525,4 +525,8 @@
|
|||
<string name="undo_menu">Annuler</string>
|
||||
<string name="made_main">Ligne principale désormais</string>
|
||||
<string name="elo">Elo</string>
|
||||
<string name="play_analyse_short">Analyser</string>
|
||||
<string name="play_on_short">Continuer</string>
|
||||
<string name="play_viewing">Consultation %1$s · retour à la partie ›</string>
|
||||
<string name="start_position">la position initiale</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -525,4 +525,8 @@
|
|||
<string name="undo_menu">Annulla</string>
|
||||
<string name="made_main">Ora è la linea principale</string>
|
||||
<string name="elo">Elo</string>
|
||||
<string name="play_analyse_short">Analizza</string>
|
||||
<string name="play_on_short">Continua</string>
|
||||
<string name="play_viewing">Visione %1$s · torna alla partita ›</string>
|
||||
<string name="start_position">la posizione iniziale</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -518,4 +518,8 @@
|
|||
<string name="undo_menu">Болдырмау</string>
|
||||
<string name="made_main">Енді негізгі нұсқа</string>
|
||||
<string name="elo">Эло</string>
|
||||
<string name="play_analyse_short">Талдау</string>
|
||||
<string name="play_on_short">Жалғастыру</string>
|
||||
<string name="play_viewing">Қарау %1$s · ойынға оралу ›</string>
|
||||
<string name="start_position">бастапқы позиция</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -526,4 +526,8 @@
|
|||
<string name="undo_menu">Desfazer</string>
|
||||
<string name="made_main">Agora é a linha principal</string>
|
||||
<string name="elo">Elo</string>
|
||||
<string name="play_analyse_short">Analisar</string>
|
||||
<string name="play_on_short">Continuar</string>
|
||||
<string name="play_viewing">Vendo %1$s · voltar à partida ›</string>
|
||||
<string name="start_position">a posição inicial</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -533,4 +533,8 @@
|
|||
<string name="undo_menu">Отменить</string>
|
||||
<string name="made_main">Теперь основной вариант</string>
|
||||
<string name="elo">Эло</string>
|
||||
<string name="play_analyse_short">Анализ</string>
|
||||
<string name="play_on_short">Доиграть</string>
|
||||
<string name="play_viewing">Просмотр %1$s · к игре ›</string>
|
||||
<string name="start_position">начальная позиция</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -516,4 +516,8 @@
|
|||
<string name="undo_menu">Bekor qilish</string>
|
||||
<string name="made_main">Endi asosiy variant</string>
|
||||
<string name="elo">Elo</string>
|
||||
<string name="play_analyse_short">Tahlil</string>
|
||||
<string name="play_on_short">Davom etish</string>
|
||||
<string name="play_viewing">Ko‘rish %1$s · o‘yinga qaytish ›</string>
|
||||
<string name="start_position">boshlang‘ich pozitsiya</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -521,4 +521,8 @@
|
|||
<string name="undo_menu">Undo</string>
|
||||
<string name="made_main">Now the main line</string>
|
||||
<string name="elo">Elo</string>
|
||||
<string name="play_analyse_short">Analyse</string>
|
||||
<string name="play_on_short">Play on</string>
|
||||
<string name="play_viewing">Viewing %1$s · back to the game ›</string>
|
||||
<string name="start_position">the starting position</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue