From 669ea6c0e59c753a10dc4fdede9cf2dac37190fc Mon Sep 17 00:00:00 2001 From: maximkrouk Date: Tue, 4 Mar 2025 21:10:39 +0100 Subject: [PATCH] Expose UITransaction APIs under @_spi - UITransaction.current - UIKitAnimation.Framework - AppKitAnimation.Framework --- .../AppKitNavigation/AppKitAnimation.swift | 14 +++++---- Sources/SwiftNavigation/UITransaction.swift | 4 ++- Sources/UIKitNavigation/UIKitAnimation.swift | 30 ++++++++++--------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Sources/AppKitNavigation/AppKitAnimation.swift b/Sources/AppKitNavigation/AppKitAnimation.swift index 096761ab3..5fa54c7d6 100644 --- a/Sources/AppKitNavigation/AppKitAnimation.swift +++ b/Sources/AppKitNavigation/AppKitAnimation.swift @@ -31,7 +31,8 @@ /// The way a view changes over time to create a smooth visual transition from one state to /// another. public struct AppKitAnimation: Hashable, Sendable { - fileprivate let framework: Framework + @_spi(Internals) + public let framework: Framework @MainActor func perform( @@ -68,15 +69,16 @@ } } - fileprivate enum Framework: Hashable, Sendable { + @_spi(Internals) + public enum Framework: Hashable, Sendable { case appKit(AppKit) case swiftUI(Animation) - fileprivate struct AppKit: Hashable, @unchecked Sendable { - fileprivate var duration: TimeInterval - fileprivate var timingFunction: CAMediaTimingFunction? + public struct AppKit: Hashable, @unchecked Sendable { + public var duration: TimeInterval + public var timingFunction: CAMediaTimingFunction? - func hash(into hasher: inout Hasher) { + public func hash(into hasher: inout Hasher) { hasher.combine(duration) } } diff --git a/Sources/SwiftNavigation/UITransaction.swift b/Sources/SwiftNavigation/UITransaction.swift index 3c81d45c2..d1161997f 100644 --- a/Sources/SwiftNavigation/UITransaction.swift +++ b/Sources/SwiftNavigation/UITransaction.swift @@ -39,7 +39,9 @@ public func withUITransaction( /// The root transaction for a state change comes from the binding that changed, plus any global /// values set by calling ``withUITransaction(_:_:)``. public struct UITransaction: Sendable { - @TaskLocal package static var current = Self() + /// Current TaskLocal transaction + @_spi(Internals) + @TaskLocal public static var current = Self() var storage: OrderedDictionary = [:] diff --git a/Sources/UIKitNavigation/UIKitAnimation.swift b/Sources/UIKitNavigation/UIKitAnimation.swift index f0fef59ea..d4cb9ff08 100644 --- a/Sources/UIKitNavigation/UIKitAnimation.swift +++ b/Sources/UIKitNavigation/UIKitAnimation.swift @@ -30,7 +30,8 @@ /// The way a view changes over time to create a smooth visual transition from one state to /// another. public struct UIKitAnimation: Hashable, Sendable { - fileprivate let framework: Framework + @_spi(Internals) + public let framework: Framework @MainActor func perform( @@ -115,19 +116,20 @@ } } - fileprivate enum Framework: Hashable, Sendable { + @_spi(Internals) + public enum Framework: Hashable, Sendable { case uiKit(UIKit) case swiftUI(Animation) - fileprivate struct UIKit: Hashable, Sendable { - fileprivate var delay: TimeInterval - fileprivate var duration: TimeInterval - fileprivate var options: UIView.AnimationOptions - fileprivate var repeatModifier: RepeatModifier? - fileprivate var speed: Double = 1 - fileprivate var style: Style + public struct UIKit: Hashable, Sendable { + public var delay: TimeInterval + public var duration: TimeInterval + public var options: UIView.AnimationOptions + public var repeatModifier: RepeatModifier? + public var speed: Double = 1 + public var style: Style - func hash(into hasher: inout Hasher) { + public func hash(into hasher: inout Hasher) { hasher.combine(delay) hasher.combine(duration) hasher.combine(options.rawValue) @@ -136,12 +138,12 @@ hasher.combine(style) } - fileprivate struct RepeatModifier: Hashable, Sendable { - var autoreverses = true - var count: CGFloat = 1 + public struct RepeatModifier: Hashable, Sendable { + public var autoreverses = true + public var count: CGFloat = 1 } - fileprivate enum Style: Hashable, Sendable { + public enum Style: Hashable, Sendable { case iOS4 case iOS7(dampingRatio: CGFloat, velocity: CGFloat) case iOS17(bounce: CGFloat = 0, initialSpringVelocity: CGFloat = 0)