diff --git a/Baccarat/Baccarat/Models/GameSettings.swift b/Baccarat/Baccarat/Models/GameSettings.swift index 6be80d1..0a4d77a 100644 --- a/Baccarat/Baccarat/Models/GameSettings.swift +++ b/Baccarat/Baccarat/Models/GameSettings.swift @@ -71,8 +71,8 @@ final class GameSettings: GameSettingsProtocol { /// Whether to show dealing animations. var showAnimations: Bool = true - /// Speed of card dealing (1.0 = normal, 0.5 = fast, 2.0 = slow) - var dealingSpeed: Double = 1.0 + /// Speed of card dealing (uses CasinoDesign.DealingSpeed constants) + var dealingSpeed: Double = CasinoDesign.DealingSpeed.normal // MARK: - Display Settings @@ -317,7 +317,7 @@ final class GameSettings: GameSettingsProtocol { tableLimits = .casual startingBalance = 1_000 showAnimations = true - dealingSpeed = 1.0 + dealingSpeed = CasinoDesign.DealingSpeed.normal showCardsRemaining = true showHistory = true showHints = true diff --git a/Baccarat/Baccarat/Views/Table/CompactHandView.swift b/Baccarat/Baccarat/Views/Table/CompactHandView.swift index cd36a95..5c2ccb6 100644 --- a/Baccarat/Baccarat/Views/Table/CompactHandView.swift +++ b/Baccarat/Baccarat/Views/Table/CompactHandView.swift @@ -24,11 +24,6 @@ struct CompactHandView: View { @Environment(\.horizontalSizeClass) private var horizontalSizeClass - /// Scaled animation duration based on dealing speed. - private var animationDuration: Double { - Design.Animation.springDuration * dealingSpeed - } - // MARK: - Constants /// Overlap ratio relative to card width (negative = overlap) @@ -114,7 +109,7 @@ struct CompactHandView: View { } .animation( showAnimations - ? .spring(duration: animationDuration, bounce: Design.Animation.springBounce) + ? CasinoDesign.Animation.cardDeal(speed: dealingSpeed) : .none, value: cards.count ) diff --git a/Blackjack/Blackjack/Models/GameSettings.swift b/Blackjack/Blackjack/Models/GameSettings.swift index 54f3bd1..7d8205a 100644 --- a/Blackjack/Blackjack/Models/GameSettings.swift +++ b/Blackjack/Blackjack/Models/GameSettings.swift @@ -133,8 +133,8 @@ final class GameSettings: GameSettingsProtocol { /// Whether to show dealing animations. var showAnimations: Bool = true { didSet { save() } } - /// Speed of card dealing (1.0 = normal) - var dealingSpeed: Double = 1.0 { didSet { save() } } + /// Speed of card dealing (uses CasinoDesign.DealingSpeed constants) + var dealingSpeed: Double = CasinoDesign.DealingSpeed.normal { didSet { save() } } // MARK: - Side Bets @@ -299,7 +299,7 @@ final class GameSettings: GameSettingsProtocol { neverAskInsurance = false sideBetsEnabled = false showAnimations = true - dealingSpeed = 1.0 + dealingSpeed = CasinoDesign.DealingSpeed.normal showCardsRemaining = true showHistory = true showHints = true diff --git a/Blackjack/Blackjack/Views/Table/CardStackView.swift b/Blackjack/Blackjack/Views/Table/CardStackView.swift index af0c525..473abce 100644 --- a/Blackjack/Blackjack/Views/Table/CardStackView.swift +++ b/Blackjack/Blackjack/Views/Table/CardStackView.swift @@ -45,11 +45,6 @@ struct CardStackView: View { staggeredPlaceholders ? cardSpacing : Design.Spacing.small } - /// Scaled animation duration based on dealing speed. - private var animationDuration: Double { - Design.Animation.springDuration * dealingSpeed - } - var body: some View { // Use staggered or side-by-side spacing based on configuration HStack(spacing: cards.isEmpty && placeholdersNeeded > 0 ? placeholderSpacing : cardSpacing) { @@ -96,7 +91,7 @@ struct CardStackView: View { } .animation( showAnimations - ? .spring(duration: animationDuration, bounce: Design.Animation.springBounce) + ? CasinoDesign.Animation.cardDeal(speed: dealingSpeed) : .none, value: cards.count ) diff --git a/CasinoKit/Sources/CasinoKit/Theme/CasinoDesign.swift b/CasinoKit/Sources/CasinoKit/Theme/CasinoDesign.swift index 5b5afc4..5e800b4 100644 --- a/CasinoKit/Sources/CasinoKit/Theme/CasinoDesign.swift +++ b/CasinoKit/Sources/CasinoKit/Theme/CasinoDesign.swift @@ -111,6 +111,26 @@ public enum CasinoDesign { public static let staggerDelay1: Double = 0.1 public static let staggerDelay2: Double = 0.25 public static let staggerDelay3: Double = 0.4 + + /// Creates an easeOut animation for card dealing. + /// Cards decelerate as they arrive, simulating friction—more realistic than spring bounce. + /// - Parameter speed: Speed multiplier (1.0 = normal, lower = faster) + public static func cardDeal(speed: Double = 1.0) -> SwiftUI.Animation { + .easeOut(duration: springDuration * speed) + } + } + + // MARK: - Dealing Speed + + /// Speed multipliers for card dealing animations. + /// Lower values = faster dealing. Multiplied by `Animation.springDuration`. + public enum DealingSpeed { + /// Fast dealing (snappy, quick deal) + public static let fast: Double = 0.4 + /// Normal dealing speed + public static let normal: Double = 0.7 + /// Slow dealing (relaxed pace) + public static let slow: Double = 1.2 } // MARK: - Sizes diff --git a/CasinoKit/Sources/CasinoKit/Views/Settings/SettingsComponents.swift b/CasinoKit/Sources/CasinoKit/Views/Settings/SettingsComponents.swift index b2c63f4..c9bb917 100644 --- a/CasinoKit/Sources/CasinoKit/Views/Settings/SettingsComponents.swift +++ b/CasinoKit/Sources/CasinoKit/Views/Settings/SettingsComponents.swift @@ -57,16 +57,17 @@ public struct SettingsToggle: View { /// A segmented picker for animation speed (Fast/Normal/Slow). public struct SpeedPicker: View { - /// Binding to the speed value (0.5 = fast, 1.0 = normal, 2.0 = slow). + /// Binding to the speed value (multiplier for animation duration). @Binding public var speed: Double /// The accent color for the selected button. public let accentColor: Color + /// Speed options using centralized CasinoDesign constants. private let options: [(String, Double)] = [ - ("Fast", 0.5), - ("Normal", 1.0), - ("Slow", 2.0) + ("Fast", CasinoDesign.DealingSpeed.fast), + ("Normal", CasinoDesign.DealingSpeed.normal), + ("Slow", CasinoDesign.DealingSpeed.slow) ] /// Creates a speed picker.