Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2025-12-23 00:13:21 -06:00
parent 017000b197
commit 000849cb70

View File

@ -43,25 +43,13 @@ struct BlackjackTableView: View {
return verticalSizeClass == .compact return verticalSizeClass == .compact
} }
/// Dynamic card width based on screen width /// Card width derived from screen height percentage and card aspect ratio
/// - iPhone SE (375pt): ~80pt /// cardHeight = maxHeight × percentage, then cardWidth = cardHeight / aspectRatio
/// - iPhone 16 Pro (393pt): ~95pt
/// - iPhone 16 Pro Max (430pt): ~120pt
/// - iPad mini (landscape): ~90pt (reduced for smaller tablet screen)
/// - iPad: ~140pt (capped)
private var cardWidth: CGFloat { private var cardWidth: CGFloat {
// iPad mini in landscape gets smaller cards to fit better let maxHeight = max(screenWidth, screenHeight)
if DeviceInfo.isPadMini && isLandscape { let heightPercentage: CGFloat = 0.19 // Card takes 12% of screen height
return 90 let cardHeight = maxHeight * heightPercentage
} return cardHeight
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))
} }
/// Card overlap scales proportionally with card width /// Card overlap scales proportionally with card width
@ -157,19 +145,12 @@ struct BlackjackTableView: View {
} }
.padding(.horizontal, Design.Spacing.large) .padding(.horizontal, Design.Spacing.large)
.padding(.vertical, Design.Spacing.medium) .padding(.vertical, Design.Spacing.medium)
.background( .onGeometryChange(for: CGSize.self) { proxy in
GeometryReader { geometry in proxy.size
Color.clear } action: { size in
.onAppear { screenWidth = size.width
screenHeight = geometry.size.height screenHeight = size.height
screenWidth = geometry.size.width
} }
.onChange(of: geometry.size) { _, newSize in
screenHeight = newSize.height
screenWidth = newSize.width
}
}
)
.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)
} }