Android UI (WIP)
This commit is contained in:
@@ -24,7 +24,6 @@ import androidx.compose.runtime.getValue
|
|||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
import androidx.compose.ui.draw.shadow
|
import androidx.compose.ui.draw.shadow
|
||||||
@@ -114,36 +113,55 @@ fun App(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box(modifier = modifier) {
|
Box(modifier = modifier) {
|
||||||
Row(modifier = Modifier.blurOnFinished(isSolved)) {
|
AdaptiveGameLayout(
|
||||||
Column(modifier = Modifier.weight(0.6f)) {
|
modifier = Modifier.blurOnFinished(isSolved),
|
||||||
|
grid = {
|
||||||
PuzzleGrid(
|
PuzzleGrid(
|
||||||
modifier = Modifier
|
// modifier = Modifier
|
||||||
.aspectRatio(1f)
|
// .aspectRatio(1f)
|
||||||
.fillMaxWidth()
|
// .fillMaxWidth()
|
||||||
.align(Alignment.CenterHorizontally),
|
// .align(Alignment.CenterHorizontally),
|
||||||
grid = game.grid,
|
grid = game.grid,
|
||||||
onUpdate = {
|
onUpdate = {
|
||||||
horizontalClues.forEach { it.update(game.grid) }
|
horizontalClues.forEach { it.update(game.grid) }
|
||||||
verticalClues.forEach { it.update(game.grid) }
|
verticalClues.forEach { it.update(game.grid) }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
Column(
|
clues = {
|
||||||
modifier = Modifier.padding(start = 16.dp).weight(0.4f).fillMaxHeight()
|
|
||||||
) {
|
|
||||||
PuzzleClues(
|
PuzzleClues(
|
||||||
modifier = Modifier,
|
horizontalClues = horizontalClues,
|
||||||
horizontalClues,
|
verticalClues = verticalClues
|
||||||
verticalClues
|
|
||||||
)
|
)
|
||||||
|
},
|
||||||
Text(time, fontSize = TextUnit(4f, TextUnitType.Em))
|
time = time
|
||||||
}
|
)
|
||||||
}
|
|
||||||
EndOfGame(isSolved = isSolved, time = time, onRestart = onNewGame)
|
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
|
@Composable
|
||||||
fun PuzzleGrid(
|
fun PuzzleGrid(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
|||||||
Reference in New Issue
Block a user