From 000849cb7063a5d5d17d93e171d1b57cb14a1fc4 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 23 Dec 2025 00:13:21 -0600 Subject: [PATCH] Signed-off-by: Matt Bruce --- .../Views/Table/BlackjackTableView.swift | 43 ++++++------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/Blackjack/Blackjack/Views/Table/BlackjackTableView.swift b/Blackjack/Blackjack/Views/Table/BlackjackTableView.swift index 4b18929..9da0e90 100644 --- a/Blackjack/Blackjack/Views/Table/BlackjackTableView.swift +++ b/Blackjack/Blackjack/Views/Table/BlackjackTableView.swift @@ -43,25 +43,13 @@ struct BlackjackTableView: View { return verticalSizeClass == .compact } - /// Dynamic card width based on screen width - /// - iPhone SE (375pt): ~80pt - /// - iPhone 16 Pro (393pt): ~95pt - /// - iPhone 16 Pro Max (430pt): ~120pt - /// - iPad mini (landscape): ~90pt (reduced for smaller tablet screen) - /// - iPad: ~140pt (capped) + /// Card width derived from screen height percentage and card aspect ratio + /// cardHeight = maxHeight × percentage, then cardWidth = cardHeight / aspectRatio private var cardWidth: CGFloat { - // iPad mini in landscape gets smaller cards to fit better - if DeviceInfo.isPadMini && isLandscape { - return 90 - } - - let baseWidth: CGFloat = 80 // Minimum card width for smallest screens - let baseScreen: CGFloat = 375 // iPhone SE width - let scale: CGFloat = 0.7 // Scale factor (70% of width increase goes to cards) - let maxWidth: CGFloat = 140 // Cap for large screens - - let calculated = baseWidth + (screenWidth - baseScreen) * scale - return min(maxWidth, max(baseWidth, calculated)) + let maxHeight = max(screenWidth, screenHeight) + let heightPercentage: CGFloat = 0.19 // Card takes 12% of screen height + let cardHeight = maxHeight * heightPercentage + return cardHeight } /// Card overlap scales proportionally with card width @@ -157,19 +145,12 @@ struct BlackjackTableView: View { } .padding(.horizontal, Design.Spacing.large) .padding(.vertical, Design.Spacing.medium) - .background( - GeometryReader { geometry in - Color.clear - .onAppear { - screenHeight = geometry.size.height - screenWidth = geometry.size.width - } - .onChange(of: geometry.size) { _, newSize in - screenHeight = newSize.height - screenWidth = newSize.width - } - } - ) + .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) }