diff --git a/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/component/alphabet.kt b/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/component/alphabet.kt index 727705d..d36120e 100644 --- a/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/component/alphabet.kt +++ b/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/component/alphabet.kt @@ -25,6 +25,7 @@ package net.opatry.game.wordle.mosaic.component import androidx.compose.runtime.Composable import com.jakewharton.mosaic.Column import com.jakewharton.mosaic.Row +import com.jakewharton.mosaic.Text import net.opatry.game.wordle.AnswerFlag @Composable @@ -33,9 +34,12 @@ fun Alphabet(alphabet: Map) { alphabet.keys.chunked(9).forEach { row -> Row { row.forEach { letter -> + Text(" ") WordleCharCell(letter, alphabet[letter]!!) + Text(" ") } } + Text(" ") } } } diff --git a/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/component/wordle.kt b/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/component/wordle.kt index 3699c85..95680b7 100644 --- a/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/component/wordle.kt +++ b/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/component/wordle.kt @@ -35,18 +35,29 @@ import net.opatry.game.wordle.AnswerFlag @Composable fun WordleGrid(grid: List) { Column { - grid.forEach { row -> - WordleWordRow(row) - } - } -} + // Box drawing: https://en.wikipedia.org/wiki/Box-drawing_character#Box_Drawing + // FIXME dividers length depends on max of row.letters + // good enough for now given that we know it's a 5x6 grid + Text("╭─────┬─────┬─────┬─────┬─────╮") + grid.forEachIndexed { rowIndex, row -> + if (rowIndex > 0) { + Text("├─────┼─────┼─────┼─────┼─────┤") + } + Row { + row.letters.forEachIndexed { cellIndex, char -> + if (cellIndex == 0) + Text("│ ") + else + Text(" │ ") -@Composable -fun WordleWordRow(row: Answer) { - Row { - row.letters.forEachIndexed { index, char -> - WordleCharCell(char, row.flags[index]) + WordleCharCell(char, row.flags[cellIndex]) + + if (cellIndex == row.letters.size - 1) + Text(" │") + } + } } + Text("╰─────┴─────┴─────┴─────┴─────╯") } } @@ -68,15 +79,12 @@ fun WordleCharCell(char: Char, flag: AnswerFlag) { // TODO AnnotatedString " $char " https://github.com/JakeWharton/mosaic/issues/9 Column { Row { - Text(" ") Text( " $char ", color = foregroundColor, background = backgroundColor, style = TextStyle.Bold ) - Text(" ") } - Text("") } } diff --git a/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/gameScreen.kt b/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/gameScreen.kt index 9ff226f..773ee7f 100644 --- a/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/gameScreen.kt +++ b/wordle-compose-mosaic/src/main/java/net/opatry/game/wordle/mosaic/gameScreen.kt @@ -44,6 +44,8 @@ fun GameScreen(viewModel: WordleViewModel) { Alphabet(viewModel.alphabet) } + Text("") + when (val state = viewModel.state) { is State.Won -> { Text("Wordle ${state.wordleId} ${state.answers.size}/${state.maxTries}")