75 lines
2.6 KiB
Kotlin
75 lines
2.6 KiB
Kotlin
|
package components.questiondialog
|
||
|
|
||
|
import androidx.compose.foundation.BorderStroke
|
||
|
import androidx.compose.foundation.border
|
||
|
import androidx.compose.foundation.layout.*
|
||
|
import androidx.compose.runtime.Composable
|
||
|
import androidx.compose.ui.Alignment
|
||
|
import androidx.compose.ui.Modifier
|
||
|
import androidx.compose.ui.unit.dp
|
||
|
import androidx.compose.ui.unit.em
|
||
|
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
|
||
|
|
||
|
@Suppress("FunctionName")
|
||
|
@Composable
|
||
|
fun QuestionDialogButtons(
|
||
|
topic: Topic,
|
||
|
questionData: QuestionData,
|
||
|
players: List<Player>,
|
||
|
onPointsChange: (Player, Long) -> Unit,
|
||
|
onResolve: () -> Unit,
|
||
|
secondRoundDouble: Boolean
|
||
|
) {
|
||
|
val fontSize = 5.em
|
||
|
|
||
|
Box(
|
||
|
modifier = Modifier.fillMaxHeight().fillMaxWidth()
|
||
|
.border(
|
||
|
border = BorderStroke(150.dp, topic.color.toColor())
|
||
|
)
|
||
|
.padding(150.dp),
|
||
|
contentAlignment = Alignment.Center,
|
||
|
) {
|
||
|
Column(
|
||
|
modifier = Modifier.fillMaxWidth().fillMaxHeight(),
|
||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||
|
verticalArrangement = Arrangement.SpaceAround
|
||
|
) {
|
||
|
HintText(
|
||
|
topicName = topic.topic,
|
||
|
points = questionData.actualUsagePoints(secondRoundDouble),
|
||
|
deferredDouble = questionData.isDeferredDouble,
|
||
|
hint = questionData.hint
|
||
|
)
|
||
|
for (player in players) {
|
||
|
if (questionData.isDeferredDouble) {
|
||
|
DeferredDoubleQuestionDialogPlayer(
|
||
|
player = player,
|
||
|
fontSize = fontSize,
|
||
|
onPointsChange = onPointsChange,
|
||
|
questionPoints = questionData.actualUsagePoints(secondRoundDouble).toLong(),
|
||
|
onQuestionAnswered = onResolve
|
||
|
)
|
||
|
} else {
|
||
|
QuestionDialogPlayer(
|
||
|
player = player,
|
||
|
fontSize = fontSize,
|
||
|
onPointsChange = onPointsChange,
|
||
|
questionPoints = questionData.actualUsagePoints(secondRoundDouble).toLong(),
|
||
|
onQuestionAnswered = onResolve
|
||
|
)
|
||
|
}
|
||
|
Spacer(Modifier.height(20.dp))
|
||
|
}
|
||
|
DismissButton(onResolve, fontSize)
|
||
|
}
|
||
|
}
|
||
|
}
|