Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose UITransaction APIs under @_spi #277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
14 changes: 8 additions & 6 deletions Sources/AppKitNavigation/AppKitAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Result>(
Expand Down Expand Up @@ -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)
}
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/SwiftNavigation/UITransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public func withUITransaction<R, V>(
/// 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<Key, any Sendable> = [:]

Expand Down
30 changes: 16 additions & 14 deletions Sources/UIKitNavigation/UIKitAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Result>(
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down