Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
04fc1542f5
commit
bda234a3bb
@ -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
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user