79 lines
2.4 KiB
Kotlin
79 lines
2.4 KiB
Kotlin
package components.questiondialog.player
|
|
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.material.Text
|
|
import androidx.compose.runtime.*
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.unit.TextUnit
|
|
import components.common.DisabledButton
|
|
import components.questiondialog.buttons.BadAnswerButton
|
|
import components.questiondialog.buttons.ButtonSpacer
|
|
import components.questiondialog.buttons.GoodAnswerButton
|
|
import data.Player
|
|
|
|
@Suppress("FunctionName")
|
|
@Composable
|
|
fun DeferredDoubleQuestionDialogPlayer(
|
|
player: Player,
|
|
fontSize: TextUnit,
|
|
allowedToAnswer: Boolean,
|
|
onPointsChange: (Player, Long) -> Unit,
|
|
onQuestionDone: () -> Unit,
|
|
onQuestionAnswered: (Player) -> Unit,
|
|
questionPoints: Long,
|
|
) {
|
|
Row(
|
|
modifier = Modifier.fillMaxWidth(),
|
|
verticalAlignment = Alignment.CenterVertically
|
|
) {
|
|
var deferredGuess by remember { mutableStateOf(false) }
|
|
var hadFail by remember { mutableStateOf(false) }
|
|
|
|
Text(
|
|
text = player.name,
|
|
modifier = Modifier.fillMaxWidth(0.6f),
|
|
fontSize = fontSize
|
|
)
|
|
ButtonSpacer()
|
|
if (hadFail || !allowedToAnswer) {
|
|
DisabledButton(maxWidthFraction = 1f, fontSize = fontSize)
|
|
} else {
|
|
if (deferredGuess) {
|
|
DisabledButton(0.7f, fontSize)
|
|
} else {
|
|
BadAnswerButton(
|
|
fontSize = fontSize,
|
|
onClick = {
|
|
hadFail = true
|
|
onPointsChange(
|
|
player,
|
|
-questionPoints
|
|
)
|
|
}
|
|
)
|
|
}
|
|
ButtonSpacer()
|
|
if (!deferredGuess) {
|
|
GoodAnswerButton(
|
|
fontSize = fontSize,
|
|
onClick = {
|
|
deferredGuess = true
|
|
onPointsChange(player, questionPoints)
|
|
onQuestionAnswered(player)
|
|
}
|
|
)
|
|
} else {
|
|
GoodAnswerButton(
|
|
fontSize = fontSize,
|
|
onClick = {
|
|
onPointsChange(player, questionPoints)
|
|
onQuestionDone()
|
|
}
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|