From 795c7c3336efc9687489c95454e9cc0fca9bc35b Mon Sep 17 00:00:00 2001 From: Joe Fabisevich Date: Fri, 11 Oct 2024 14:02:50 -0400 Subject: [PATCH] Readying Recap for Swift 6 --- Sources/Recap/Public/IconFillMode.swift | 2 +- .../Recap/Public/RecapScreenStartIndex.swift | 2 +- .../Public/ReleasesScreenDismissAction.swift | 6 ++--- Sources/Recap/Public/View+Recap.swift | 26 ++++++++++--------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Sources/Recap/Public/IconFillMode.swift b/Sources/Recap/Public/IconFillMode.swift index 76ed0c5..c7275d1 100644 --- a/Sources/Recap/Public/IconFillMode.swift +++ b/Sources/Recap/Public/IconFillMode.swift @@ -2,7 +2,7 @@ import Foundation /// - `solid`: The icon will be displayed as a solid color. /// - `gradient`: The icon will be displayed with a gradient overlay. -public enum IconFillMode { +public enum IconFillMode: Sendable { case solid case gradient } diff --git a/Sources/Recap/Public/RecapScreenStartIndex.swift b/Sources/Recap/Public/RecapScreenStartIndex.swift index 31870a2..8cb42ca 100644 --- a/Sources/Recap/Public/RecapScreenStartIndex.swift +++ b/Sources/Recap/Public/RecapScreenStartIndex.swift @@ -1,4 +1,4 @@ -public enum RecapScreenStartIndex { +public enum RecapScreenStartIndex: Sendable { case leadingView case release(Int = 0) case trailingView diff --git a/Sources/Recap/Public/ReleasesScreenDismissAction.swift b/Sources/Recap/Public/ReleasesScreenDismissAction.swift index 71a0b62..21259de 100644 --- a/Sources/Recap/Public/ReleasesScreenDismissAction.swift +++ b/Sources/Recap/Public/ReleasesScreenDismissAction.swift @@ -1,12 +1,12 @@ /// A customizable action for the `RecapScreen` dismiss button, useful when your screen is presented through non-standard means. -public struct RecapScreenDismissAction { +public struct RecapScreenDismissAction: Sendable { /// The closure that defines the dismiss action. - public let dismissAction: (() -> Void) + public let dismissAction: (@Sendable () -> Void) /// Initializes a new `RecapScreenDismissAction` with a custom dismiss action. /// /// - Parameter dismissAction: A closure that will be executed when the dismiss action is triggered. - public init(dismissAction: @escaping (() -> Void)) { + public init(dismissAction: @escaping (@Sendable () -> Void)) { self.dismissAction = dismissAction } diff --git a/Sources/Recap/Public/View+Recap.swift b/Sources/Recap/Public/View+Recap.swift index 7b60e92..1795750 100644 --- a/Sources/Recap/Public/View+Recap.swift +++ b/Sources/Recap/Public/View+Recap.swift @@ -70,7 +70,7 @@ public extension View { } /// Configures a customizable action for the `RecapScreen` dismiss button, useful when your screen is presented through non-standard means. - func recapScreenDismissAction(_ dismissAction: (() -> Void)?) -> some View { + func recapScreenDismissAction(_ dismissAction: (@Sendable () -> Void)?) -> some View { if let dismissAction { self.environment(\.recapScreenDismissAction, RecapScreenDismissAction(dismissAction: dismissAction)) } else { @@ -84,13 +84,15 @@ public extension View { internal extension EnvironmentValues { // MARK: StartIndex - var recapScreenStartIndex: RecapScreenStartIndex { + @Entry var recapScreenStartIndex = RecapScreenStartIndex.leadingView + + var recapScreenStartIndex2: RecapScreenStartIndex { get { self[RecapScreenStartIndexKey.self] } set { self[RecapScreenStartIndexKey.self] = newValue } } private struct RecapScreenStartIndexKey: EnvironmentKey { - static var defaultValue = RecapScreenStartIndex.leadingView + static let defaultValue = RecapScreenStartIndex.leadingView } // MARK: TitleStyle @@ -101,7 +103,7 @@ internal extension EnvironmentValues { } private struct TitleStyleKey: EnvironmentKey { - static var defaultValue = AnyShapeStyle(Color.black) + static let defaultValue = AnyShapeStyle(Color.black) } // MARK: DismissButtonStyle @@ -112,7 +114,7 @@ internal extension EnvironmentValues { } private struct DismissButtonStyleKey: EnvironmentKey { - static var defaultValue = RecapScreenDismissButtonStyle( + static let defaultValue = RecapScreenDismissButtonStyle( backgroundStyle: AnyShapeStyle(Color.blue), foregroundStyle: AnyShapeStyle(Color.white) ) @@ -126,7 +128,7 @@ internal extension EnvironmentValues { } private struct RecapScreenDismissActionKey: EnvironmentKey { - static var defaultValue: RecapScreenDismissAction? + static let defaultValue: RecapScreenDismissAction? = nil } // MARK: SelectedPageIndicatorColor @@ -137,7 +139,7 @@ internal extension EnvironmentValues { } private struct SelectedPageIndicatorColorKey: EnvironmentKey { - static var defaultValue = Color.black + static let defaultValue = Color.black } // MARK: DeselectedPageIndicatorColor @@ -148,7 +150,7 @@ internal extension EnvironmentValues { } private struct DeselectedPageIndicatorColorKey: EnvironmentKey { - static var defaultValue = Color.gray + static let defaultValue = Color.gray } // MARK: IconFillMode @@ -159,7 +161,7 @@ internal extension EnvironmentValues { } private struct IconFillModeKey: EnvironmentKey { - static var defaultValue = IconFillMode.solid + static let defaultValue = IconFillMode.solid } // MARK: PaddingKey @@ -170,7 +172,7 @@ internal extension EnvironmentValues { } private struct PaddingKey: EnvironmentKey { - static var defaultValue = EdgeInsets(top: 48.0, leading: 32.0, bottom: 24.0, trailing: 32.0) + static let defaultValue = EdgeInsets(top: 48.0, leading: 32.0, bottom: 24.0, trailing: 32.0) } // MARK: ItemSpacing @@ -181,7 +183,7 @@ internal extension EnvironmentValues { } private struct ItemSpacingKey: EnvironmentKey { - static var defaultValue = 32.0 + static let defaultValue = 32.0 } // MARK: HeaderSpacing @@ -192,6 +194,6 @@ internal extension EnvironmentValues { } private struct HeaderSpacingKey: EnvironmentKey { - static var defaultValue = 32.0 + static let defaultValue = 32.0 } } -- 2.51.2