11//
2- // ThrowableStyle+Shake .swift
2+ // AsyncStyle+SymbolEffect .swift
33// ButtonKit
44//
55// MIT License
2525// SOFTWARE.
2626//
2727
28+ import Symbols
2829import SwiftUI
2930
30- @available ( iOS 17 . 0 , macOS 14 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , * )
31+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
3132public struct SymbolEffectAsyncButtonStyle < Effect: SymbolEffect & IndefiniteSymbolEffect > : AsyncButtonStyle {
3233 let effect : Effect
3334
@@ -37,80 +38,86 @@ public struct SymbolEffectAsyncButtonStyle<Effect: SymbolEffect&IndefiniteSymbol
3738 }
3839}
3940
40- @available ( iOS 17 . 0 , macOS 14 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , * )
41+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
4142extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < AppearSymbolEffect > {
4243 public static func symbolEffect( _ effect: AppearSymbolEffect ) -> some AsyncButtonStyle {
4344 SymbolEffectAsyncButtonStyle ( effect: effect)
4445 }
4546}
46- @available ( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , * )
47- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < BounceSymbolEffect > {
48- public static func symbolEffect( _ effect: BounceSymbolEffect ) -> some AsyncButtonStyle {
47+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
48+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DisappearSymbolEffect > {
49+ public static func symbolEffect( _ effect: DisappearSymbolEffect ) -> some AsyncButtonStyle {
4950 SymbolEffectAsyncButtonStyle ( effect: effect)
5051 }
5152}
52- @available ( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , * )
53- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < BreatheSymbolEffect > {
54- public static func symbolEffect( _ effect: BreatheSymbolEffect ) -> some AsyncButtonStyle {
53+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
54+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < PulseSymbolEffect > {
55+ public static func symbolEffect( _ effect: PulseSymbolEffect ) -> some AsyncButtonStyle {
5556 SymbolEffectAsyncButtonStyle ( effect: effect)
5657 }
5758}
58- @available ( iOS 17 . 0 , macOS 14 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , * )
59- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DisappearSymbolEffect > {
60- public static func symbolEffect( _ effect: DisappearSymbolEffect ) -> some AsyncButtonStyle {
59+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
60+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < ScaleSymbolEffect > {
61+ public static func symbolEffect( _ effect: ScaleSymbolEffect ) -> some AsyncButtonStyle {
6162 SymbolEffectAsyncButtonStyle ( effect: effect)
6263 }
6364}
64- @available ( iOS 26 . 0 , macOS 26 . 0 , tvOS 26 . 0 , watchOS 26 . 0 , * )
65- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DrawOffSymbolEffect > {
66- public static func symbolEffect( _ effect: DrawOffSymbolEffect ) -> some AsyncButtonStyle {
65+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
66+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < VariableColorSymbolEffect > {
67+ public static func symbolEffect( _ effect: VariableColorSymbolEffect ) -> some AsyncButtonStyle {
6768 SymbolEffectAsyncButtonStyle ( effect: effect)
6869 }
6970}
70- @available ( iOS 26 . 0 , macOS 26 . 0 , tvOS 26 . 0 , watchOS 26 . 0 , * )
71- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DrawOnSymbolEffect > {
72- public static func symbolEffect( _ effect: DrawOnSymbolEffect ) -> some AsyncButtonStyle {
71+
72+ @available ( macOS 15 . 0 , iOS 18 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , visionOS 2 . 0 , * )
73+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < BounceSymbolEffect > {
74+ public static func symbolEffect( _ effect: BounceSymbolEffect ) -> some AsyncButtonStyle {
7375 SymbolEffectAsyncButtonStyle ( effect: effect)
7476 }
7577}
76- @available ( iOS 17 . 0 , macOS 14 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , * )
77- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < PulseSymbolEffect > {
78- public static func symbolEffect( _ effect: PulseSymbolEffect ) -> some AsyncButtonStyle {
78+ @available ( macOS 15 . 0 , iOS 18 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , visionOS 2 . 0 , * )
79+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < BreatheSymbolEffect > {
80+ public static func symbolEffect( _ effect: BreatheSymbolEffect ) -> some AsyncButtonStyle {
7981 SymbolEffectAsyncButtonStyle ( effect: effect)
8082 }
8183}
82- @available ( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , * )
84+ @available ( macOS 15 . 0 , iOS 18 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , visionOS 2 . 0 , * )
8385extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < RotateSymbolEffect > {
8486 public static func symbolEffect( _ effect: RotateSymbolEffect ) -> some AsyncButtonStyle {
8587 SymbolEffectAsyncButtonStyle ( effect: effect)
8688 }
8789}
88- @available ( iOS 17 . 0 , macOS 14 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , * )
89- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < ScaleSymbolEffect > {
90- public static func symbolEffect( _ effect: ScaleSymbolEffect ) -> some AsyncButtonStyle {
90+ @available ( macOS 15 . 0 , iOS 18 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , visionOS 2 . 0 , * )
91+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < WiggleSymbolEffect > {
92+ public static func symbolEffect( _ effect: WiggleSymbolEffect ) -> some AsyncButtonStyle {
9193 SymbolEffectAsyncButtonStyle ( effect: effect)
9294 }
9395}
94- @available ( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , * )
95- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < VariableColorSymbolEffect > {
96- public static func symbolEffect( _ effect: VariableColorSymbolEffect ) -> some AsyncButtonStyle {
96+
97+ #if swift(>=6.2)
98+
99+ @available ( macOS 26 . 0 , iOS 26 . 0 , tvOS 26 . 0 , watchOS 26 . 0 , * )
100+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DrawOffSymbolEffect > {
101+ public static func symbolEffect( _ effect: DrawOffSymbolEffect ) -> some AsyncButtonStyle {
97102 SymbolEffectAsyncButtonStyle ( effect: effect)
98103 }
99104}
100- @available ( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , * )
101- extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < WiggleSymbolEffect > {
102- public static func symbolEffect( _ effect: WiggleSymbolEffect ) -> some AsyncButtonStyle {
105+ @available ( macOS 26 . 0 , iOS 26 . 0 , tvOS 26 . 0 , watchOS 26 . 0 , * )
106+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DrawOnSymbolEffect > {
107+ public static func symbolEffect( _ effect: DrawOnSymbolEffect ) -> some AsyncButtonStyle {
103108 SymbolEffectAsyncButtonStyle ( effect: effect)
104109 }
105110}
106111
107- @available ( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , * )
112+ #endif
113+
114+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
108115#Preview( " Indeterminate " ) {
109116 AsyncButton {
110117 try await Task . sleep ( nanoseconds: 30_000_000_000 )
111118 } label: {
112119 Image ( systemName: " ellipsis " )
113120 }
114121 . buttonStyle ( . borderedProminent)
115- . asyncButtonStyle ( . symbolEffect( . variableColor ) )
122+ . asyncButtonStyle ( . symbolEffect( . pulse ) )
116123}
0 commit comments