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

This commit is contained in:
Matt Bruce 2025-12-31 12:59:13 -06:00
parent 04fc1542f5
commit bda234a3bb
6 changed files with 33 additions and 22 deletions

View File

@ -71,8 +71,8 @@ final class GameSettings: GameSettingsProtocol {
/// Whether to show dealing animations. /// Whether to show dealing animations.
var showAnimations: Bool = true var showAnimations: Bool = true
/// Speed of card dealing (1.0 = normal, 0.5 = fast, 2.0 = slow) /// Speed of card dealing (uses CasinoDesign.DealingSpeed constants)
var dealingSpeed: Double = 1.0 var dealingSpeed: Double = CasinoDesign.DealingSpeed.normal
// MARK: - Display Settings // MARK: - Display Settings
@ -317,7 +317,7 @@ final class GameSettings: GameSettingsProtocol {
tableLimits = .casual tableLimits = .casual
startingBalance = 1_000 startingBalance = 1_000
showAnimations = true showAnimations = true
dealingSpeed = 1.0 dealingSpeed = CasinoDesign.DealingSpeed.normal
showCardsRemaining = true showCardsRemaining = true
showHistory = true showHistory = true
showHints = true showHints = true

View File

@ -24,11 +24,6 @@ struct CompactHandView: View {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass @Environment(\.horizontalSizeClass) private var horizontalSizeClass
/// Scaled animation duration based on dealing speed.
private var animationDuration: Double {
Design.Animation.springDuration * dealingSpeed
}
// MARK: - Constants // MARK: - Constants
/// Overlap ratio relative to card width (negative = overlap) /// Overlap ratio relative to card width (negative = overlap)
@ -114,7 +109,7 @@ struct CompactHandView: View {
} }
.animation( .animation(
showAnimations showAnimations
? .spring(duration: animationDuration, bounce: Design.Animation.springBounce) ? CasinoDesign.Animation.cardDeal(speed: dealingSpeed)
: .none, : .none,
value: cards.count value: cards.count
) )

View File

@ -133,8 +133,8 @@ final class GameSettings: GameSettingsProtocol {
/// Whether to show dealing animations. /// Whether to show dealing animations.
var showAnimations: Bool = true { didSet { save() } } var showAnimations: Bool = true { didSet { save() } }
/// Speed of card dealing (1.0 = normal) /// Speed of card dealing (uses CasinoDesign.DealingSpeed constants)
var dealingSpeed: Double = 1.0 { didSet { save() } } var dealingSpeed: Double = CasinoDesign.DealingSpeed.normal { didSet { save() } }
// MARK: - Side Bets // MARK: - Side Bets
@ -299,7 +299,7 @@ final class GameSettings: GameSettingsProtocol {
neverAskInsurance = false neverAskInsurance = false
sideBetsEnabled = false sideBetsEnabled = false
showAnimations = true showAnimations = true
dealingSpeed = 1.0 dealingSpeed = CasinoDesign.DealingSpeed.normal
showCardsRemaining = true showCardsRemaining = true
showHistory = true showHistory = true
showHints = true showHints = true

View File

@ -45,11 +45,6 @@ struct CardStackView: View {
staggeredPlaceholders ? cardSpacing : Design.Spacing.small staggeredPlaceholders ? cardSpacing : Design.Spacing.small
} }
/// Scaled animation duration based on dealing speed.
private var animationDuration: Double {
Design.Animation.springDuration * dealingSpeed
}
var body: some View { var body: some View {
// Use staggered or side-by-side spacing based on configuration // Use staggered or side-by-side spacing based on configuration
HStack(spacing: cards.isEmpty && placeholdersNeeded > 0 ? placeholderSpacing : cardSpacing) { HStack(spacing: cards.isEmpty && placeholdersNeeded > 0 ? placeholderSpacing : cardSpacing) {
@ -96,7 +91,7 @@ struct CardStackView: View {
} }
.animation( .animation(
showAnimations showAnimations
? .spring(duration: animationDuration, bounce: Design.Animation.springBounce) ? CasinoDesign.Animation.cardDeal(speed: dealingSpeed)
: .none, : .none,
value: cards.count value: cards.count
) )

View File

@ -111,6 +111,26 @@ public enum CasinoDesign {
public static let staggerDelay1: Double = 0.1 public static let staggerDelay1: Double = 0.1
public static let staggerDelay2: Double = 0.25 public static let staggerDelay2: Double = 0.25
public static let staggerDelay3: Double = 0.4 public static let staggerDelay3: Double = 0.4
/// Creates an easeOut animation for card dealing.
/// Cards decelerate as they arrive, simulating frictionmore 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 // MARK: - Sizes

View File

@ -57,16 +57,17 @@ public struct SettingsToggle: View {
/// A segmented picker for animation speed (Fast/Normal/Slow). /// A segmented picker for animation speed (Fast/Normal/Slow).
public struct SpeedPicker: View { 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 @Binding public var speed: Double
/// The accent color for the selected button. /// The accent color for the selected button.
public let accentColor: Color public let accentColor: Color
/// Speed options using centralized CasinoDesign constants.
private let options: [(String, Double)] = [ private let options: [(String, Double)] = [
("Fast", 0.5), ("Fast", CasinoDesign.DealingSpeed.fast),
("Normal", 1.0), ("Normal", CasinoDesign.DealingSpeed.normal),
("Slow", 2.0) ("Slow", CasinoDesign.DealingSpeed.slow)
] ]
/// Creates a speed picker. /// Creates a speed picker.