11//
2- // ThrowableStyle+Shake .swift
2+ // AsyncStyle+SymbolEffect .swift
33// ButtonKit
44//
55// MIT License
2727
2828import SwiftUI
2929
30- @available ( iOS 17 . 0 , macOS 14 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , * )
30+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
3131public struct SymbolEffectAsyncButtonStyle < Effect: SymbolEffect & IndefiniteSymbolEffect > : AsyncButtonStyle {
3232 let effect : Effect
3333
@@ -37,80 +37,86 @@ public struct SymbolEffectAsyncButtonStyle<Effect: SymbolEffect&IndefiniteSymbol
3737 }
3838}
3939
40- @available ( iOS 17 . 0 , macOS 14 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , * )
40+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
4141extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < AppearSymbolEffect > {
4242 public static func symbolEffect( _ effect: AppearSymbolEffect ) -> some AsyncButtonStyle {
4343 SymbolEffectAsyncButtonStyle ( effect: effect)
4444 }
4545}
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 {
46+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
47+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DisappearSymbolEffect > {
48+ public static func symbolEffect( _ effect: DisappearSymbolEffect ) -> some AsyncButtonStyle {
4949 SymbolEffectAsyncButtonStyle ( effect: effect)
5050 }
5151}
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 {
52+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
53+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < PulseSymbolEffect > {
54+ public static func symbolEffect( _ effect: PulseSymbolEffect ) -> some AsyncButtonStyle {
5555 SymbolEffectAsyncButtonStyle ( effect: effect)
5656 }
5757}
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 {
58+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
59+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < ScaleSymbolEffect > {
60+ public static func symbolEffect( _ effect: ScaleSymbolEffect ) -> some AsyncButtonStyle {
6161 SymbolEffectAsyncButtonStyle ( effect: effect)
6262 }
6363}
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 {
64+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
65+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < VariableColorSymbolEffect > {
66+ public static func symbolEffect( _ effect: VariableColorSymbolEffect ) -> some AsyncButtonStyle {
6767 SymbolEffectAsyncButtonStyle ( effect: effect)
6868 }
6969}
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 {
70+
71+ @available ( macOS 15 . 0 , iOS 18 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , visionOS 2 . 0 , * )
72+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < BounceSymbolEffect > {
73+ public static func symbolEffect( _ effect: BounceSymbolEffect ) -> some AsyncButtonStyle {
7374 SymbolEffectAsyncButtonStyle ( effect: effect)
7475 }
7576}
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 {
77+ @available ( macOS 15 . 0 , iOS 18 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , visionOS 2 . 0 , * )
78+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < BreatheSymbolEffect > {
79+ public static func symbolEffect( _ effect: BreatheSymbolEffect ) -> some AsyncButtonStyle {
7980 SymbolEffectAsyncButtonStyle ( effect: effect)
8081 }
8182}
82- @available ( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , * )
83+ @available ( macOS 15 . 0 , iOS 18 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , visionOS 2 . 0 , * )
8384extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < RotateSymbolEffect > {
8485 public static func symbolEffect( _ effect: RotateSymbolEffect ) -> some AsyncButtonStyle {
8586 SymbolEffectAsyncButtonStyle ( effect: effect)
8687 }
8788}
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 {
89+ @available ( macOS 15 . 0 , iOS 18 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , visionOS 2 . 0 , * )
90+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < WiggleSymbolEffect > {
91+ public static func symbolEffect( _ effect: WiggleSymbolEffect ) -> some AsyncButtonStyle {
9192 SymbolEffectAsyncButtonStyle ( effect: effect)
9293 }
9394}
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 {
95+
96+ #if swift(>=6.2)
97+
98+ @available ( macOS 26 . 0 , iOS 26 . 0 , tvOS 26 . 0 , watchOS 26 . 0 , * )
99+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DrawOffSymbolEffect > {
100+ public static func symbolEffect( _ effect: DrawOffSymbolEffect ) -> some AsyncButtonStyle {
97101 SymbolEffectAsyncButtonStyle ( effect: effect)
98102 }
99103}
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 {
104+ @available ( macOS 26 . 0 , iOS 26 . 0 , tvOS 26 . 0 , watchOS 26 . 0 , * )
105+ extension AsyncButtonStyle where Self == SymbolEffectAsyncButtonStyle < DrawOnSymbolEffect > {
106+ public static func symbolEffect( _ effect: DrawOnSymbolEffect ) -> some AsyncButtonStyle {
103107 SymbolEffectAsyncButtonStyle ( effect: effect)
104108 }
105109}
106110
107- @available ( iOS 18 . 0 , macOS 15 . 0 , tvOS 18 . 0 , watchOS 11 . 0 , * )
111+ #endif
112+
113+ @available ( macOS 14 . 0 , iOS 17 . 0 , tvOS 17 . 0 , watchOS 10 . 0 , visionOS 1 . 0 , * )
108114#Preview( " Indeterminate " ) {
109115 AsyncButton {
110116 try await Task . sleep ( nanoseconds: 30_000_000_000 )
111117 } label: {
112118 Image ( systemName: " ellipsis " )
113119 }
114120 . buttonStyle ( . borderedProminent)
115- . asyncButtonStyle ( . symbolEffect( . variableColor ) )
121+ . asyncButtonStyle ( . symbolEffect( . pulse ) )
116122}
0 commit comments