From 2b0f36a12ce9ca960854772026d8731469899ed2 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 24 Dec 2025 13:57:36 -0600 Subject: [PATCH] Signed-off-by: Matt Bruce --- .../Blackjack/Views/Game/GameTableView.swift | 17 +++++++---- .../Views/Table/DealerHandView.swift | 30 +++++++++++-------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Blackjack/Blackjack/Views/Game/GameTableView.swift b/Blackjack/Blackjack/Views/Game/GameTableView.swift index cbb918d..f9e2984 100644 --- a/Blackjack/Blackjack/Views/Game/GameTableView.swift +++ b/Blackjack/Blackjack/Views/Game/GameTableView.swift @@ -128,15 +128,19 @@ struct GameTableView: View { Design.debugLog(" Cached: \(Int(cachedScreenSize.width))×\(Int(cachedScreenSize.height)), initialized=\(hasInitializedScreenSize)") } - // Capture screen size ONCE on first valid measurement, then only on orientation change + // Capture screen size ONCE on first valid measurement + // Use the DEFAULT initialized value (667 for iPhone) if first measurement is smaller + // This handles the case where safe area reduces the first measurement if !hasInitializedScreenSize && size.width > 0 && size.height > 0 { - // First time: capture the initial size - Design.debugLog("📐 🎯 INITIAL capture: \(Int(size.width))×\(Int(size.height))") - cachedScreenSize = size + // Use the LARGER of default and first measurement + let useHeight = max(size.height, cachedScreenSize.height) + let useWidth = max(size.width, cachedScreenSize.width) + let captureSize = CGSize(width: useWidth, height: useHeight) + Design.debugLog("📐 🎯 INITIAL capture: measured=\(Int(size.width))×\(Int(size.height)), using=\(Int(captureSize.width))×\(Int(captureSize.height))") + cachedScreenSize = captureSize hasInitializedScreenSize = true } else if hasInitializedScreenSize { - // After initialization: only update on TRUE orientation change - // (when portrait becomes landscape or vice versa) + // After initialization: ONLY update on TRUE orientation change let wasPortrait = cachedScreenSize.height > cachedScreenSize.width let isPortrait = size.height > size.width @@ -144,6 +148,7 @@ struct GameTableView: View { Design.debugLog("📐 🔄 ORIENTATION changed: \(Int(cachedScreenSize.width))×\(Int(cachedScreenSize.height)) → \(Int(size.width))×\(Int(size.height))") cachedScreenSize = size } + // Otherwise: IGNORE all geometry changes - keep cached size stable } } diff --git a/Blackjack/Blackjack/Views/Table/DealerHandView.swift b/Blackjack/Blackjack/Views/Table/DealerHandView.swift index 2aca7cc..a302c89 100644 --- a/Blackjack/Blackjack/Views/Table/DealerHandView.swift +++ b/Blackjack/Blackjack/Views/Table/DealerHandView.swift @@ -42,7 +42,7 @@ struct DealerHandView: View { } .frame(minHeight: badgeHeight) // Reserve consistent height .animation(.spring(duration: Design.Animation.springDuration), value: hand.cards.isEmpty) - // Cards + // Cards with result badge overlay (overlay prevents height change) HStack(spacing: hand.cards.isEmpty ? Design.Spacing.small : cardSpacing) { if hand.cards.isEmpty { CardPlaceholderView(width: cardWidth) @@ -70,18 +70,22 @@ struct DealerHandView: View { } } } - - // Result badge - if let result = hand.cards.count >= 2 && showHoleCard ? handResultText : nil { - Text(result) - .font(.system(size: labelFontSize, weight: .black)) - .foregroundStyle(handResultColor) - .padding(.horizontal, Design.Spacing.medium) - .padding(.vertical, Design.Spacing.xSmall) - .background( - Capsule() - .fill(handResultColor.opacity(Design.Opacity.hint)) - ) + .overlay(alignment: .bottom) { + // Result badge - overlayed so it doesn't add height to the view + if let result = hand.cards.count >= 2 && showHoleCard ? handResultText : nil { + Text(result) + .font(.system(size: labelFontSize, weight: .black)) + .foregroundStyle(.white) + .padding(.horizontal, Design.Spacing.medium) + .padding(.vertical, Design.Spacing.xSmall) + .background( + Capsule() + .fill(handResultColor) + .shadow(color: .black.opacity(Design.Opacity.medium), radius: Design.Shadow.radiusMedium) + ) + .offset(y: Design.Spacing.xLarge) // Position below cards + .transition(.scale.combined(with: .opacity)) + } } } .accessibilityElement(children: .ignore)