Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
e4c43354f0
commit
2dd9ae020e
@ -19,6 +19,9 @@ struct GameTableView: View {
|
||||
@State private var showRules = false
|
||||
@State private var showStats = false
|
||||
|
||||
/// Full screen size (measured from TableBackgroundView - stable, doesn't change with content)
|
||||
@State private var fullScreenSize: CGSize = CGSize(width: 375, height: 667)
|
||||
|
||||
// MARK: - Environment
|
||||
|
||||
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
||||
@ -73,8 +76,13 @@ struct GameTableView: View {
|
||||
@ViewBuilder
|
||||
private func mainGameView(state: GameState) -> some View {
|
||||
ZStack {
|
||||
// Background
|
||||
// Background - measures full screen size (stable)
|
||||
TableBackgroundView()
|
||||
.onGeometryChange(for: CGSize.self) { proxy in
|
||||
proxy.size
|
||||
} action: { size in
|
||||
fullScreenSize = size
|
||||
}
|
||||
|
||||
mainContent(state: state)
|
||||
}
|
||||
@ -117,7 +125,8 @@ struct GameTableView: View {
|
||||
// Table layout - fills available space
|
||||
BlackjackTableView(
|
||||
state: state,
|
||||
onPlaceBet: { placeBet(state: state) }
|
||||
onPlaceBet: { placeBet(state: state) },
|
||||
fullScreenSize: fullScreenSize
|
||||
)
|
||||
.frame(maxWidth: maxContentWidth)
|
||||
|
||||
|
||||
@ -12,15 +12,17 @@ struct BlackjackTableView: View {
|
||||
@Bindable var state: GameState
|
||||
let onPlaceBet: () -> Void
|
||||
|
||||
/// Full screen size passed from parent (stable - measured from TableBackgroundView)
|
||||
let fullScreenSize: CGSize
|
||||
|
||||
// MARK: - Environment
|
||||
|
||||
@Environment(\.verticalSizeClass) private var verticalSizeClass
|
||||
|
||||
// MARK: - State
|
||||
// MARK: - Computed from stable screen size
|
||||
|
||||
/// Screen dimensions measured from container for responsive sizing
|
||||
@State private var screenHeight: CGFloat = 800
|
||||
@State private var screenWidth: CGFloat = 375
|
||||
private var screenWidth: CGFloat { fullScreenSize.width }
|
||||
private var screenHeight: CGFloat { fullScreenSize.height }
|
||||
|
||||
/// Whether to show Hi-Lo card count values on cards.
|
||||
var showCardCount: Bool { state.settings.showCardCount }
|
||||
@ -43,13 +45,11 @@ struct BlackjackTableView: View {
|
||||
return verticalSizeClass == .compact
|
||||
}
|
||||
|
||||
/// Card width derived from screen height percentage and card aspect ratio
|
||||
/// cardHeight = maxHeight × percentage, then cardWidth = cardHeight / aspectRatio
|
||||
/// Card width based on full screen height (stable - doesn't change with content)
|
||||
private var cardWidth: CGFloat {
|
||||
let maxHeight = max(screenWidth, screenHeight)
|
||||
let heightPercentage: CGFloat = 0.19 // Card takes 12% of screen height
|
||||
let cardHeight = maxHeight * heightPercentage
|
||||
return cardHeight
|
||||
let maxDimension = screenHeight
|
||||
let percentage: CGFloat = 0.13 // ~10% of screen
|
||||
return maxDimension * percentage
|
||||
}
|
||||
|
||||
/// Card overlap scales proportionally with card width
|
||||
@ -146,12 +146,6 @@ struct BlackjackTableView: View {
|
||||
}
|
||||
.padding(.horizontal, Design.Spacing.large)
|
||||
.padding(.vertical, Design.Spacing.medium)
|
||||
.onGeometryChange(for: CGSize.self) { proxy in
|
||||
proxy.size
|
||||
} action: { size in
|
||||
screenWidth = size.width
|
||||
screenHeight = size.height
|
||||
}
|
||||
.debugBorder(showDebugBorders, color: .white, label: "TableView")
|
||||
.animation(.spring(duration: Design.Animation.springDuration), value: state.currentPhase)
|
||||
}
|
||||
|
||||
@ -81,20 +81,6 @@ struct DealerHandView: View {
|
||||
}
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(dealerAccessibilityLabel)
|
||||
.background(
|
||||
GeometryReader { geo in
|
||||
Color.clear
|
||||
.onAppear {
|
||||
print("🃏 DealerHandView SIZE: \(geo.size.width) x \(geo.size.height), cards: \(hand.cards.count), cardWidth: \(cardWidth), cardSpacing: \(cardSpacing)")
|
||||
}
|
||||
.onChange(of: geo.size) { oldSize, newSize in
|
||||
print("🃏 DealerHandView CHANGED: \(oldSize.width)x\(oldSize.height) → \(newSize.width)x\(newSize.height), cards: \(hand.cards.count)")
|
||||
}
|
||||
.onChange(of: hand.cards.count) { oldCount, newCount in
|
||||
print("🃏 DealerHandView CARDS: \(oldCount) → \(newCount), size: \(geo.size.width)x\(geo.size.height)")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - Computed Properties
|
||||
|
||||
Loading…
Reference in New Issue
Block a user