Teeny-Tiny-Cleanup

This commit is contained in:
Oliver Rümpelein 2021-08-29 11:17:03 +02:00
parent 0fd44f3b34
commit 44d9e533af
5 changed files with 47 additions and 29 deletions

View file

@ -23,16 +23,14 @@ fun GameBoard(
onDisableReviewMode: () -> Unit, onDisableReviewMode: () -> Unit,
onPointsChange: (Player, Long) -> Unit, onPointsChange: (Player, Long) -> Unit,
onQuestionDone: (QuestionData, QuestionResolution) -> Unit, onQuestionDone: (QuestionData, QuestionResolution) -> Unit,
onExit: () -> Unit
) { ) {
Column(modifier = Modifier.fillMaxHeight().fillMaxWidth()) { Column(modifier = Modifier.fillMaxHeight().fillMaxWidth()) {
Row(
modifier = Modifier.fillMaxHeight(0.2f)
) {
GameHeader( GameHeader(
title = gameData.title, title = gameData.title,
color = gameData.headerColor color = gameData.headerColor,
onExit = onExit
) )
}
Spacer(modifier = Modifier.height(5.dp)) Spacer(modifier = Modifier.height(5.dp))
Row( Row(
modifier = Modifier.fillMaxHeight() modifier = Modifier.fillMaxHeight()

View file

@ -112,8 +112,12 @@ val gameData = Game(
@OptIn(ExperimentalSerializationApi::class) @OptIn(ExperimentalSerializationApi::class)
val gameJson = Json.encodeToString(gameData) val gameJson = Json.encodeToString(gameData)
fun main() {
graphicalApplication()
}
@OptIn(ExperimentalSerializationApi::class) @OptIn(ExperimentalSerializationApi::class)
fun main() = application { fun graphicalApplication() = application {
// TODO: Read Game from JSON // TODO: Read Game from JSON
println(gameJson) println(gameJson)
Window( Window(
@ -164,7 +168,8 @@ fun main() = application {
}, },
onQuestionDone = { question, questionResolution -> onQuestionDone = { question, questionResolution ->
questionsResolved[question] = questionResolution questionsResolved[question] = questionResolution
} },
onExit = ::exitApplication
) )
} else { } else {
EndCard( EndCard(

View file

@ -1,8 +1,8 @@
package components package components
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Column import androidx.compose.material.Button
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Surface import androidx.compose.material.Surface
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -15,16 +15,32 @@ import data.toColor
@Suppress("FunctionName") @Suppress("FunctionName")
@Composable @Composable
fun GameHeader(title: String, color: ColorData?) { fun GameHeader(title: String, color: ColorData?, onExit: () -> Unit) {
Row(
modifier = Modifier.fillMaxHeight(0.2f)
.fillMaxWidth()
) {
Surface( Surface(
color = color.toColor(), color = color.toColor(),
modifier = Modifier.fillMaxSize(1f) modifier = Modifier.fillMaxSize(1f)
) { ) {
Column( Column(
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth(0.9f)
.fillMaxHeight()
) { ) {
Text(text = title, color = Color.LightGray, fontSize = 8.em) Text(text = title, color = Color.LightGray, fontSize = 8.em)
} }
Column(
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.End,
modifier = Modifier.fillMaxSize()
) {
Button(onClick = onExit, colors = ButtonDefaults.buttonColors(Color.Red)) {
Text(text = "X", color = Color.LightGray)
}
}
}
} }
} }

View file

@ -30,7 +30,8 @@ fun QuestionDialogue(
onDismissRequest = { }, onDismissRequest = { },
buttons = { buttons = {
QuestionDialogButtons( QuestionDialogButtons(
topic = topic, topic = topic.topic,
topicColor = topic.color,
questionData = questionData, questionData = questionData,
players = players, players = players,
onPointsChange = onPointsChange, onPointsChange = onPointsChange,

View file

@ -13,15 +13,13 @@ import components.questiondialog.assets.HintText
import components.questiondialog.buttons.DismissButton import components.questiondialog.buttons.DismissButton
import components.questiondialog.player.DeferredDoubleQuestionDialogPlayer import components.questiondialog.player.DeferredDoubleQuestionDialogPlayer
import components.questiondialog.player.QuestionDialogPlayer import components.questiondialog.player.QuestionDialogPlayer
import data.Player import data.*
import data.QuestionData
import data.Topic
import data.toColor
@Suppress("FunctionName") @Suppress("FunctionName")
@Composable @Composable
fun QuestionDialogButtons( fun QuestionDialogButtons(
topic: Topic, topic: String,
topicColor: ColorData?,
questionData: QuestionData, questionData: QuestionData,
players: List<Player>, players: List<Player>,
onPointsChange: (Player, Long) -> Unit, onPointsChange: (Player, Long) -> Unit,
@ -34,7 +32,7 @@ fun QuestionDialogButtons(
Box( Box(
modifier = Modifier.fillMaxHeight().fillMaxWidth() modifier = Modifier.fillMaxHeight().fillMaxWidth()
.border( .border(
border = BorderStroke(150.dp, topic.color.toColor()) border = BorderStroke(150.dp, topicColor.toColor())
) )
.padding(150.dp), .padding(150.dp),
contentAlignment = Alignment.Center, contentAlignment = Alignment.Center,
@ -45,7 +43,7 @@ fun QuestionDialogButtons(
verticalArrangement = Arrangement.SpaceAround verticalArrangement = Arrangement.SpaceAround
) { ) {
HintText( HintText(
topicName = topic.topic, topicName = topic,
points = questionData.actualUsagePoints(secondRoundDouble), points = questionData.actualUsagePoints(secondRoundDouble),
deferredDouble = questionData.isDeferredDouble, deferredDouble = questionData.isDeferredDouble,
hint = questionData.hint hint = questionData.hint