This commit is contained in:
Jan Hülsmann 2026-02-27 00:20:21 +01:00 committed by GitHub
commit d0d87fed05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 44 additions and 2 deletions

View file

@ -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.

View file

@ -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 {

View file

@ -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

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,6 +1,7 @@
#if !os(tvOS)
import SwiftUI
@available(watchOS 9.0, *)
struct AngleControl<Label: View>: View {
@Binding
var angle: Angle
@ -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
@ -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

View file

@ -1,6 +1,7 @@
import SwiftUI
import simd
#if !os(watchOS)
internal struct Transform3DEffect: GeometryEffect, Animatable {
var animatableData: AnimatablePair<TRS, AnimatablePair<Anchor3D, Double>> = .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, *)

View file

@ -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))
}

View file

@ -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, *)

View file

@ -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, *)

View file

@ -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, *)