From e41eadff3c39557f9ad33255f8046c7ef7a85f45 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 22 Dec 2025 17:55:40 -0600 Subject: [PATCH] Signed-off-by: Matt Bruce --- Baccarat/Baccarat/Theme/DesignConstants.swift | 55 +++++++++++-------- .../Views/Table/CardsDisplayArea.swift | 4 +- .../Views/Table/CompactHandView.swift | 19 ++----- .../Baccarat/Views/Table/HandValueBadge.swift | 2 +- 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/Baccarat/Baccarat/Theme/DesignConstants.swift b/Baccarat/Baccarat/Theme/DesignConstants.swift index bfb7d2e..9999008 100644 --- a/Baccarat/Baccarat/Theme/DesignConstants.swift +++ b/Baccarat/Baccarat/Theme/DesignConstants.swift @@ -34,14 +34,13 @@ enum Design { enum Size { // MARK: - Hand Scaling - /// Hand scaling factor for cards and related elements. - /// 1.0 = original size, 1.5 = 50% larger, 2.0 = double size. - /// Adjust this value to change card sizes across the app. - static let handScale: CGFloat = 1.75 + /// Hand scaling factor for small screens (iPhone SE, etc). + /// Applied on screens narrower than smallScreenThreshold. + static let handScaleSmall: CGFloat = 1.75 - /// Scale multiplier for small screens (iPhone SE, etc). - /// Applied instead of handScale on screens narrower than smallScreenThreshold. - static let smallScreenScale: CGFloat = 1.2 + /// Hand scaling factor for standard+ iPhones. + /// Applied on screens wider than smallScreenThreshold. + static let handScaleLarge: CGFloat = 2.0 /// Screen width threshold for small screen detection (iPhone SE is 375pt) static let smallScreenThreshold: CGFloat = 390 @@ -50,37 +49,45 @@ enum Design { /// Applied on top of handScale when on regular size class. static let largeScreenMultiplier: CGFloat = 1.2 + /// Returns the appropriate hand scale based on screen width. + /// - Parameter screenWidth: The current screen width in points + /// - Returns: handScaleSmall for iPhone SE, handScaleLarge for larger phones + static func handScale(for screenWidth: CGFloat) -> CGFloat { + screenWidth <= smallScreenThreshold ? handScaleSmall : handScaleLarge + } + // Cards - base values from CasinoDesign static let cardWidthSmall: CGFloat = CasinoDesign.Size.cardWidthSmall static let cardWidthMedium: CGFloat = CasinoDesign.Size.cardWidthMedium static let cardWidthLarge: CGFloat = CasinoDesign.Size.cardWidthLarge static let cardAspectRatio: CGFloat = CasinoDesign.Size.cardAspectRatio - /// Base card width before scaling (for reference) - private static let cardWidthTableBase: CGFloat = 45 + /// Base card width before scaling + static let cardWidthTableBase: CGFloat = 45 /// Base card overlap before scaling. /// More negative = more overlap (less card visible). - /// -15 is default, -20 shows less card, -25 shows even less. private static let cardOverlapBase: CGFloat = -25 - /// Card overlap scaled with hand size (standard iPhone) - static let cardOverlap: CGFloat = cardOverlapBase * handScale + /// Returns card width for the given screen width + static func cardWidthTable(for screenWidth: CGFloat) -> CGFloat { + cardWidthTableBase * handScale(for: screenWidth) + } - /// Card overlap for small screens - static let cardOverlapSmall: CGFloat = cardOverlapBase * smallScreenScale + /// Returns card width for iPad (with large screen multiplier) + static func cardWidthTableLarge(for screenWidth: CGFloat) -> CGFloat { + cardWidthTableBase * handScale(for: screenWidth) * largeScreenMultiplier + } - // Baccarat table cards - scaled for better visibility (standard iPhone) - static let cardWidthTable: CGFloat = cardWidthTableBase * handScale + /// Returns card overlap for the given screen width + static func cardOverlap(for screenWidth: CGFloat) -> CGFloat { + cardOverlapBase * handScale(for: screenWidth) + } - /// Card width for small screens (iPhone SE, etc) - static let cardWidthTableSmall: CGFloat = cardWidthTableBase * smallScreenScale - - /// Card width for large screens (iPad) - applies additional multiplier - static let cardWidthTableLarge: CGFloat = cardWidthTableBase * handScale * largeScreenMultiplier - - /// Card overlap for large screens - static let cardOverlapLarge: CGFloat = cardOverlapBase * handScale * largeScreenMultiplier + /// Returns card overlap for iPad (with large screen multiplier) + static func cardOverlapLarge(for screenWidth: CGFloat) -> CGFloat { + cardOverlapBase * handScale(for: screenWidth) * largeScreenMultiplier + } // Chips - use CasinoDesign values static let chipSmall: CGFloat = CasinoDesign.Size.chipSmall diff --git a/Baccarat/Baccarat/Views/Table/CardsDisplayArea.swift b/Baccarat/Baccarat/Views/Table/CardsDisplayArea.swift index 5d5ec58..e0d81d6 100644 --- a/Baccarat/Baccarat/Views/Table/CardsDisplayArea.swift +++ b/Baccarat/Baccarat/Views/Table/CardsDisplayArea.swift @@ -39,13 +39,13 @@ struct CardsDisplayArea: View { /// Label font size - only scales on iPad to avoid clipping on small iPhones private var labelFontSize: CGFloat { let baseSize: CGFloat = 14 - return isLargeScreen ? baseSize * Design.Size.handScale * Design.Size.largeScreenMultiplier : baseSize + return isLargeScreen ? baseSize * Design.Size.handScale(for: screenWidth) * Design.Size.largeScreenMultiplier : baseSize } /// Minimum height for label row - only scales on iPad private var labelRowMinHeight: CGFloat { let baseHeight: CGFloat = 30 - return isLargeScreen ? baseHeight * Design.Size.handScale * Design.Size.largeScreenMultiplier : baseHeight + return isLargeScreen ? baseHeight * Design.Size.handScale(for: screenWidth) * Design.Size.largeScreenMultiplier : baseHeight } /// Spacing between PLAYER and BANKER hands - reduced on smaller screens diff --git a/Baccarat/Baccarat/Views/Table/CompactHandView.swift b/Baccarat/Baccarat/Views/Table/CompactHandView.swift index 22cc700..6c7f81e 100644 --- a/Baccarat/Baccarat/Views/Table/CompactHandView.swift +++ b/Baccarat/Baccarat/Views/Table/CompactHandView.swift @@ -27,25 +27,18 @@ struct CompactHandView: View { horizontalSizeClass == .regular } - /// Whether we're on a small screen (iPhone SE, etc) - private var isSmallScreen: Bool { - !isLargeScreen && screenWidth < Design.Size.smallScreenThreshold - } - /// WIN badge font size - only scales on iPad private var winBadgeFontSize: CGFloat { let baseSize: CGFloat = 10 - return isLargeScreen ? baseSize * Design.Size.handScale * Design.Size.largeScreenMultiplier : baseSize + return isLargeScreen ? baseSize * Design.Size.handScale(for: screenWidth) * Design.Size.largeScreenMultiplier : baseSize } /// Card width - responsive based on screen size private var cardWidth: CGFloat { if isLargeScreen { - return Design.Size.cardWidthTableLarge - } else if isSmallScreen { - return Design.Size.cardWidthTableSmall + return Design.Size.cardWidthTableLarge(for: screenWidth) } else { - return Design.Size.cardWidthTable + return Design.Size.cardWidthTable(for: screenWidth) } } @@ -57,11 +50,9 @@ struct CompactHandView: View { /// Card overlap - scaled with card size private var cardOverlap: CGFloat { if isLargeScreen { - return Design.Size.cardOverlapLarge - } else if isSmallScreen { - return Design.Size.cardOverlapSmall + return Design.Size.cardOverlapLarge(for: screenWidth) } else { - return Design.Size.cardOverlap + return Design.Size.cardOverlap(for: screenWidth) } } diff --git a/Baccarat/Baccarat/Views/Table/HandValueBadge.swift b/Baccarat/Baccarat/Views/Table/HandValueBadge.swift index 54217fc..4137b7b 100644 --- a/Baccarat/Baccarat/Views/Table/HandValueBadge.swift +++ b/Baccarat/Baccarat/Views/Table/HandValueBadge.swift @@ -26,7 +26,7 @@ struct HandValueBadge: View { /// Scale factor for badge sizing - only applies on iPad to avoid clipping on iPhone private var scale: CGFloat { - isLargeScreen ? Design.Size.handScale * Design.Size.largeScreenMultiplier : 1.0 + isLargeScreen ? Design.Size.handScaleLarge * Design.Size.largeScreenMultiplier : 1.0 } @ScaledMetric(relativeTo: .headline) private var baseValueFontSize: CGFloat = 15