Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions Sources/Pow/Effects/ShakeEffect.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion Sources/Pow/Effects/SmokeEffect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -21,7 +22,9 @@ public extension AnyConditionalEffect {
)
}
}
#endif

#if !os(watchOS)
private struct SmokeEffect: ViewModifier, Continuous {
var isActive: Bool

Expand Down Expand Up @@ -69,6 +72,7 @@ private struct SmokeEffect: ViewModifier, Continuous {
}
}
}
#endif

#if os(iOS) || os(visionOS) || os(tvOS)
private class EmitterView: UIView {
Expand Down Expand Up @@ -108,6 +112,7 @@ private class EmitterView: NSView {
}
#endif

#if !os(watchOS)
private struct SmokeLayerView: ViewRepresentable {
var size: CGSize

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Sources/Pow/Effects/SpinEffect.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SwiftUI

#if !os(watchOS)
public extension AnyChangeEffect {
/// The rate of the spin effect.
enum SpinRate {
Expand Down Expand Up @@ -47,7 +48,9 @@ public extension AnyChangeEffect {
}
}
}
#endif

#if !os(watchOS)
internal struct SpinSimulationModifier: ViewModifier, Simulative {
var impulseCount: Int

Expand Down Expand Up @@ -143,6 +146,7 @@ internal struct SpinSimulationModifier: ViewModifier, Simulative {
}
}
}
#endif

#if os(iOS) && DEBUG
struct SpinSimulation_Previews: PreviewProvider {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Pow/Effects/WiggleEffect.swift
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -104,6 +107,7 @@ internal struct WiggleSimulationModifier: ViewModifier, Simulative {
wiggleCount = clamp(0, wiggleCount - 2 * (step / phaseLength), .infinity)
}
}
#endif


#if os(iOS) && DEBUG
Expand Down
1 change: 1 addition & 0 deletions Sources/Pow/Extensions/Duration+TimeInterval.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Sources/Pow/Extensions/ProjectionTransform+Utilities.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import simd
import SwiftUI

#if !os(watchOS)
internal extension ProjectionTransform {
init(_ m: simd_double4x4) {
let d = CATransform3D(
Expand All @@ -13,3 +14,4 @@ internal extension ProjectionTransform {
self.init(d)
}
}
#endif
3 changes: 3 additions & 0 deletions Sources/Pow/Infrastructure/AngleControl.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if !os(tvOS)
import SwiftUI

@available(watchOS 9.0, *)
struct AngleControl<Label: View>: View {
@Binding
var angle: Angle
Expand Down Expand Up @@ -81,6 +82,7 @@ struct AngleControl<Label: View>: View {
}
}

@available(watchOS 9.0, *)
extension AngleControl where Label == Text {
init(_ title: some StringProtocol, angle: Binding<Angle>) {
self._angle = angle
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Sources/Pow/Infrastructure/Transform3DEffect.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SwiftUI
import simd

#if !os(watchOS)
internal struct Transform3DEffect: GeometryEffect, Animatable {
var animatableData: AnimatablePair<TRS, AnimatablePair<Anchor3D, Double>> = .zero

Expand Down Expand Up @@ -69,15 +70,19 @@ internal struct Transform3DEffect: GeometryEffect, Animatable {
ShadedTransform3DEffect(animatableData: animatableData, lightSource: lightSource)
}
}
#endif

#if !os(watchOS)
extension Transform3DEffect {
internal struct Anchor3D: Equatable {
var xy: UnitPoint = .center

var z: Double = 0
}
}
#endif

#if !os(watchOS)
extension Transform3DEffect.Anchor3D: VectorArithmetic {
mutating func scale(by rhs: Double) {
xy.x *= rhs
Expand Down Expand Up @@ -111,7 +116,9 @@ extension Transform3DEffect.Anchor3D: VectorArithmetic {
return result
}
}
#endif

#if !os(watchOS)
internal struct ShadedTransform3DEffect: ViewModifier, Animatable {
var animatableData: Transform3DEffect.AnimatableData

Expand Down Expand Up @@ -147,6 +154,7 @@ internal struct ShadedTransform3DEffect: ViewModifier, Animatable {
.modifier(Transform3DEffect(animatableData: animatableData))
}
}
#endif

#if os(iOS) && DEBUG
@available(iOS 16.0, *)
Expand Down
1 change: 1 addition & 0 deletions Sources/Pow/Infrastructure/WhileEffect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/Pow/Transitions/Flip.swift
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -64,6 +65,7 @@ public extension AnyTransition.MovingParts {
)
}
}
#endif

#if os(iOS) && DEBUG
@available(iOS 15.0, *)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Pow/Transitions/Move.swift
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)`.
Expand Down Expand Up @@ -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, *)
Expand Down
2 changes: 2 additions & 0 deletions Sources/Pow/Transitions/Swoosh.swift
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -21,6 +22,7 @@ public extension AnyTransition.MovingParts {
)
}
}
#endif

#if os(iOS) && DEBUG
@available(iOS 15.0, *)
Expand Down