Add answer card
This commit is contained in:
parent
6fb0bf1885
commit
9eaf6f54ef
3 changed files with 58 additions and 29 deletions
17
src/main/kotlin/components/questiondialog/AnswerBox.kt
Normal file
17
src/main/kotlin/components/questiondialog/AnswerBox.kt
Normal file
|
@ -0,0 +1,17 @@
|
|||
package components.questiondialog
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.unit.em
|
||||
|
||||
@Composable
|
||||
@Suppress("FunctionName")
|
||||
fun AnswerBox(answer: String) {
|
||||
Row() {
|
||||
Column() {
|
||||
Text(text = answer, fontSize = 3.em)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ fun QuestionDialogue(
|
|||
.fillMaxHeight(),
|
||||
onDismissRequest = { },
|
||||
buttons = {
|
||||
QuestionDialogButtons(
|
||||
QuestionDialogContent(
|
||||
topic = topic.topic,
|
||||
topicColor = topic.color,
|
||||
questionData = questionData,
|
||||
|
|
|
@ -12,11 +12,14 @@ import components.questiondialog.assets.HintText
|
|||
import components.questiondialog.buttons.DismissButton
|
||||
import components.questiondialog.player.DeferredDoubleQuestionDialogPlayer
|
||||
import components.questiondialog.player.QuestionDialogPlayer
|
||||
import data.*
|
||||
import data.ColorData
|
||||
import data.Player
|
||||
import data.QuestionData
|
||||
import data.toColorOrDefault
|
||||
|
||||
@Suppress("FunctionName")
|
||||
@Composable
|
||||
fun QuestionDialogButtons(
|
||||
fun QuestionDialogContent(
|
||||
topic: String,
|
||||
topicColor: ColorData?,
|
||||
questionData: QuestionData,
|
||||
|
@ -26,6 +29,7 @@ fun QuestionDialogButtons(
|
|||
secondRoundDouble: Boolean
|
||||
) {
|
||||
val fontSize = 5.em
|
||||
var showAnswer by remember { mutableStateOf(false) }
|
||||
var questionAnswered by remember { mutableStateOf(QuestionResolution(false, null)) }
|
||||
|
||||
BorderBox(borderColor = topicColor.toColorOrDefault()) {
|
||||
|
@ -40,6 +44,9 @@ fun QuestionDialogButtons(
|
|||
deferredDouble = questionData.isDeferredDouble,
|
||||
hint = questionData.hint
|
||||
)
|
||||
if (showAnswer) {
|
||||
AnswerBox(questionData.answer)
|
||||
} else {
|
||||
for (player in players) {
|
||||
if (questionData.isDeferredDouble) {
|
||||
DeferredDoubleQuestionDialogPlayer(
|
||||
|
@ -48,7 +55,7 @@ fun QuestionDialogButtons(
|
|||
allowedToAnswer = !(questionAnswered.answered) || player == questionAnswered.player,
|
||||
onPointsChange = onPointsChange,
|
||||
questionPoints = questionData.actualUsagePoints(secondRoundDouble).toLong(),
|
||||
onQuestionDone = { onResolve(questionAnswered) },
|
||||
onQuestionDone = { showAnswer = true },
|
||||
onQuestionAnswered = { questionAnswered = QuestionResolution(true, it) }
|
||||
)
|
||||
} else {
|
||||
|
@ -60,18 +67,23 @@ fun QuestionDialogButtons(
|
|||
onQuestionAnswered = {
|
||||
val answer = QuestionResolution(true, it)
|
||||
questionAnswered = answer
|
||||
onResolve(answer)
|
||||
showAnswer = true
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(20.dp))
|
||||
DismissButton(
|
||||
fontSize = fontSize,
|
||||
onResolve = {
|
||||
if (showAnswer) {
|
||||
onResolve(
|
||||
QuestionResolution(true, null)
|
||||
)
|
||||
} else {
|
||||
showAnswer = true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue