Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2026-01-24 16:42:45 -06:00
parent 32bff901c7
commit bfda399fdd
2 changed files with 26 additions and 8 deletions

View File

@ -280,6 +280,7 @@ struct CardsDisplayArea: View {
revealProgress: revealProgress,
isPlayerHand: true,
isBottom: playerOnBottom,
isDealing: isDealing,
onReveal: onReveal,
onUpdateProgress: onUpdateProgress
)
@ -330,6 +331,7 @@ struct CardsDisplayArea: View {
revealProgress: revealProgress,
isPlayerHand: false,
isBottom: !playerOnBottom,
isDealing: isDealing,
onReveal: onReveal,
onUpdateProgress: onUpdateProgress
)

View File

@ -25,6 +25,8 @@ struct CompactHandView: View {
let isPlayerHand: Bool
/// Whether this hand is currently displayed at the bottom of the screen (Home hand)
let isBottom: Bool
/// Whether the game is in dealing phase (vertical layout) vs betting phase (horizontal layout)
let isDealing: Bool
let onReveal: () -> Void
let onUpdateProgress: (Double) -> Void
@ -55,18 +57,28 @@ struct CompactHandView: View {
isLargeScreen ? 14 : 10
}
/// Card width calculated from container width
/// Formula accounts for spacing between 3 cards
/// Card width for dealt cards - sized to fit 3 cards with spacing
private var cardWidth: CGFloat {
// containerWidth = 3 * cardWidth + 2 * spacing
// cardWidth = (containerWidth - 2 * spacing) / 3
let spacing = cardSpacing
return max(50, (containerWidth - 2 * spacing) / CGFloat(maxCards))
return max(50, (containerWidth - 2 * cardSpacing) / CGFloat(maxCards))
}
/// Card width for placeholders in horizontal betting view - uses original larger sizing
private var bettingPlaceholderWidth: CGFloat {
// Original formula: containerWidth / 2.1 (from overlap ratio of -0.45)
containerWidth / 2.1
}
/// Card width to use for placeholders - larger in betting view, regular in dealing view
private var placeholderWidth: CGFloat {
isDealing ? cardWidth : bettingPlaceholderWidth
}
/// Card height based on aspect ratio
private var cardHeight: CGFloat {
cardWidth * CasinoDesign.Size.cardAspectRatio
let width = cards.isEmpty ? placeholderWidth : cardWidth
return width * CasinoDesign.Size.cardAspectRatio
}
/// The effective spacing for the card stack
@ -127,7 +139,7 @@ struct CompactHandView: View {
if cards.isEmpty {
// Placeholders - no overlap, just side by side
ForEach(0..<2, id: \.self) { _ in
CardPlaceholderView(width: cardWidth)
CardPlaceholderView(width: placeholderWidth)
}
} else {
ForEach(cards.indices, id: \.self) { index in
@ -204,7 +216,7 @@ struct CompactHandView: View {
// MARK: - Previews
#Preview("Empty Hand") {
#Preview("Empty Hand - Betting") {
ZStack {
TableBackgroundView()
CompactHandView(
@ -220,13 +232,14 @@ struct CompactHandView: View {
revealProgress: 0,
isPlayerHand: true,
isBottom: true,
isDealing: false,
onReveal: {},
onUpdateProgress: { _ in }
)
}
}
#Preview("Two Cards") {
#Preview("Two Cards - Dealing") {
ZStack {
TableBackgroundView()
CompactHandView(
@ -245,6 +258,7 @@ struct CompactHandView: View {
revealProgress: 0,
isPlayerHand: true,
isBottom: true,
isDealing: true,
onReveal: {},
onUpdateProgress: { _ in }
)
@ -271,6 +285,7 @@ struct CompactHandView: View {
revealProgress: 0,
isPlayerHand: true,
isBottom: true,
isDealing: true,
onReveal: {},
onUpdateProgress: { _ in }
)
@ -296,6 +311,7 @@ struct CompactHandView: View {
revealProgress: 0,
isPlayerHand: true,
isBottom: true,
isDealing: true,
onReveal: {},
onUpdateProgress: { _ in }
)