Skip to content

Commit

Permalink
Fixed build for Swift 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean151 committed Jun 11, 2024
1 parent 9ee37ea commit 4ae6dc9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/ButtonKit/Style/Throwable/ThrowableStyle+Shake.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extension ThrowableButtonStyle where Self == ShakeThrowableButtonStyle {
}
}

#if swift(>=6)
struct Shake: @preconcurrency GeometryEffect, @preconcurrency Animatable {
let amount: CGFloat = 10
let shakesPerUnit = 4
Expand All @@ -52,6 +53,17 @@ struct Shake: @preconcurrency GeometryEffect, @preconcurrency Animatable {
ProjectionTransform(CGAffineTransform(translationX: amount * sin(animatableData * .pi * CGFloat(shakesPerUnit)), y: 0))
}
}
#else
struct Shake: GeometryEffect {
let amount: CGFloat = 10
let shakesPerUnit = 4
var animatableData: CGFloat

func effectValue(size: CGSize) -> ProjectionTransform {
ProjectionTransform(CGAffineTransform(translationX: amount * sin(animatableData * .pi * CGFloat(shakesPerUnit)), y: 0))
}
}
#endif

#Preview {
ThrowableButton {
Expand Down

0 comments on commit 4ae6dc9

Please sign in to comment.