Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
32bff901c7
commit
bfda399fdd
@ -280,6 +280,7 @@ struct CardsDisplayArea: View {
|
|||||||
revealProgress: revealProgress,
|
revealProgress: revealProgress,
|
||||||
isPlayerHand: true,
|
isPlayerHand: true,
|
||||||
isBottom: playerOnBottom,
|
isBottom: playerOnBottom,
|
||||||
|
isDealing: isDealing,
|
||||||
onReveal: onReveal,
|
onReveal: onReveal,
|
||||||
onUpdateProgress: onUpdateProgress
|
onUpdateProgress: onUpdateProgress
|
||||||
)
|
)
|
||||||
@ -330,6 +331,7 @@ struct CardsDisplayArea: View {
|
|||||||
revealProgress: revealProgress,
|
revealProgress: revealProgress,
|
||||||
isPlayerHand: false,
|
isPlayerHand: false,
|
||||||
isBottom: !playerOnBottom,
|
isBottom: !playerOnBottom,
|
||||||
|
isDealing: isDealing,
|
||||||
onReveal: onReveal,
|
onReveal: onReveal,
|
||||||
onUpdateProgress: onUpdateProgress
|
onUpdateProgress: onUpdateProgress
|
||||||
)
|
)
|
||||||
|
|||||||
@ -25,6 +25,8 @@ struct CompactHandView: View {
|
|||||||
let isPlayerHand: Bool
|
let isPlayerHand: Bool
|
||||||
/// Whether this hand is currently displayed at the bottom of the screen (Home hand)
|
/// Whether this hand is currently displayed at the bottom of the screen (Home hand)
|
||||||
let isBottom: Bool
|
let isBottom: Bool
|
||||||
|
/// Whether the game is in dealing phase (vertical layout) vs betting phase (horizontal layout)
|
||||||
|
let isDealing: Bool
|
||||||
let onReveal: () -> Void
|
let onReveal: () -> Void
|
||||||
let onUpdateProgress: (Double) -> Void
|
let onUpdateProgress: (Double) -> Void
|
||||||
|
|
||||||
@ -55,18 +57,28 @@ struct CompactHandView: View {
|
|||||||
isLargeScreen ? 14 : 10
|
isLargeScreen ? 14 : 10
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Card width calculated from container width
|
/// Card width for dealt cards - sized to fit 3 cards with spacing
|
||||||
/// Formula accounts for spacing between 3 cards
|
|
||||||
private var cardWidth: CGFloat {
|
private var cardWidth: CGFloat {
|
||||||
// containerWidth = 3 * cardWidth + 2 * spacing
|
// containerWidth = 3 * cardWidth + 2 * spacing
|
||||||
// cardWidth = (containerWidth - 2 * spacing) / 3
|
// cardWidth = (containerWidth - 2 * spacing) / 3
|
||||||
let spacing = cardSpacing
|
return max(50, (containerWidth - 2 * cardSpacing) / CGFloat(maxCards))
|
||||||
return max(50, (containerWidth - 2 * spacing) / 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
|
/// Card height based on aspect ratio
|
||||||
private var cardHeight: CGFloat {
|
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
|
/// The effective spacing for the card stack
|
||||||
@ -127,7 +139,7 @@ struct CompactHandView: View {
|
|||||||
if cards.isEmpty {
|
if cards.isEmpty {
|
||||||
// Placeholders - no overlap, just side by side
|
// Placeholders - no overlap, just side by side
|
||||||
ForEach(0..<2, id: \.self) { _ in
|
ForEach(0..<2, id: \.self) { _ in
|
||||||
CardPlaceholderView(width: cardWidth)
|
CardPlaceholderView(width: placeholderWidth)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ForEach(cards.indices, id: \.self) { index in
|
ForEach(cards.indices, id: \.self) { index in
|
||||||
@ -204,7 +216,7 @@ struct CompactHandView: View {
|
|||||||
|
|
||||||
// MARK: - Previews
|
// MARK: - Previews
|
||||||
|
|
||||||
#Preview("Empty Hand") {
|
#Preview("Empty Hand - Betting") {
|
||||||
ZStack {
|
ZStack {
|
||||||
TableBackgroundView()
|
TableBackgroundView()
|
||||||
CompactHandView(
|
CompactHandView(
|
||||||
@ -220,13 +232,14 @@ struct CompactHandView: View {
|
|||||||
revealProgress: 0,
|
revealProgress: 0,
|
||||||
isPlayerHand: true,
|
isPlayerHand: true,
|
||||||
isBottom: true,
|
isBottom: true,
|
||||||
|
isDealing: false,
|
||||||
onReveal: {},
|
onReveal: {},
|
||||||
onUpdateProgress: { _ in }
|
onUpdateProgress: { _ in }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview("Two Cards") {
|
#Preview("Two Cards - Dealing") {
|
||||||
ZStack {
|
ZStack {
|
||||||
TableBackgroundView()
|
TableBackgroundView()
|
||||||
CompactHandView(
|
CompactHandView(
|
||||||
@ -245,6 +258,7 @@ struct CompactHandView: View {
|
|||||||
revealProgress: 0,
|
revealProgress: 0,
|
||||||
isPlayerHand: true,
|
isPlayerHand: true,
|
||||||
isBottom: true,
|
isBottom: true,
|
||||||
|
isDealing: true,
|
||||||
onReveal: {},
|
onReveal: {},
|
||||||
onUpdateProgress: { _ in }
|
onUpdateProgress: { _ in }
|
||||||
)
|
)
|
||||||
@ -271,6 +285,7 @@ struct CompactHandView: View {
|
|||||||
revealProgress: 0,
|
revealProgress: 0,
|
||||||
isPlayerHand: true,
|
isPlayerHand: true,
|
||||||
isBottom: true,
|
isBottom: true,
|
||||||
|
isDealing: true,
|
||||||
onReveal: {},
|
onReveal: {},
|
||||||
onUpdateProgress: { _ in }
|
onUpdateProgress: { _ in }
|
||||||
)
|
)
|
||||||
@ -296,6 +311,7 @@ struct CompactHandView: View {
|
|||||||
revealProgress: 0,
|
revealProgress: 0,
|
||||||
isPlayerHand: true,
|
isPlayerHand: true,
|
||||||
isBottom: true,
|
isBottom: true,
|
||||||
|
isDealing: true,
|
||||||
onReveal: {},
|
onReveal: {},
|
||||||
onUpdateProgress: { _ in }
|
onUpdateProgress: { _ in }
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user