Add restart option
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M360,840L303,784L367,720L360,720Q243,720 161.5,638.5Q80,557 80,440Q80,323 161.5,241.5Q243,160 360,160L600,160Q717,160 798.5,241.5Q880,323 880,440Q880,557 798.5,638.5Q717,720 600,720L600,640Q683,640 741.5,581.5Q800,523 800,440Q800,357 741.5,298.5Q683,240 600,240L360,240Q277,240 218.5,298.5Q160,357 160,440Q160,523 218.5,582.5Q277,642 360,648L376,648L304,576L360,520L520,680L360,840Z"/>
|
||||
</vector>
|
||||
@@ -32,6 +32,7 @@ import androidx.compose.ui.unit.TextUnit
|
||||
import androidx.compose.ui.unit.TextUnitType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ch.dissem.yaep.domain.Clue
|
||||
import ch.dissem.yaep.domain.Game
|
||||
import ch.dissem.yaep.domain.Grid
|
||||
import ch.dissem.yaep.domain.HorizontalClue
|
||||
import ch.dissem.yaep.domain.ItemClass
|
||||
@@ -39,7 +40,6 @@ import ch.dissem.yaep.domain.NeighbourClue
|
||||
import ch.dissem.yaep.domain.OrderClue
|
||||
import ch.dissem.yaep.domain.SameColumnClue
|
||||
import ch.dissem.yaep.domain.TripletClue
|
||||
import ch.dissem.yaep.domain.generateGame
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import yaep.commonui.generated.resources.Res
|
||||
import yaep.commonui.generated.resources.neighbour
|
||||
@@ -59,10 +59,9 @@ class DisplayClue<C : Clue>(val clue: C) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun App(modifier: Modifier = Modifier) {
|
||||
var game by remember { mutableStateOf(generateGame()) }
|
||||
val horizontalClues = remember(game) { game.horizontalClues.map { DisplayClue(it) } }
|
||||
val verticalClues = remember(game) { game.verticalClues.map { DisplayClue(it) } }
|
||||
fun App(modifier: Modifier = Modifier, game: Game, onNewGame: () -> Unit, resetCluesBeacon: Any = Any()) {
|
||||
val horizontalClues = remember(game, resetCluesBeacon) { game.horizontalClues.map { DisplayClue(it) } }
|
||||
val verticalClues = remember(game, resetCluesBeacon) { game.verticalClues.map { DisplayClue(it) } }
|
||||
val timer = remember(game) { GameTimer() }
|
||||
val time by timer.elapsedTime.collectAsState("00:00")
|
||||
var isSolved by remember(game) { mutableStateOf(false) }
|
||||
@@ -104,9 +103,7 @@ fun App(modifier: Modifier = Modifier) {
|
||||
Text(time, fontSize = TextUnit(4f, TextUnitType.Em))
|
||||
}
|
||||
}
|
||||
EndOfGame(isSolved = isSolved, time = time) {
|
||||
game = generateGame()
|
||||
}
|
||||
EndOfGame(isSolved = isSolved, time = time, onRestart = onNewGame)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user