Skip to content

Commit

Permalink
Readying Recap for Swift 6
Browse files Browse the repository at this point in the history
  • Loading branch information
mergesort committed Oct 11, 2024
1 parent 9e8a812 commit 795c7c3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Sources/Recap/Public/IconFillMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion Sources/Recap/Public/RecapScreenStartIndex.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public enum RecapScreenStartIndex {
public enum RecapScreenStartIndex: Sendable {
case leadingView
case release(Int = 0)
case trailingView
Expand Down
6 changes: 3 additions & 3 deletions Sources/Recap/Public/ReleasesScreenDismissAction.swift
Original file line number Diff line number Diff line change
@@ -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
}

Expand Down
26 changes: 14 additions & 12 deletions Sources/Recap/Public/View+Recap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
)
Expand All @@ -126,7 +128,7 @@ internal extension EnvironmentValues {
}

private struct RecapScreenDismissActionKey: EnvironmentKey {
static var defaultValue: RecapScreenDismissAction?
static let defaultValue: RecapScreenDismissAction? = nil
}

// MARK: SelectedPageIndicatorColor
Expand All @@ -137,7 +139,7 @@ internal extension EnvironmentValues {
}

private struct SelectedPageIndicatorColorKey: EnvironmentKey {
static var defaultValue = Color.black
static let defaultValue = Color.black
}

// MARK: DeselectedPageIndicatorColor
Expand All @@ -148,7 +150,7 @@ internal extension EnvironmentValues {
}

private struct DeselectedPageIndicatorColorKey: EnvironmentKey {
static var defaultValue = Color.gray
static let defaultValue = Color.gray
}

// MARK: IconFillMode
Expand All @@ -159,7 +161,7 @@ internal extension EnvironmentValues {
}

private struct IconFillModeKey: EnvironmentKey {
static var defaultValue = IconFillMode.solid
static let defaultValue = IconFillMode.solid
}

// MARK: PaddingKey
Expand All @@ -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
Expand All @@ -181,7 +183,7 @@ internal extension EnvironmentValues {
}

private struct ItemSpacingKey: EnvironmentKey {
static var defaultValue = 32.0
static let defaultValue = 32.0
}

// MARK: HeaderSpacing
Expand All @@ -192,6 +194,6 @@ internal extension EnvironmentValues {
}

private struct HeaderSpacingKey: EnvironmentKey {
static var defaultValue = 32.0
static let defaultValue = 32.0
}
}

0 comments on commit 795c7c3

Please sign in to comment.