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
}
/// 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)
}