diff --git a/CasinoKit/Sources/CasinoKit/Theme/CasinoDesign.swift b/CasinoKit/Sources/CasinoKit/Theme/CasinoDesign.swift index ac09420..7ee91b6 100644 --- a/CasinoKit/Sources/CasinoKit/Theme/CasinoDesign.swift +++ b/CasinoKit/Sources/CasinoKit/Theme/CasinoDesign.swift @@ -149,7 +149,13 @@ public enum CasinoDesign { /// Common button dimensions. public static let actionButtonHeight: CGFloat = 50 - public static let actionButtonMinWidth: CGFloat = 80 + public static var actionButtonMinWidth: CGFloat { + if let width = UIScreen.current?.bounds.width { + return width < 400 ? 35.0 : 50.0 + } else { + return 35.0 + } + } /// Betting zone height. public static let bettingZoneHeight: CGFloat = 70 @@ -289,3 +295,24 @@ public extension Color { } } +import UIKit + +extension UIScreen { + /// Returns the current active screen (the one displaying the key window). + /// This is the recommended replacement for the deprecated `UIScreen.main`. + static var current: UIScreen? { + // Find the active foreground scene + UIApplication.shared.connectedScenes + .compactMap { $0 as? UIWindowScene } + .filter { $0.activationState == .foregroundActive } + .first? + .screen + + // Alternative (more robust for key window): + // UIApplication.shared.connectedScenes + // .compactMap { $0 as? UIWindowScene } + // .flatMap { $0.windows } + // .first { $0.isKeyWindow }? + // .screen + } +} diff --git a/CasinoKit/Sources/CasinoKit/Views/Buttons/ActionButton.swift b/CasinoKit/Sources/CasinoKit/Views/Buttons/ActionButton.swift index c4ddf42..d234a54 100644 --- a/CasinoKit/Sources/CasinoKit/Views/Buttons/ActionButton.swift +++ b/CasinoKit/Sources/CasinoKit/Views/Buttons/ActionButton.swift @@ -29,7 +29,7 @@ public struct ActionButton: View { private let iconSize: CGFloat = 20 /// Minimum button width to prevent tiny buttons for short words like "Hit" - private let minButtonWidth: CGFloat = 35 + private let minButtonWidth: CGFloat = CasinoDesign.Size.actionButtonMinWidth /// Creates an action button. /// - Parameters: