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,
onPointsChange: (Player, Long) -> Unit,
onQuestionDone: (QuestionData, QuestionResolution) -> Unit,
onExit: () -> Unit
) {
Column(modifier = Modifier.fillMaxHeight().fillMaxWidth()) {
Row(
modifier = Modifier.fillMaxHeight(0.2f)
) {
GameHeader(
title = gameData.title,
color = gameData.headerColor
)
}
GameHeader(
title = gameData.title,
color = gameData.headerColor,
onExit = onExit
)
Spacer(modifier = Modifier.height(5.dp))
Row(
modifier = Modifier.fillMaxHeight()

View File

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

View File

@ -1,8 +1,8 @@
package components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.*
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@ -15,16 +15,32 @@ import data.toColor
@Suppress("FunctionName")
@Composable
fun GameHeader(title: String, color: ColorData?) {
Surface(
color = color.toColor(),
modifier = Modifier.fillMaxSize(1f)
fun GameHeader(title: String, color: ColorData?, onExit: () -> Unit) {
Row(
modifier = Modifier.fillMaxHeight(0.2f)
.fillMaxWidth()
) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
Surface(
color = color.toColor(),
modifier = Modifier.fillMaxSize(1f)
) {
Text(text = title, color = Color.LightGray, fontSize = 8.em)
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxWidth(0.9f)
.fillMaxHeight()
) {
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 = { },
buttons = {
QuestionDialogButtons(
topic = topic,
topic = topic.topic,
topicColor = topic.color,
questionData = questionData,
players = players,
onPointsChange = onPointsChange,

View File

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