diff --git a/Package.swift b/Package.swift index 9a61280..c57e540 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,8 @@ let package = Package( .iOS(.v15), .macOS(.v12), .macCatalyst(.v15), - .tvOS(.v15) + .tvOS(.v15), + .watchOS(.v8) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Sources/Pow/Effects/ShakeEffect.swift b/Sources/Pow/Effects/ShakeEffect.swift index 529db0d..bf1aace 100644 --- a/Sources/Pow/Effects/ShakeEffect.swift +++ b/Sources/Pow/Effects/ShakeEffect.swift @@ -1,5 +1,6 @@ import SwiftUI +#if !os(watchOS) public extension AnyChangeEffect { /// An effect that shakes the view when a change happens. static var shake: AnyChangeEffect { @@ -32,7 +33,9 @@ public extension AnyChangeEffect { } } } +#endif +#if !os(watchOS) internal struct ShakeSimulationModifier: ViewModifier, Simulative { // TODO: Not used, remove from protocol var initialVelocity: CGFloat = 0 @@ -102,6 +105,7 @@ internal struct ShakeSimulationModifier: ViewModifier, Simulative { shakeCount = clamp(0, shakeCount - 2 * (step / phaseLength), .infinity) } } +#endif #if os(iOS) && DEBUG struct ShakeSimulation_Previews: PreviewProvider { diff --git a/Sources/Pow/Effects/SmokeEffect.swift b/Sources/Pow/Effects/SmokeEffect.swift index d661c76..1bbaeea 100644 --- a/Sources/Pow/Effects/SmokeEffect.swift +++ b/Sources/Pow/Effects/SmokeEffect.swift @@ -4,6 +4,7 @@ import simd import SnapshotPreferences #endif +#if !os(watchOS) public extension AnyConditionalEffect { /// An effect that emits smoke from the view. static var smoke: AnyConditionalEffect { @@ -21,7 +22,9 @@ public extension AnyConditionalEffect { ) } } +#endif +#if !os(watchOS) private struct SmokeEffect: ViewModifier, Continuous { var isActive: Bool @@ -69,6 +72,7 @@ private struct SmokeEffect: ViewModifier, Continuous { } } } +#endif #if os(iOS) || os(visionOS) || os(tvOS) private class EmitterView: UIView { @@ -108,6 +112,7 @@ private class EmitterView: NSView { } #endif +#if !os(watchOS) private struct SmokeLayerView: ViewRepresentable { var size: CGSize @@ -171,8 +176,9 @@ private struct SmokeLayerView: ViewRepresentable { view.emitterLayer.lifetime = isActive ? 1 : 0 } } +#endif -#if DEBUG && !os(tvOS) +#if DEBUG && !os(tvOS) && !os(watchOS) struct ContinuousParticleEffect_Previews: PreviewProvider { private struct Preview: View { @State diff --git a/Sources/Pow/Effects/SpinEffect.swift b/Sources/Pow/Effects/SpinEffect.swift index 545e6f7..84df0b3 100644 --- a/Sources/Pow/Effects/SpinEffect.swift +++ b/Sources/Pow/Effects/SpinEffect.swift @@ -1,5 +1,6 @@ import SwiftUI +#if !os(watchOS) public extension AnyChangeEffect { /// The rate of the spin effect. enum SpinRate { @@ -52,7 +53,9 @@ public extension AnyChangeEffect { } } } +#endif +#if !os(watchOS) internal struct SpinSimulationModifier: ViewModifier, Simulative { var impulseCount: Int @@ -150,6 +153,7 @@ internal struct SpinSimulationModifier: ViewModifier, Simulative { } } } +#endif #if os(iOS) && DEBUG struct SpinSimulation_Previews: PreviewProvider { diff --git a/Sources/Pow/Effects/WiggleEffect.swift b/Sources/Pow/Effects/WiggleEffect.swift index 98f93a0..de133a2 100644 --- a/Sources/Pow/Effects/WiggleEffect.swift +++ b/Sources/Pow/Effects/WiggleEffect.swift @@ -1,5 +1,6 @@ import SwiftUI +#if !os(watchOS) public extension AnyChangeEffect { /// An effect that wiggles the view when a change happens. static var wiggle: AnyChangeEffect { @@ -30,7 +31,9 @@ public extension AnyChangeEffect { }) } } +#endif +#if !os(watchOS) internal struct WiggleSimulationModifier: ViewModifier, Simulative { // TODO: Not used, remove from protocol var initialVelocity: CGFloat = 0 @@ -104,6 +107,7 @@ internal struct WiggleSimulationModifier: ViewModifier, Simulative { wiggleCount = clamp(0, wiggleCount - 2 * (step / phaseLength), .infinity) } } +#endif #if os(iOS) && DEBUG diff --git a/Sources/Pow/Extensions/Duration+TimeInterval.swift b/Sources/Pow/Extensions/Duration+TimeInterval.swift index 5436a33..6f15d37 100644 --- a/Sources/Pow/Extensions/Duration+TimeInterval.swift +++ b/Sources/Pow/Extensions/Duration+TimeInterval.swift @@ -3,6 +3,7 @@ import Foundation @available(iOS 16.0, *) @available(macOS 13.0, *) @available(tvOS 16.0, *) +@available(watchOS 9.0, *) internal extension Duration { var timeInterval: TimeInterval { TimeInterval(components.seconds) + TimeInterval(components.attoseconds) / 1e18 diff --git a/Sources/Pow/Extensions/ProjectionTransform+Utilities.swift b/Sources/Pow/Extensions/ProjectionTransform+Utilities.swift index 2ab5c62..d5ed425 100644 --- a/Sources/Pow/Extensions/ProjectionTransform+Utilities.swift +++ b/Sources/Pow/Extensions/ProjectionTransform+Utilities.swift @@ -1,6 +1,7 @@ import simd import SwiftUI +#if !os(watchOS) internal extension ProjectionTransform { init(_ m: simd_double4x4) { let d = CATransform3D( @@ -13,3 +14,4 @@ internal extension ProjectionTransform { self.init(d) } } +#endif diff --git a/Sources/Pow/Infrastructure/AngleControl.swift b/Sources/Pow/Infrastructure/AngleControl.swift index 9941fac..514fa64 100644 --- a/Sources/Pow/Infrastructure/AngleControl.swift +++ b/Sources/Pow/Infrastructure/AngleControl.swift @@ -1,6 +1,7 @@ #if !os(tvOS) import SwiftUI +@available(watchOS 9.0, *) struct AngleControl: View { @Binding var angle: Angle @@ -81,6 +82,7 @@ struct AngleControl: View { } } +@available(watchOS 9.0, *) extension AngleControl where Label == Text { init(_ title: some StringProtocol, angle: Binding) { self._angle = angle @@ -106,6 +108,7 @@ extension AngleControl where Label == Text { } } +@available(watchOS 9.0, *) struct AngleControl_Previews: PreviewProvider { struct Preview: View { @State var angle: Angle = .zero diff --git a/Sources/Pow/Infrastructure/Transform3DEffect.swift b/Sources/Pow/Infrastructure/Transform3DEffect.swift index 90eb9d9..e076345 100644 --- a/Sources/Pow/Infrastructure/Transform3DEffect.swift +++ b/Sources/Pow/Infrastructure/Transform3DEffect.swift @@ -1,6 +1,7 @@ import SwiftUI import simd +#if !os(watchOS) internal struct Transform3DEffect: GeometryEffect, Animatable { var animatableData: AnimatablePair> = .zero @@ -69,7 +70,9 @@ internal struct Transform3DEffect: GeometryEffect, Animatable { ShadedTransform3DEffect(animatableData: animatableData, lightSource: lightSource) } } +#endif +#if !os(watchOS) extension Transform3DEffect { internal struct Anchor3D: Equatable { var xy: UnitPoint = .center @@ -77,7 +80,9 @@ extension Transform3DEffect { var z: Double = 0 } } +#endif +#if !os(watchOS) extension Transform3DEffect.Anchor3D: VectorArithmetic { mutating func scale(by rhs: Double) { xy.x *= rhs @@ -111,7 +116,9 @@ extension Transform3DEffect.Anchor3D: VectorArithmetic { return result } } +#endif +#if !os(watchOS) internal struct ShadedTransform3DEffect: ViewModifier, Animatable { var animatableData: Transform3DEffect.AnimatableData @@ -147,6 +154,7 @@ internal struct ShadedTransform3DEffect: ViewModifier, Animatable { .modifier(Transform3DEffect(animatableData: animatableData)) } } +#endif #if os(iOS) && DEBUG @available(iOS 16.0, *) diff --git a/Sources/Pow/Infrastructure/WhileEffect.swift b/Sources/Pow/Infrastructure/WhileEffect.swift index ea4cb21..d335db7 100644 --- a/Sources/Pow/Infrastructure/WhileEffect.swift +++ b/Sources/Pow/Infrastructure/WhileEffect.swift @@ -55,6 +55,7 @@ public struct AnyConditionalEffect { @available(iOS 16.0, *) @available(macOS 13.0, *) @available(tvOS 16.0, *) + @available(watchOS 9.0, *) public static func `repeat`(_ effect: AnyChangeEffect, every interval: Duration) -> AnyConditionalEffect { AnyConditionalEffect(guts: .repeating(effect, interval.timeInterval)) } diff --git a/Sources/Pow/Transitions/Flip.swift b/Sources/Pow/Transitions/Flip.swift index 808932f..dc340a5 100644 --- a/Sources/Pow/Transitions/Flip.swift +++ b/Sources/Pow/Transitions/Flip.swift @@ -1,6 +1,7 @@ import SwiftUI import simd +#if !os(watchOS) public extension AnyTransition.MovingParts { /// A transition that inserts by rotating the view towards the viewer, and /// removes by rotating the view away from the viewer. @@ -64,6 +65,7 @@ public extension AnyTransition.MovingParts { ) } } +#endif #if os(iOS) && DEBUG @available(iOS 15.0, *) diff --git a/Sources/Pow/Transitions/Move.swift b/Sources/Pow/Transitions/Move.swift index 436aec2..7bb7111 100644 --- a/Sources/Pow/Transitions/Move.swift +++ b/Sources/Pow/Transitions/Move.swift @@ -1,6 +1,7 @@ import SwiftUI import simd +#if !os(watchOS) public extension AnyTransition.MovingParts { /// A transition that moves the view from the specified edge of the on /// insertion and towards it on removal. @@ -35,7 +36,9 @@ public extension AnyTransition.MovingParts { ) } } +#endif +#if !os(watchOS) internal struct Move: GeometryEffect, Animatable { /// Translation is relative, depth is ignored, anchor is always /// `UnitPoint(0.5, 0.5)`. @@ -90,6 +93,7 @@ internal struct Move: GeometryEffect, Animatable { return ProjectionTransform((((offset * translation) * rotation) * scale) * offset.inverse) } } +#endif #if os(iOS) && DEBUG @available(iOS 15.0, *) diff --git a/Sources/Pow/Transitions/Swoosh.swift b/Sources/Pow/Transitions/Swoosh.swift index eff113b..5cdcadd 100644 --- a/Sources/Pow/Transitions/Swoosh.swift +++ b/Sources/Pow/Transitions/Swoosh.swift @@ -1,6 +1,7 @@ import SwiftUI import simd +#if !os(watchOS) public extension AnyTransition.MovingParts { /// A three-dimensional transition from the back of the towards the front /// during insertion and from the front towards the back during removal. @@ -21,6 +22,7 @@ public extension AnyTransition.MovingParts { ) } } +#endif #if os(iOS) && DEBUG @available(iOS 15.0, *)