fix: scope dédié à l'écran de jeu pour annuler le moteur à la sortie

This commit is contained in:
herel committed 2026-08-28 15:41:22 +02:00
1 parent b7426e09eb
commit a115647015
2 files changed
+2 -3

No files matched your search

@@ -41,7 +41,6 @@ fun App(
is Screen.Game -> GameScreen( is Screen.Game -> GameScreen(
config = current.config, config = current.config,
scope = scope,
onFinish = { result -> onFinish = { result ->
screen = Screen.Results(result) screen = Screen.Results(result)
scope.launch { history.save(result) } scope.launch { history.save(result) }
@@ -26,6 +26,7 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue 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.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@@ -37,15 +38,14 @@ import com.livrets.game.GameConfig
import com.livrets.game.GameEngine import com.livrets.game.GameEngine
import com.livrets.game.GameResult import com.livrets.game.GameResult
import com.livrets.game.GameState import com.livrets.game.GameState
import kotlinx.coroutines.CoroutineScope
@Composable @Composable
fun GameScreen( fun GameScreen(
config: GameConfig, config: GameConfig,
scope: CoroutineScope,
onFinish: (GameResult) -> Unit, onFinish: (GameResult) -> Unit,
onQuit: () -> Unit, onQuit: () -> Unit,
) { ) {
val scope = rememberCoroutineScope()
val engine = remember(config) { GameEngine(config, scope, onFinish = onFinish) } val engine = remember(config) { GameEngine(config, scope, onFinish = onFinish) }
val state by engine.state.collectAsState() val state by engine.state.collectAsState()