Pause between hands and show results
This commit is contained in:
@@ -19,6 +19,7 @@ import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.Slider
|
||||
import androidx.compose.material3.SliderDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -48,6 +49,7 @@ fun TableScreen(vm: PokerViewModel) {
|
||||
val snap = state.snapshot
|
||||
// Only show an action bar that belongs to the table currently on screen.
|
||||
val offer = state.liveOffer(rawOffer)
|
||||
val handSummary = state.visibleHandSummary()
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -122,10 +124,13 @@ fun TableScreen(vm: PokerViewModel) {
|
||||
|
||||
ActionBar(
|
||||
offer = offer,
|
||||
handSummary = handSummary,
|
||||
nextHandRequested = state.nextHandRequested,
|
||||
heroFolded = hero?.folded == true,
|
||||
onFold = vm::fold,
|
||||
onCheckCall = vm::checkOrCall,
|
||||
onRaise = vm::raiseTo,
|
||||
onNextHand = vm::nextHand,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -217,17 +222,28 @@ private fun HeroSeat(seat: SeatSnapshot?, isTurn: Boolean) {
|
||||
@Composable
|
||||
private fun ActionBar(
|
||||
offer: com.jsjdesigns.poker.game.DecisionOffer?,
|
||||
handSummary: HandSummary?,
|
||||
nextHandRequested: Boolean,
|
||||
heroFolded: Boolean,
|
||||
onFold: (Long) -> Unit,
|
||||
onCheckCall: (Long) -> Unit,
|
||||
onRaise: (Long, Int) -> Unit,
|
||||
onNextHand: (Int) -> Unit,
|
||||
) {
|
||||
if (offer == null) {
|
||||
Box(Modifier.fillMaxWidth().height(96.dp), contentAlignment = Alignment.Center) {
|
||||
Text(
|
||||
if (heroFolded) "You folded — sitting out this hand" else "Waiting…",
|
||||
color = Color.White.copy(alpha = 0.4f),
|
||||
if (handSummary != null) {
|
||||
HandResultBar(
|
||||
summary = handSummary,
|
||||
nextHandRequested = nextHandRequested,
|
||||
onNextHand = onNextHand,
|
||||
)
|
||||
} else {
|
||||
Box(Modifier.fillMaxWidth().height(96.dp), contentAlignment = Alignment.Center) {
|
||||
Text(
|
||||
if (heroFolded) "You folded — sitting out this hand" else "Waiting…",
|
||||
color = Color.White.copy(alpha = 0.4f),
|
||||
)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -244,6 +260,11 @@ private fun ActionBar(
|
||||
value = raiseTo.coerceIn(buttons.sliderMin, buttons.sliderMax).toFloat(),
|
||||
onValueChange = { raiseTo = it.toInt() },
|
||||
valueRange = buttons.sliderMin.toFloat()..buttons.sliderMax.toFloat(),
|
||||
colors = SliderDefaults.colors(
|
||||
thumbColor = Color(0xFFE3C179),
|
||||
activeTrackColor = Color(0xFFE3C179),
|
||||
inactiveTrackColor = Color.White.copy(alpha = 0.22f),
|
||||
),
|
||||
)
|
||||
}
|
||||
Row(
|
||||
@@ -254,14 +275,20 @@ private fun ActionBar(
|
||||
Button(
|
||||
onClick = { onFold(offer.token) },
|
||||
modifier = Modifier.weight(1f),
|
||||
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF8F1218)),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color(0xFF8F1218),
|
||||
contentColor = Color.White,
|
||||
),
|
||||
) { Text("Fold") }
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = { onCheckCall(offer.token) },
|
||||
modifier = Modifier.weight(1f),
|
||||
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF2C6E49)),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color(0xFF2C6E49),
|
||||
contentColor = Color.White,
|
||||
),
|
||||
) { Text(buttons.checkOrCallLabel) }
|
||||
|
||||
if (buttons.showRaise) {
|
||||
@@ -273,13 +300,59 @@ private fun ActionBar(
|
||||
Button(
|
||||
onClick = { onRaise(offer.token, amount) },
|
||||
modifier = Modifier.weight(1f),
|
||||
colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF14357A)),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color(0xFF14357A),
|
||||
contentColor = Color.White,
|
||||
),
|
||||
) { Text(raiseLabel(buttons, amount)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun HandResultBar(
|
||||
summary: HandSummary,
|
||||
nextHandRequested: Boolean,
|
||||
onNextHand: (Int) -> Unit,
|
||||
) {
|
||||
Card(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = CardDefaults.cardColors(containerColor = Color.White.copy(alpha = 0.09f)),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth().padding(12.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Text(
|
||||
summary.title,
|
||||
color = Color(0xFFE3C179),
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 18.sp,
|
||||
)
|
||||
Text(
|
||||
summary.detail,
|
||||
color = Color.White.copy(alpha = 0.7f),
|
||||
fontSize = 12.sp,
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Button(
|
||||
onClick = { onNextHand(summary.handNumber) },
|
||||
enabled = !nextHandRequested,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color(0xFF2C6E49),
|
||||
contentColor = Color.White,
|
||||
disabledContainerColor = Color(0xFF2C6E49).copy(alpha = 0.45f),
|
||||
disabledContentColor = Color.White.copy(alpha = 0.65f),
|
||||
),
|
||||
) {
|
||||
Text(if (nextHandRequested) "Dealing…" else "Next hand")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CardImage(index: Int?, modifier: Modifier) {
|
||||
Image(
|
||||
|
||||
Reference in New Issue
Block a user