diff --git a/commonUI/src/commonMain/kotlin/ch/dissem/yaep/ui/common/App.kt b/commonUI/src/commonMain/kotlin/ch/dissem/yaep/ui/common/App.kt index d2358a7..30b83a7 100644 --- a/commonUI/src/commonMain/kotlin/ch/dissem/yaep/ui/common/App.kt +++ b/commonUI/src/commonMain/kotlin/ch/dissem/yaep/ui/common/App.kt @@ -24,7 +24,6 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf 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.alpha import androidx.compose.ui.draw.shadow @@ -114,36 +113,55 @@ fun App( } Box(modifier = modifier) { - Row(modifier = Modifier.blurOnFinished(isSolved)) { - Column(modifier = Modifier.weight(0.6f)) { + AdaptiveGameLayout( + modifier = Modifier.blurOnFinished(isSolved), + grid = { PuzzleGrid( - modifier = Modifier - .aspectRatio(1f) - .fillMaxWidth() - .align(Alignment.CenterHorizontally), +// modifier = Modifier +// .aspectRatio(1f) +// .fillMaxWidth() +// .align(Alignment.CenterHorizontally), grid = game.grid, onUpdate = { horizontalClues.forEach { it.update(game.grid) } verticalClues.forEach { it.update(game.grid) } } ) - } - Column( - modifier = Modifier.padding(start = 16.dp).weight(0.4f).fillMaxHeight() - ) { + }, + clues = { PuzzleClues( - modifier = Modifier, - horizontalClues, - verticalClues + horizontalClues = horizontalClues, + verticalClues = verticalClues ) - - Text(time, fontSize = TextUnit(4f, TextUnitType.Em)) - } - } + }, + time = time + ) EndOfGame(isSolved = isSolved, time = time, onRestart = onNewGame) } } +@Composable +fun AdaptiveGameLayout( + modifier: Modifier = Modifier, + grid: @Composable () -> Unit, + clues: @Composable () -> Unit, + time: String = "00:00" +) { + // TODO: actually use an adaptive layout + Row(modifier = modifier) { + Column(modifier = Modifier.weight(0.6f)) { + grid() + } + Column( + modifier = Modifier.padding(start = 16.dp).weight(0.4f).fillMaxHeight() + ) { + clues() + + Text(time, fontSize = TextUnit(4f, TextUnitType.Em)) + } + } +} + @Composable fun PuzzleGrid( modifier: Modifier = Modifier,