From ebf05a2239eaded68a17bb417a4fbbb4ca431849 Mon Sep 17 00:00:00 2001 From: Nick Kohrn Date: Sat, 6 Apr 2024 12:13:48 -0400 Subject: [PATCH 1/3] [README] Fix Sound Effect Feedback Documentation (#64) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da78233..866b4b1 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ static func shine(angle: Angle, duration: Double = 1.0) -> AnyChangeEffect Triggers a sound effect as feedback whenever a value changes. -This effect will not interrupt or duck any other audio that may currently playing. It may also not triggered based on the setting of the user's silent switch or playback device. +This effect will not interrupt or duck any other audio that may be currently playing. This effect is not guaranteed to be triggered; the effect running depends on the user's silent switch position and the current playback device. To relay important information to the user, you should always accompany audio effects with visual cues. From 5ac714041351f0160e918ef3a91f7f282217bac0 Mon Sep 17 00:00:00 2001 From: Joe Fabisevich Date: Sun, 19 May 2024 14:33:56 -0400 Subject: [PATCH 2/3] Adding custom phase length options for WiggleRate and ShakeRate (#62) --- Sources/Pow/Effects/ShakeEffect.swift | 2 ++ Sources/Pow/Effects/WiggleEffect.swift | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Sources/Pow/Effects/ShakeEffect.swift b/Sources/Pow/Effects/ShakeEffect.swift index 59cb4ab..529db0d 100644 --- a/Sources/Pow/Effects/ShakeEffect.swift +++ b/Sources/Pow/Effects/ShakeEffect.swift @@ -12,11 +12,13 @@ public extension AnyChangeEffect { enum ShakeRate { case `default` case fast + case phaseLength(CGFloat) fileprivate var phaseLength: CGFloat { switch self { case .default: return 0.8 case .fast: return 0.3 + case .phaseLength(let phaseLength): return phaseLength } } } diff --git a/Sources/Pow/Effects/WiggleEffect.swift b/Sources/Pow/Effects/WiggleEffect.swift index 7cad1d8..98f93a0 100644 --- a/Sources/Pow/Effects/WiggleEffect.swift +++ b/Sources/Pow/Effects/WiggleEffect.swift @@ -10,11 +10,13 @@ public extension AnyChangeEffect { enum WiggleRate { case `default` case fast + case phaseLength(CGFloat) fileprivate var phaseLength: CGFloat { switch self { case .default: return 0.8 case .fast: return 0.3 + case .phaseLength(let phaseLength): return phaseLength } } } From f0d0f3e72d42beaf2b01f1cb798e1b55902814eb Mon Sep 17 00:00:00 2001 From: Adam McNight Date: Sun, 19 May 2024 20:44:29 +0200 Subject: [PATCH 3/3] Add tvOS support (#66) --- Package.swift | 3 ++- Sources/Pow/Effects/SmokeEffect.swift | 6 +++--- Sources/Pow/Extensions/Duration+TimeInterval.swift | 1 + Sources/Pow/Infrastructure/AngleControl.swift | 2 ++ Sources/Pow/Infrastructure/WhileEffect.swift | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index a27f82d..7e6bb2a 100644 --- a/Package.swift +++ b/Package.swift @@ -10,7 +10,8 @@ let package = Package( platforms: [ .iOS(.v15), .macOS(.v12), - .macCatalyst(.v15) + .macCatalyst(.v15), + .tvOS(.v15) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Sources/Pow/Effects/SmokeEffect.swift b/Sources/Pow/Effects/SmokeEffect.swift index 660ed7f..d661c76 100644 --- a/Sources/Pow/Effects/SmokeEffect.swift +++ b/Sources/Pow/Effects/SmokeEffect.swift @@ -57,7 +57,7 @@ private struct SmokeEffect: ViewModifier, Continuous { GeometryReader { proxy in ZStack { ForEach(Array(particles.enumerated()), id: \.element) { (offset, particle) in - #if os(iOS) || os(visionOS) + #if os(iOS) || os(visionOS) || os(tvOS) let image = UIImage(named: particle, in: .module, with: nil)!.cgImage! #elseif os(macOS) let image = Bundle.module.image(forResource: particle)!.cgImage(forProposedRect: nil, context: nil, hints: nil)! @@ -70,7 +70,7 @@ private struct SmokeEffect: ViewModifier, Continuous { } } -#if os(iOS) || os(visionOS) +#if os(iOS) || os(visionOS) || os(tvOS) private class EmitterView: UIView { override class var layerClass : AnyClass { return CAEmitterLayer.self @@ -172,7 +172,7 @@ private struct SmokeLayerView: ViewRepresentable { } } -#if DEBUG +#if DEBUG && !os(tvOS) struct ContinuousParticleEffect_Previews: PreviewProvider { private struct Preview: View { @State diff --git a/Sources/Pow/Extensions/Duration+TimeInterval.swift b/Sources/Pow/Extensions/Duration+TimeInterval.swift index 7375eb6..5436a33 100644 --- a/Sources/Pow/Extensions/Duration+TimeInterval.swift +++ b/Sources/Pow/Extensions/Duration+TimeInterval.swift @@ -2,6 +2,7 @@ import Foundation @available(iOS 16.0, *) @available(macOS 13.0, *) +@available(tvOS 16.0, *) internal extension Duration { var timeInterval: TimeInterval { TimeInterval(components.seconds) + TimeInterval(components.attoseconds) / 1e18 diff --git a/Sources/Pow/Infrastructure/AngleControl.swift b/Sources/Pow/Infrastructure/AngleControl.swift index 564c194..9941fac 100644 --- a/Sources/Pow/Infrastructure/AngleControl.swift +++ b/Sources/Pow/Infrastructure/AngleControl.swift @@ -1,3 +1,4 @@ +#if !os(tvOS) import SwiftUI struct AngleControl: View { @@ -132,3 +133,4 @@ struct AngleControl_Previews: PreviewProvider { .padding() } } +#endif diff --git a/Sources/Pow/Infrastructure/WhileEffect.swift b/Sources/Pow/Infrastructure/WhileEffect.swift index 2de7d02..ea4cb21 100644 --- a/Sources/Pow/Infrastructure/WhileEffect.swift +++ b/Sources/Pow/Infrastructure/WhileEffect.swift @@ -54,6 +54,7 @@ public struct AnyConditionalEffect { /// - interval: The duration between each change effect. @available(iOS 16.0, *) @available(macOS 13.0, *) + @available(tvOS 16.0, *) public static func `repeat`(_ effect: AnyChangeEffect, every interval: Duration) -> AnyConditionalEffect { AnyConditionalEffect(guts: .repeating(effect, interval.timeInterval)) }