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