feat: add dark mode with toggle in top bar
- Created UnoTheme.kt with light/dark color schemes - Added dark mode toggle (moon/sun icon) in GameInfoBar - Wrapped all entry points (Desktop, Android, Web) with UnoTheme - Fixed Web entry point to use CanvasBasedWindow - Fixed Math.random() for WASM compatibility
This commit is contained in:
@@ -13,6 +13,7 @@ import androidx.compose.ui.window.application
|
||||
import com.uno.game.GameEngine
|
||||
import com.uno.game.model.*
|
||||
import com.uno.shared.UnoGameScreen
|
||||
import com.uno.shared.UnoTheme
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
fun main() = application {
|
||||
@@ -49,31 +50,33 @@ fun UnoDesktopApp() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!gameStarted) {
|
||||
DesktopStartScreen(onStartGame = { playerCount ->
|
||||
gameState = engine.startGame(playerCount)
|
||||
gameStarted = true
|
||||
})
|
||||
} else {
|
||||
UnoGameScreen(
|
||||
state = gameState,
|
||||
onPlayCard = { card, color ->
|
||||
gameState = engine.playCard(gameState, 0, card, color)
|
||||
},
|
||||
onDrawCard = {
|
||||
gameState = engine.drawCard(gameState, 0)
|
||||
},
|
||||
onCallUno = { gameState = engine.callUno(gameState, 0) }
|
||||
)
|
||||
|
||||
if (gameState.isFinished) {
|
||||
DesktopGameOverScreen(
|
||||
winner = gameState.winner,
|
||||
onPlayAgain = {
|
||||
gameState = engine.startGame()
|
||||
gameStarted = false
|
||||
}
|
||||
UnoTheme {
|
||||
if (!gameStarted) {
|
||||
DesktopStartScreen(onStartGame = { playerCount ->
|
||||
gameState = engine.startGame(playerCount)
|
||||
gameStarted = true
|
||||
})
|
||||
} else {
|
||||
UnoGameScreen(
|
||||
state = gameState,
|
||||
onPlayCard = { card, color ->
|
||||
gameState = engine.playCard(gameState, 0, card, color)
|
||||
},
|
||||
onDrawCard = {
|
||||
gameState = engine.drawCard(gameState, 0)
|
||||
},
|
||||
onCallUno = { gameState = engine.callUno(gameState, 0) }
|
||||
)
|
||||
|
||||
if (gameState.isFinished) {
|
||||
DesktopGameOverScreen(
|
||||
winner = gameState.winner,
|
||||
onPlayAgain = {
|
||||
gameState = engine.startGame()
|
||||
gameStarted = false
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user