From 8af2ddb0a023aa14a645adcb35b660d4db4e1e44 Mon Sep 17 00:00:00 2001 From: Alexandr Romanov Date: Tue, 15 Oct 2024 21:37:26 +0400 Subject: [PATCH] Adopt Swift 6 --- Package.swift | 2 +- .../Controls/Checkbox/Checkbox.swift | 24 ++- .../ColorSelector/ColorSelectorStyle.swift | 6 +- .../Styles/AnyColorSelectorStyle.swift | 2 +- .../Controls/GridSelect/GridSelectStyle.swift | 12 +- Sources/OversizeUI/Controls/Radio/Radio.swift | 22 +- .../Controls/Radio/RadioPicker.swift | 22 +- .../Controls/SectionView/SectionView.swift | 12 +- .../SegmentedControlStyle.swift | 154 ++++++++------ .../OversizeUI/Controls/Switch/Switch.swift | 24 ++- .../TextField/LabeledTextFieldStyle.swift | 30 --- .../Core/Appearance/Appearance.swift | 4 +- .../OversizeUI/Core/Appearance/Theme.swift | 2 +- .../Core/Appearance/ThemeSettings.swift | 32 +-- Sources/OversizeUI/Core/Colors.swift | 126 +++++------ Sources/OversizeUI/Core/EdgeSpaceInsets.swift | 2 +- Sources/OversizeUI/Core/Elevation.swift | 2 +- .../EnvironmentKeys/AccentEnvironment.swift | 2 +- .../EnvironmentKeys/BorderedEnvironment.swift | 2 +- .../ControlBorderShapeEnvironment.swift | 4 +- .../ControlPaddingEnvironment.swift | 4 +- .../ElevationEnvironment.swift | 2 +- .../FieldLabelPositionEnvironment.swift | 4 +- .../FieldPositionEnvironment.swift | 2 +- .../IconStyleEnvironment.swift | 4 +- .../EnvironmentKeys/LoadingEnvironment.swift | 2 +- .../MultiSelectStyleEnvironment.swift | 4 +- .../Core/EnvironmentKeys/Platform.swift | 54 +++-- .../EnvironmentKeys/PortraitEnvironment.swift | 2 +- .../EnvironmentKeys/PremiumEnvironment.swift | 2 +- .../EnvironmentKeys/RadiusEnvironment.swift | 2 +- .../ScreenSizeEnvironment.swift | 2 +- .../SectionViewStyleEnvironment.swift | 2 +- .../SelectPickerStyleEnvironment.swift | 4 +- .../SurfaceElevationEnvironment.swift | 2 +- .../SurfaceRadiusEnvironment.swift | 2 +- .../EnvironmentKeys/ThemeEnvironment.swift | 2 +- Sources/OversizeUI/Core/Palette.swift | 6 +- .../ScrollOffsetPreferenceKey.swift | 2 +- .../PreferenceKeys/SizePreferenceKey.swift | 2 +- Sources/OversizeUI/Core/Radius.swift | 2 +- Sources/OversizeUI/Core/Space.swift | 2 +- Sources/OversizeUI/Core/Typography.swift | 200 +++++++----------- Sources/OversizeUI/Core/Validation.swift | 2 +- .../ViewModifier/HalfSheet/HalfSheet.swift | 4 +- Sources/OversizeUI/Deprecated/Icon.swift | 10 +- .../Deprecated/TextFieldDeprecated.swift | 173 --------------- .../OversizeUI/Deprecated/ViewOffsetKey.swift | 2 +- .../Extensions/Padding/Padding.swift | 12 +- .../Extensions/Spacing/Spacing.swift | 16 +- .../OversizeUI/Extensions/View/View+If.swift | 2 +- .../Shapes/RoundedRectangleCorner.swift | 2 +- 52 files changed, 410 insertions(+), 609 deletions(-) delete mode 100644 Sources/OversizeUI/Deprecated/TextFieldDeprecated.swift diff --git a/Package.swift b/Package.swift index 9c6c4ca..96be672 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.9 +// swift-tools-version: 6.0 // The swift-tools-version declares the minimum version of Swift required to build this package. // swiftlint:disable all diff --git a/Sources/OversizeUI/Controls/Checkbox/Checkbox.swift b/Sources/OversizeUI/Controls/Checkbox/Checkbox.swift index 1683531..e72a2d8 100644 --- a/Sources/OversizeUI/Controls/Checkbox/Checkbox.swift +++ b/Sources/OversizeUI/Controls/Checkbox/Checkbox.swift @@ -5,7 +5,7 @@ import SwiftUI -public enum CheckboxAlignment { +public enum CheckboxAlignment: Sendable { case leading, trailing } @@ -115,16 +115,18 @@ public extension Checkbox where Label == EmptyView { } } -struct Checkbox_LibraryContent: LibraryContentProvider { - var views: [LibraryItem] { - LibraryItem( - Checkbox(isOn: .constant(false), label: { - Text("Text") - }), - title: "Checkbox", category: .control - ) - } -} +/* + struct Checkbox_LibraryContent: LibraryContentProvider { + var views: [LibraryItem] { + LibraryItem( + Checkbox(isOn: .constant(false), label: { + Text("Text") + }), + title: "Checkbox", category: .control + ) + } + } + */ struct Checkbox_preview: PreviewProvider { static var previews: some View { diff --git a/Sources/OversizeUI/Controls/ColorSelector/ColorSelectorStyle.swift b/Sources/OversizeUI/Controls/ColorSelector/ColorSelectorStyle.swift index 03f792a..42ae91a 100644 --- a/Sources/OversizeUI/Controls/ColorSelector/ColorSelectorStyle.swift +++ b/Sources/OversizeUI/Controls/ColorSelector/ColorSelectorStyle.swift @@ -5,14 +5,14 @@ import SwiftUI -public protocol ColorSelectorStyle { +public protocol ColorSelectorStyle: Sendable { associatedtype Body: View typealias Configuration = ColorSelectorConfiguration func makeBody(configuration: Self.Configuration) -> Self.Body } -public struct ColorSelectorConfiguration { +public struct ColorSelectorConfiguration: Sendable { public struct Label: View { public init(content: some View) { body = AnyView(content) @@ -31,7 +31,7 @@ public struct DefaultColorSelectorStyle: ColorSelectorStyle { } struct ColorSelectorStyleStyleKey: EnvironmentKey { - public static var defaultValue = AnyColorSelectorStyle(style: DefaultColorSelectorStyle()) + public static let defaultValue = AnyColorSelectorStyle(style: DefaultColorSelectorStyle()) } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Controls/ColorSelector/Styles/AnyColorSelectorStyle.swift b/Sources/OversizeUI/Controls/ColorSelector/Styles/AnyColorSelectorStyle.swift index 2ce0164..e99bffd 100644 --- a/Sources/OversizeUI/Controls/ColorSelector/Styles/AnyColorSelectorStyle.swift +++ b/Sources/OversizeUI/Controls/ColorSelector/Styles/AnyColorSelectorStyle.swift @@ -6,7 +6,7 @@ import SwiftUI public struct AnyColorSelectorStyle: ColorSelectorStyle { - private var _makeBody: (Configuration) -> AnyView + private var _makeBody: @Sendable (Configuration) -> AnyView public init(style: some ColorSelectorStyle) { _makeBody = { configuration in diff --git a/Sources/OversizeUI/Controls/GridSelect/GridSelectStyle.swift b/Sources/OversizeUI/Controls/GridSelect/GridSelectStyle.swift index 0023816..d097c13 100644 --- a/Sources/OversizeUI/Controls/GridSelect/GridSelectStyle.swift +++ b/Sources/OversizeUI/Controls/GridSelect/GridSelectStyle.swift @@ -57,24 +57,24 @@ public struct SelectionOnlyGridSelectStyle: GridSelectStyle { // MARK: - Support -public enum GridSelectSeletionIconStyle { +public enum GridSelectSeletionIconStyle: Sendable { case none case checkbox(alignment: Alignment = .bottomTrailing) case radio(alignment: Alignment = .bottomTrailing) } -public enum GridSelectSeletionStyle { +public enum GridSelectSeletionStyle: Sendable { case shadowSurface case graySurface case accentSurface } -public enum GridSelectUnseletionStyle { +public enum GridSelectUnseletionStyle: Sendable { case clean case surface } -public protocol GridSelectStyle { +public protocol GridSelectStyle: Sendable { associatedtype Body: View typealias Configuration = GridSelectConfiguration @@ -103,7 +103,7 @@ public struct AnyGridSelectStyle: GridSelectStyle { public var unseletionStyle: GridSelectUnseletionStyle public var icon: GridSelectSeletionIconStyle - private var _makeBody: (Configuration) -> AnyView + private var _makeBody: @Sendable (Configuration) -> AnyView public init( seletionStyle: GridSelectSeletionStyle, @@ -125,7 +125,7 @@ public struct AnyGridSelectStyle: GridSelectStyle { } struct GridSelectStyleKey: EnvironmentKey { - public static var defaultValue = AnyGridSelectStyle(seletionStyle: .accentSurface, + public static let defaultValue = AnyGridSelectStyle(seletionStyle: .accentSurface, unseletionStyle: .surface, icon: .none, style: IslandGridSelectStyle()) diff --git a/Sources/OversizeUI/Controls/Radio/Radio.swift b/Sources/OversizeUI/Controls/Radio/Radio.swift index 4bc8a4f..caf8b8d 100644 --- a/Sources/OversizeUI/Controls/Radio/Radio.swift +++ b/Sources/OversizeUI/Controls/Radio/Radio.swift @@ -121,16 +121,18 @@ public extension Radio where Label == EmptyView { } } -struct Radio_LibraryContent: LibraryContentProvider { - var views: [LibraryItem] { - LibraryItem( - Radio(isOn: false, alignment: .leading, label: { - Text("Text") - }), - title: "Chip", category: .control - ) - } -} +/* + struct Radio_LibraryContent: LibraryContentProvider { + var views: [LibraryItem] { + LibraryItem( + Radio(isOn: false, alignment: .leading, label: { + Text("Text") + }), + title: "Chip", category: .control + ) + } + } + */ struct Radio_preview: PreviewProvider { struct RadioPreview: View { diff --git a/Sources/OversizeUI/Controls/Radio/RadioPicker.swift b/Sources/OversizeUI/Controls/Radio/RadioPicker.swift index 0663843..d05b5d2 100644 --- a/Sources/OversizeUI/Controls/Radio/RadioPicker.swift +++ b/Sources/OversizeUI/Controls/Radio/RadioPicker.swift @@ -54,16 +54,18 @@ public struct RadioPicker: View where Content: View } } -struct RadioPicker_LibraryContent: LibraryContentProvider { - var views: [LibraryItem] { - LibraryItem( - RadioPicker(["One", "Two"], selection: .constant("One")) { item in - Text(item) - }, - title: "Radio Picker", category: .control - ) - } -} +/* + struct RadioPicker_LibraryContent: LibraryContentProvider { + var views: [LibraryItem] { + LibraryItem( + RadioPicker(["One", "Two"], selection: .constant("One")) { item in + Text(item) + }, + title: "Radio Picker", category: .control + ) + } + } + */ struct RadioPicker_previw: PreviewProvider { struct RadioPickerPreview: View { diff --git a/Sources/OversizeUI/Controls/SectionView/SectionView.swift b/Sources/OversizeUI/Controls/SectionView/SectionView.swift index 9822275..b1fb071 100644 --- a/Sources/OversizeUI/Controls/SectionView/SectionView.swift +++ b/Sources/OversizeUI/Controls/SectionView/SectionView.swift @@ -5,20 +5,20 @@ import SwiftUI -public enum SectionViewTitlePosition { +public enum SectionViewTitlePosition: Sendable { case inside, outside } -public enum SectionViewTitleButtonPosition { +public enum SectionViewTitleButtonPosition: Sendable { case leading, trailing } -public enum SectionViewTitleButton { - case arrow(_ action: () -> Void) - case title(_ title: String, _ action: () -> Void) +public enum SectionViewTitleButton: Sendable { + case arrow(_ action: @Sendable () -> Void) + case title(_ title: String, _ action: @Sendable () -> Void) } -public enum SectionViewStyle { +public enum SectionViewStyle: Sendable { case `default`, smallIndent, edgeToEdge } diff --git a/Sources/OversizeUI/Controls/SegmentedControl/SegmentedControlStyle.swift b/Sources/OversizeUI/Controls/SegmentedControl/SegmentedControlStyle.swift index 29286b9..7d634db 100644 --- a/Sources/OversizeUI/Controls/SegmentedControl/SegmentedControlStyle.swift +++ b/Sources/OversizeUI/Controls/SegmentedControl/SegmentedControlStyle.swift @@ -7,7 +7,7 @@ import SwiftUI // MARK: - Styles -public enum SegmentedControlStyleType { +public enum SegmentedControlStyleType: Sendable { case `default` case island(selected: SegmentedControlSeletionStyle = .shadowSurface) case islandLeading(selected: SegmentedControlSeletionStyle = .shadowSurface) @@ -17,13 +17,13 @@ public enum SegmentedControlStyleType { case onlySelectionScroll(selected: SegmentedControlSeletionStyle = .shadowSurface) } -public enum SegmentedControlSeletionStyle { +public enum SegmentedControlSeletionStyle: Sendable { case shadowSurface case graySurface case accentSurface } -public enum SegmentedControlUnseletionStyle { +public enum SegmentedControlUnseletionStyle: Sendable { case clean case surface } @@ -35,66 +35,94 @@ public extension View { case .default: let style: RectangleSegmentedControlStyle = .init() - return environment(\.segmentedControlStyle, - AnySegmentedControlStyle(isEquallySpacing: style.isEquallySpacing, - isShowBackground: style.isShowBackground, - seletionStyle: style.seletionStyle, - unseletionStyle: style.unseletionStyle, - style: style)) + return environment( + \.segmentedControlStyle, + AnySegmentedControlStyle( + isEquallySpacing: style.isEquallySpacing, + isShowBackground: style.isShowBackground, + seletionStyle: style.seletionStyle, + unseletionStyle: style.unseletionStyle, + style: style + ) + ) case let .island(selected: selected): let style: IslandSegmentedControlStyle = .init() - return environment(\.segmentedControlStyle, - AnySegmentedControlStyle(isEquallySpacing: true, - isShowBackground: false, - seletionStyle: selected, - unseletionStyle: .surface, - style: style)) + return environment( + \.segmentedControlStyle, + AnySegmentedControlStyle( + isEquallySpacing: true, + isShowBackground: false, + seletionStyle: selected, + unseletionStyle: .surface, + style: style + ) + ) case let .islandScroll(selected: selected): let style: ScrollSegmentedControlStyle = .init() - return environment(\.segmentedControlStyle, - AnySegmentedControlStyle(isEquallySpacing: false, - isShowBackground: false, - seletionStyle: selected, - unseletionStyle: .surface, - style: style)) + return environment( + \.segmentedControlStyle, + AnySegmentedControlStyle( + isEquallySpacing: false, + isShowBackground: false, + seletionStyle: selected, + unseletionStyle: .surface, + style: style + ) + ) case let .onlySelection(selected: selected): let style: SelectionOnlySegmentedControlStyle = .init() - return environment(\.segmentedControlStyle, - AnySegmentedControlStyle(isEquallySpacing: true, - isShowBackground: false, - seletionStyle: selected, - unseletionStyle: .clean, - style: style)) + return environment( + \.segmentedControlStyle, + AnySegmentedControlStyle( + isEquallySpacing: true, + isShowBackground: false, + seletionStyle: selected, + unseletionStyle: .clean, + style: style + ) + ) case let .onlySelectionLeading(selected: selected): let style: SelectionOnlySegmentedControlStyle = .init() - return environment(\.segmentedControlStyle, - AnySegmentedControlStyle(isEquallySpacing: false, - isShowBackground: false, - seletionStyle: selected, - unseletionStyle: .clean, - style: style)) + return environment( + \.segmentedControlStyle, + AnySegmentedControlStyle( + isEquallySpacing: false, + isShowBackground: false, + seletionStyle: selected, + unseletionStyle: .clean, + style: style + ) + ) case let .onlySelectionScroll(selected: selected): let style: ScrollSegmentedControlStyle = .init() - return environment(\.segmentedControlStyle, - AnySegmentedControlStyle(isEquallySpacing: false, - isShowBackground: false, - seletionStyle: selected, - unseletionStyle: .clean, - style: style)) + return environment( + \.segmentedControlStyle, + AnySegmentedControlStyle( + isEquallySpacing: false, + isShowBackground: false, + seletionStyle: selected, + unseletionStyle: .clean, + style: style + ) + ) case let .islandLeading(selected: selected): let style: IslandSegmentedControlStyle = .init() - return environment(\.segmentedControlStyle, - AnySegmentedControlStyle(isEquallySpacing: false, - isShowBackground: false, - seletionStyle: selected, - unseletionStyle: .surface, - style: style)) + return environment( + \.segmentedControlStyle, + AnySegmentedControlStyle( + isEquallySpacing: false, + isShowBackground: false, + seletionStyle: selected, + unseletionStyle: .surface, + style: style + ) + ) } } } @@ -187,7 +215,7 @@ public struct IslandSegmentedControlStyle: SegmentedControlStyle { // MARK: - Support -public protocol SegmentedControlStyle { +public protocol SegmentedControlStyle: Sendable { associatedtype Body: View typealias Configuration = SegmentedControlConfiguration @@ -199,7 +227,7 @@ public protocol SegmentedControlStyle { func makeBody(configuration: Self.Configuration) -> Self.Body } -public struct SegmentedControlConfiguration { +public struct SegmentedControlConfiguration: Sendable { public struct Label: View { public init(content: some View) { body = AnyView(content) @@ -211,7 +239,7 @@ public struct SegmentedControlConfiguration { public let label: SegmentedControlConfiguration.Label } -public struct AnySegmentedControlStyle: SegmentedControlStyle { +public struct AnySegmentedControlStyle: SegmentedControlStyle, Sendable { public var isEquallySpacing: Bool public var isShowBackground: Bool @@ -220,7 +248,7 @@ public struct AnySegmentedControlStyle: SegmentedControlStyle { public var unseletionStyle: SegmentedControlUnseletionStyle - private var _makeBody: (Configuration) -> AnyView + private var _makeBody: @Sendable (Configuration) -> AnyView public init(isEquallySpacing: Bool, isShowBackground: Bool, @@ -243,11 +271,13 @@ public struct AnySegmentedControlStyle: SegmentedControlStyle { } public struct SegmentedControlKey: EnvironmentKey { - public static var defaultValue = AnySegmentedControlStyle(isEquallySpacing: true, - isShowBackground: true, - seletionStyle: .shadowSurface, - unseletionStyle: .clean, - style: RectangleSegmentedControlStyle()) + public static let defaultValue = AnySegmentedControlStyle( + isEquallySpacing: true, + isShowBackground: true, + seletionStyle: .shadowSurface, + unseletionStyle: .clean, + style: RectangleSegmentedControlStyle() + ) } public extension EnvironmentValues { @@ -259,11 +289,15 @@ public extension EnvironmentValues { public extension View { func segmentedControlStyle(_ style: some SegmentedControlStyle) -> some View { - environment(\.segmentedControlStyle, - AnySegmentedControlStyle(isEquallySpacing: style.isEquallySpacing, - isShowBackground: style.isShowBackground, - seletionStyle: style.seletionStyle, - unseletionStyle: style.unseletionStyle, - style: style)) + environment( + \.segmentedControlStyle, + AnySegmentedControlStyle( + isEquallySpacing: style.isEquallySpacing, + isShowBackground: style.isShowBackground, + seletionStyle: style.seletionStyle, + unseletionStyle: style.unseletionStyle, + style: style + ) + ) } } diff --git a/Sources/OversizeUI/Controls/Switch/Switch.swift b/Sources/OversizeUI/Controls/Switch/Switch.swift index dac048d..da141b3 100644 --- a/Sources/OversizeUI/Controls/Switch/Switch.swift +++ b/Sources/OversizeUI/Controls/Switch/Switch.swift @@ -110,17 +110,19 @@ public extension Switch where Label == EmptyView { } } -@available(iOS 14.0, *) -struct Switch_LibraryContent: LibraryContentProvider { - var views: [LibraryItem] { - LibraryItem( - Switch(isOn: .constant(false)) { - Text("Text") - }, - title: "Checkbox", category: .control - ) - } -} +/* + @available(iOS 14.0, *) + struct Switch_LibraryContent: LibraryContentProvider { + var views: [LibraryItem] { + LibraryItem( + Switch(isOn: .constant(false)) { + Text("Text") + }, + title: "Checkbox", category: .control + ) + } + } + */ struct Switch_preview: PreviewProvider { static var previews: some View { diff --git a/Sources/OversizeUI/Controls/TextField/LabeledTextFieldStyle.swift b/Sources/OversizeUI/Controls/TextField/LabeledTextFieldStyle.swift index 0e41744..0190799 100644 --- a/Sources/OversizeUI/Controls/TextField/LabeledTextFieldStyle.swift +++ b/Sources/OversizeUI/Controls/TextField/LabeledTextFieldStyle.swift @@ -263,33 +263,3 @@ public extension TextFieldStyle where Self == LabeledTextFieldStyle { LabeledTextFieldStyle(placeholder: placeholder, text: text) } } - -@available(iOS 15.0, macOS 14, tvOS 15.0, watchOS 9.0, *) -struct LabeledTextFieldStyle_Previews: PreviewProvider { - static var previews: some View { - VStack(spacing: 32) { - TextField("Text", text: .constant("Placeholder")) - .textFieldStyle(.default) - - TextField("Text", text: .constant("Placeholder")) - .textFieldStyle(OverPlaceholderTextFieldStyle(placeholder: "Label")) - - TextField("Text", text: .constant("Placeholder")) - .textFieldStyle(InsidePlaceholderTextFieldStyle(placeholder: "Label")) - - TextField("Text", text: .constant("Placeholder")) - .textFieldStyle(DefaultPlaceholderTextFieldStyle()) - .fieldHelper(.constant("Help"), style: .constant(.helperText)) - - TextField("Text", text: .constant("Placeholder")) - .textFieldStyle(OverPlaceholderTextFieldStyle(placeholder: "Label")) - .fieldHelper(.constant("Ok"), style: .constant(.sussesText)) - - TextField("Text", text: .constant("Placeholder")) - .textFieldStyle(InsidePlaceholderTextFieldStyle(placeholder: "Label")) - .fieldHelper(.constant("Error"), style: .constant(.errorText)) - - }.padding() - .previewLayout(.sizeThatFits) - } -} diff --git a/Sources/OversizeUI/Core/Appearance/Appearance.swift b/Sources/OversizeUI/Core/Appearance/Appearance.swift index 7eff3b9..10eaed3 100644 --- a/Sources/OversizeUI/Core/Appearance/Appearance.swift +++ b/Sources/OversizeUI/Core/Appearance/Appearance.swift @@ -5,7 +5,7 @@ import SwiftUI -public enum Appearance: Int { +public enum Appearance: Int, Sendable { case system case light case dark @@ -43,5 +43,5 @@ public enum Appearance: Int { } } - public static var allCases: [Appearance] = [.system, .light, .dark] + public static let allCases: [Appearance] = [.system, .light, .dark] } diff --git a/Sources/OversizeUI/Core/Appearance/Theme.swift b/Sources/OversizeUI/Core/Appearance/Theme.swift index 7f58413..96cc35a 100644 --- a/Sources/OversizeUI/Core/Appearance/Theme.swift +++ b/Sources/OversizeUI/Core/Appearance/Theme.swift @@ -6,7 +6,7 @@ import SwiftUI // swiftlint:disable identifier_name -public struct Theme: Identifiable { +public struct Theme: Identifiable, Sendable { public let id: Int public let name: String public let accentColor: Color diff --git a/Sources/OversizeUI/Core/Appearance/ThemeSettings.swift b/Sources/OversizeUI/Core/Appearance/ThemeSettings.swift index f7031be..d710d9d 100644 --- a/Sources/OversizeUI/Core/Appearance/ThemeSettings.swift +++ b/Sources/OversizeUI/Core/Appearance/ThemeSettings.swift @@ -5,24 +5,24 @@ import SwiftUI -public enum ThemeSettingsNames { - public static var appearance = "Settings.Appearance" - public static var accentColor = "Settings.AccentColor" - public static var fontTitle = "Settings.FontTitle" - public static var fontParagraph = "Settings.FontParagraph" - public static var fontButton = "Settings.FontButton" - public static var fontOverline = "Settings.FontOverline" - public static var borderApp = "Settings.BorderApp" - public static var borderButtons = "Settings.BorderButtons" - public static var borderSurface = "Settings.BorderSurface" - public static var borderTextFields = "Settings.BorderTextFields" - public static var borderControls = "Settings.BorderControls" - public static var borderSize = "Settings.BorderSize" - public static var theme = "Settings.Theme" - public static var radius = "Settings.Radius" +public enum ThemeSettingsNames: Sendable { + public static let appearance = "Settings.Appearance" + public static let accentColor = "Settings.AccentColor" + public static let fontTitle = "Settings.FontTitle" + public static let fontParagraph = "Settings.FontParagraph" + public static let fontButton = "Settings.FontButton" + public static let fontOverline = "Settings.FontOverline" + public static let borderApp = "Settings.BorderApp" + public static let borderButtons = "Settings.BorderButtons" + public static let borderSurface = "Settings.BorderSurface" + public static let borderTextFields = "Settings.BorderTextFields" + public static let borderControls = "Settings.BorderControls" + public static let borderSize = "Settings.BorderSize" + public static let theme = "Settings.Theme" + public static let radius = "Settings.Radius" } -public class ThemeSettings: ObservableObject { +public class ThemeSettings: ObservableObject, @unchecked Sendable { public init() {} @AppStorage(ThemeSettingsNames.appearance) public var appearance: Appearance = .system diff --git a/Sources/OversizeUI/Core/Colors.swift b/Sources/OversizeUI/Core/Colors.swift index 3a275b5..6dd7271 100644 --- a/Sources/OversizeUI/Core/Colors.swift +++ b/Sources/OversizeUI/Core/Colors.swift @@ -126,87 +126,87 @@ public extension Color { // MARK: - Foreground Color Extension public extension View { - func onPrimaryHighEmphasisForegroundColor() -> some View { + nonisolated func onPrimaryHighEmphasisForegroundColor() -> some View { foregroundColor(Color.onPrimaryHighEmphasis) } - func onPrimaryMediumEmphasisForegroundColor() -> some View { + nonisolated func onPrimaryMediumEmphasisForegroundColor() -> some View { foregroundColor(Color.onPrimaryMediumEmphasis) } - func onPrimaryDisabledForegroundColor() -> some View { + nonisolated func onPrimaryDisabledForegroundColor() -> some View { foregroundColor(Color.onPrimaryDisabled) } - func backgroundPrimaryForegroundColor() -> some View { + nonisolated func backgroundPrimaryForegroundColor() -> some View { foregroundColor(Color.backgroundPrimary) } - func backgroundSecondaryForegroundColor() -> some View { + nonisolated func backgroundSecondaryForegroundColor() -> some View { foregroundColor(Color.backgroundSecondary) } - func backgroundTertiaryForegroundColor() -> some View { + nonisolated func backgroundTertiaryForegroundColor() -> some View { foregroundColor(Color.backgroundTertiary) } - func onBackgroundHighEmphasisForegroundColor() -> some View { + nonisolated func onBackgroundHighEmphasisForegroundColor() -> some View { foregroundColor(Color.onBackgroundHighEmphasis) } - func onBackgroundMediumEmphasisForegroundColor() -> some View { + nonisolated func onBackgroundMediumEmphasisForegroundColor() -> some View { foregroundColor(Color.onBackgroundMediumEmphasis) } - func onBackgroundDisabledForegroundColor() -> some View { + nonisolated func onBackgroundDisabledForegroundColor() -> some View { foregroundColor(Color.onBackgroundDisabled) } - func surfacePrimaryForegroundColor() -> some View { + nonisolated func surfacePrimaryForegroundColor() -> some View { foregroundColor(Color.surfacePrimary) } - func surfaceSecondaryForegroundColor() -> some View { + nonisolated func surfaceSecondaryForegroundColor() -> some View { foregroundColor(Color.surfaceSecondary) } - func surfaceTertiaryForegroundColor() -> some View { + nonisolated func surfaceTertiaryForegroundColor() -> some View { foregroundColor(Color.surfaceTertiary) } - func onSurfaceHighEmphasisForegroundColor() -> some View { + nonisolated func onSurfaceHighEmphasisForegroundColor() -> some View { foregroundColor(Color.onSurfaceHighEmphasis) } - func onSurfaceMediumEmphasisForegroundColor() -> some View { + nonisolated func onSurfaceMediumEmphasisForegroundColor() -> some View { foregroundColor(Color.onSurfaceMediumEmphasis) } - func onSurfaceDisabledForegroundColor() -> some View { + nonisolated func onSurfaceDisabledForegroundColor() -> some View { foregroundColor(Color.onSurfaceDisabled) } - func accentForegroundColor() -> some View { + nonisolated func accentForegroundColor() -> some View { foregroundColor(Color.accentColor) } - func errorForegroundColor() -> some View { + nonisolated func errorForegroundColor() -> some View { foregroundColor(Color.error) } - func successForegroundColor() -> some View { + nonisolated func successForegroundColor() -> some View { foregroundColor(Color.success) } - func warningForegroundColor() -> some View { + nonisolated func warningForegroundColor() -> some View { foregroundColor(Color.warning) } - func linkForegroundColor() -> some View { + nonisolated func linkForegroundColor() -> some View { foregroundColor(Color.link) } - func borderForegroundColor() -> some View { + nonisolated func borderForegroundColor() -> some View { foregroundColor(Color.border) } } @@ -214,194 +214,194 @@ public extension View { // MARK: - Fill Color Extension public extension Shape { - func fillOnPrimaryHighEmphasis() -> some View { + nonisolated func fillOnPrimaryHighEmphasis() -> some View { fill(Color.onPrimaryHighEmphasis) } - func fillOnPrimaryMediumEmphasis() -> some View { + nonisolated func fillOnPrimaryMediumEmphasis() -> some View { fill(Color.onPrimaryMediumEmphasis) } - func fillOnPrimaryDisabled() -> some View { + nonisolated func fillOnPrimaryDisabled() -> some View { fill(Color.onPrimaryDisabled) } - func fillAccent() -> some View { + nonisolated func fillAccent() -> some View { fill(Color.accentColor) } - func fillBackgroundPrimary() -> some View { + nonisolated func fillBackgroundPrimary() -> some View { fill(Color.backgroundPrimary) } - func fillBackgroundSecondary() -> some View { + nonisolated func fillBackgroundSecondary() -> some View { fill(Color.backgroundSecondary) } - func fillBackgroundTertiary() -> some View { + nonisolated func fillBackgroundTertiary() -> some View { fill(Color.backgroundTertiary) } - func fillOnBackgroundHighEmphasis() -> some View { + nonisolated func fillOnBackgroundHighEmphasis() -> some View { fill(Color.onBackgroundHighEmphasis) } - func fillOnBackgroundMediumEmphasis() -> some View { + nonisolated func fillOnBackgroundMediumEmphasis() -> some View { fill(Color.onBackgroundMediumEmphasis) } - func fillOnBackgroundDisabled() -> some View { + nonisolated func fillOnBackgroundDisabled() -> some View { fill(Color.onBackgroundDisabled) } - func fillSurfacePrimary() -> some View { + nonisolated func fillSurfacePrimary() -> some View { fill(Color.surfacePrimary) } - func fillSurfaceSecondary() -> some View { + nonisolated func fillSurfaceSecondary() -> some View { fill(Color.surfaceSecondary) } - func fillSurfaceTertiary() -> some View { + nonisolated func fillSurfaceTertiary() -> some View { fill(Color.surfaceTertiary) } - func fillOnSurfaceHighEmphasis() -> some View { + nonisolated func fillOnSurfaceHighEmphasis() -> some View { fill(Color.onSurfaceHighEmphasis) } - func fillOnSurfaceMediumEmphasis() -> some View { + nonisolated func fillOnSurfaceMediumEmphasis() -> some View { fill(Color.onSurfaceMediumEmphasis) } - func fillOnSurfaceDisabled() -> some View { + nonisolated func fillOnSurfaceDisabled() -> some View { fill(Color.onSurfaceDisabled) } - func fillError() -> some View { + nonisolated func fillError() -> some View { fill(Color.error) } - func fillSuccess() -> some View { + nonisolated func fillSuccess() -> some View { fill(Color.success) } - func fillWarning() -> some View { + nonisolated func fillWarning() -> some View { fill(Color.warning) } - func fillLink() -> some View { + nonisolated func fillLink() -> some View { fill(Color.link) } - func fillBorder() -> some View { + nonisolated func fillBorder() -> some View { fill(Color.border) } } public extension View { @available(*, deprecated, renamed: "onPrimaryHighEmphasisForegroundColor") - func foregroundOnPrimaryHighEmphasis() -> some View { + nonisolated func foregroundOnPrimaryHighEmphasis() -> some View { foregroundColor(Color.onPrimaryHighEmphasis) } @available(*, deprecated, renamed: "onPrimaryMediumEmphasisForegroundColor") - func foregroundOnPrimaryMediumEmphasis() -> some View { + nonisolated func foregroundOnPrimaryMediumEmphasis() -> some View { foregroundColor(Color.onPrimaryMediumEmphasis) } @available(*, deprecated, renamed: "onPrimaryDisabledForegroundColor") - func foregroundOnPrimaryDisabled() -> some View { + nonisolated func foregroundOnPrimaryDisabled() -> some View { foregroundColor(Color.onPrimaryDisabled) } @available(*, deprecated, renamed: "accentForegroundColor") - func foregroundAccent() -> some View { + nonisolated func foregroundAccent() -> some View { foregroundColor(Color.accentColor) } @available(*, deprecated, renamed: "backgroundPrimaryForegroundColor") - func foregroundBackgroundPrimary() -> some View { + nonisolated func foregroundBackgroundPrimary() -> some View { foregroundColor(Color.backgroundPrimary) } @available(*, deprecated, renamed: "backgroundSecondaryForegroundColor") - func foregroundBackgroundSecondary() -> some View { + nonisolated func foregroundBackgroundSecondary() -> some View { foregroundColor(Color.backgroundSecondary) } @available(*, deprecated, renamed: "backgroundTertiaryForegroundColor") - func foregroundBackgroundTertiary() -> some View { + nonisolated func foregroundBackgroundTertiary() -> some View { foregroundColor(Color.backgroundTertiary) } @available(*, deprecated, renamed: "onBackgroundHighEmphasisForegroundColor") - func foregroundOnBackgroundHighEmphasis() -> some View { + nonisolated func foregroundOnBackgroundHighEmphasis() -> some View { foregroundColor(Color.onBackgroundHighEmphasis) } @available(*, deprecated, renamed: "onBackgroundMediumEmphasisForegroundColor") - func foregroundOnBackgroundMediumEmphasis() -> some View { + nonisolated func foregroundOnBackgroundMediumEmphasis() -> some View { foregroundColor(Color.onBackgroundMediumEmphasis) } @available(*, deprecated, renamed: "onBackgroundDisabledForegroundColor") - func foregroundOnBackgroundDisabled() -> some View { + nonisolated func foregroundOnBackgroundDisabled() -> some View { foregroundColor(Color.onBackgroundDisabled) } @available(*, deprecated, renamed: "surfacePrimaryForegroundColor") - func foregroundSurfacePrimary() -> some View { + nonisolated func foregroundSurfacePrimary() -> some View { foregroundColor(Color.surfacePrimary) } @available(*, deprecated, renamed: "surfaceSecondaryForegroundColor") - func foregroundSurfaceSecondary() -> some View { + nonisolated func foregroundSurfaceSecondary() -> some View { foregroundColor(Color.surfaceSecondary) } @available(*, deprecated, renamed: "aurfaceTertiaryForegroundColor") - func foregroundSurfaceTertiary() -> some View { + nonisolated func foregroundSurfaceTertiary() -> some View { foregroundColor(Color.surfaceTertiary) } @available(*, deprecated, renamed: "onSurfaceHighEmphasisForegroundColor") - func foregroundOnSurfaceHighEmphasis() -> some View { + nonisolated func foregroundOnSurfaceHighEmphasis() -> some View { foregroundColor(Color.onSurfaceHighEmphasis) } @available(*, deprecated, renamed: "onSurfaceMediumEmphasisForegroundColor") - func foregroundOnSurfaceMediumEmphasis() -> some View { + nonisolated func foregroundOnSurfaceMediumEmphasis() -> some View { foregroundColor(Color.onSurfaceMediumEmphasis) } @available(*, deprecated, renamed: "onSurfaceDisabledForegroundColor") - func foregroundOnSurfaceDisabled() -> some View { + nonisolated func foregroundOnSurfaceDisabled() -> some View { foregroundColor(Color.onSurfaceDisabled) } @available(*, deprecated, renamed: "errorForegroundColor") - func foregroundError() -> some View { + nonisolated func foregroundError() -> some View { foregroundColor(Color.error) } @available(*, deprecated, renamed: "successForegroundColor") - func foregroundSuccess() -> some View { + nonisolated func foregroundSuccess() -> some View { foregroundColor(Color.success) } @available(*, deprecated, renamed: "warningForegroundColor") - func foregroundWarning() -> some View { + nonisolated func foregroundWarning() -> some View { foregroundColor(Color.warning) } @available(*, deprecated, renamed: "linkForegroundColor") - func foregroundLink() -> some View { + nonisolated func foregroundLink() -> some View { foregroundColor(Color.link) } @available(*, deprecated, renamed: "borderForegroundColor") - func foregroundBorder() -> some View { + nonisolated func foregroundBorder() -> some View { foregroundColor(Color.border) } } diff --git a/Sources/OversizeUI/Core/EdgeSpaceInsets.swift b/Sources/OversizeUI/Core/EdgeSpaceInsets.swift index f3fcf0b..9426e18 100644 --- a/Sources/OversizeUI/Core/EdgeSpaceInsets.swift +++ b/Sources/OversizeUI/Core/EdgeSpaceInsets.swift @@ -5,7 +5,7 @@ import Foundation -public struct EdgeSpaceInsets { +public struct EdgeSpaceInsets: Sendable { public let top: Space public let leading: Space public let bottom: Space diff --git a/Sources/OversizeUI/Core/Elevation.swift b/Sources/OversizeUI/Core/Elevation.swift index 108eeb4..57db644 100644 --- a/Sources/OversizeUI/Core/Elevation.swift +++ b/Sources/OversizeUI/Core/Elevation.swift @@ -6,7 +6,7 @@ import SwiftUI // swiftlint:disable identifier_name -public enum Elevation: Int, CaseIterable { +public enum Elevation: Int, CaseIterable, Sendable { case z0 case z1 case z2 diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/AccentEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/AccentEnvironment.swift index 2b3c744..dce7fa4 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/AccentEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/AccentEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct AccentStateKey: EnvironmentKey { - public static var defaultValue: Bool = false + public static let defaultValue: Bool = false } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/BorderedEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/BorderedEnvironment.swift index 5fb0c13..74b6747 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/BorderedEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/BorderedEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct BorderedStateKey: EnvironmentKey { - public static var defaultValue: Bool = false + public static let defaultValue: Bool = false } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/ControlBorderShapeEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/ControlBorderShapeEnvironment.swift index e57e1f7..f8c25b6 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/ControlBorderShapeEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/ControlBorderShapeEnvironment.swift @@ -5,13 +5,13 @@ import SwiftUI -public enum ControlBorderShape { +public enum ControlBorderShape: Sendable { case capsule case roundedRectangle(radius: Radius = .medium) } private struct ControlBorderShapeKey: EnvironmentKey { - public static var defaultValue: ControlBorderShape = .roundedRectangle(radius: .medium) + public static let defaultValue: ControlBorderShape = .roundedRectangle(radius: .medium) } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/ControlPaddingEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/ControlPaddingEnvironment.swift index e40107d..5310897 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/ControlPaddingEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/ControlPaddingEnvironment.swift @@ -5,7 +5,7 @@ import SwiftUI -public struct ControlMargin { +public struct ControlMargin: Sendable { public var top: Space = .medium public var leading: Space = .medium public var bottom: Space = .medium @@ -88,7 +88,7 @@ public struct ControlMargin { } private struct ControlMarginKey: EnvironmentKey { - public static var defaultValue: ControlMargin = .init(.medium) + public static let defaultValue: ControlMargin = .init(.medium) } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/ElevationEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/ElevationEnvironment.swift index fd65f22..02c2c1d 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/ElevationEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/ElevationEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct ElevationStateKey: EnvironmentKey { - public static var defaultValue: Elevation = .z0 + public static let defaultValue: Elevation = .z0 } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/FieldLabelPositionEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/FieldLabelPositionEnvironment.swift index f937246..e7a198b 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/FieldLabelPositionEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/FieldLabelPositionEnvironment.swift @@ -5,12 +5,12 @@ import SwiftUI -public enum FieldLabelPosition { +public enum FieldLabelPosition: Sendable { case `default`, adjacent, overInput } private struct FieldLabelPositionKey: EnvironmentKey { - public static var defaultValue: FieldLabelPosition = .default + public static let defaultValue: FieldLabelPosition = .default } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/FieldPositionEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/FieldPositionEnvironment.swift index 9011d73..6f38a90 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/FieldPositionEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/FieldPositionEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct FieldPositionKey: EnvironmentKey { - public static var defaultValue: VerticalAlignment? = nil + public static let defaultValue: VerticalAlignment? = nil } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/IconStyleEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/IconStyleEnvironment.swift index 36445e9..3b867fc 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/IconStyleEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/IconStyleEnvironment.swift @@ -5,12 +5,12 @@ import SwiftUI -public enum IconStyle { +public enum IconStyle: Sendable { case line, fill, twoTone } private struct IconStyleKey: EnvironmentKey { - public static var defaultValue: IconStyle = .line + public static let defaultValue: IconStyle = .line } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/LoadingEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/LoadingEnvironment.swift index 9d6663b..192685d 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/LoadingEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/LoadingEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct LoadingStateKey: EnvironmentKey { - public static var defaultValue: Bool = false + public static let defaultValue: Bool = false } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/MultiSelectStyleEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/MultiSelectStyleEnvironment.swift index 72e17fa..af58cbc 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/MultiSelectStyleEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/MultiSelectStyleEnvironment.swift @@ -5,12 +5,12 @@ import SwiftUI -public enum MultiSelectStyle { +public enum MultiSelectStyle: Sendable { case `default`, section } private struct MultiSelectStyleKey: EnvironmentKey { - public static var defaultValue: MultiSelectStyle = .default + public static let defaultValue: MultiSelectStyle = .default } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/Platform.swift b/Sources/OversizeUI/Core/EnvironmentKeys/Platform.swift index 2122915..51c7852 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/Platform.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/Platform.swift @@ -8,7 +8,7 @@ import SwiftUI import UIKit #endif -public enum Platform { +public enum Platform: Sendable { case iPhone, iPadOS, macOS, tvOS, watchOS, visionOS, carPlay, other } @@ -21,23 +21,25 @@ private struct PlatformKey: EnvironmentKey { #elseif os(visionOS) return .vision #elseif canImport(UIKit) - switch UIDevice.current.userInterfaceIdiom { - case .phone: - return .iPhone - case .pad: - return .iPadOS - case .tv: - return .tvOS - case .carPlay: - return .carPlay - case .mac: - return .macOS - case .vision: - return .visionOS - case .unspecified: - return .other - @unknown default: - return .other + MainActor.assumeIsolated { + switch UIDevice.current.userInterfaceIdiom { + case .phone: + return .iPhone + case .pad: + return .iPadOS + case .tv: + return .tvOS + case .carPlay: + return .carPlay + case .mac: + return .macOS + case .vision: + return .visionOS + case .unspecified: + return .other + @unknown default: + return .other + } } #else return .other @@ -45,6 +47,22 @@ private struct PlatformKey: EnvironmentKey { }() } +// private struct PlatformKey: EnvironmentKey { +// +// #if os(macOS) || targetEnvironment(macCatalyst) +// static let defaultValue: Platform = .macOS +// #elseif os(watchOS) +// static let defaultValue: Platform = .watchOS +// #elseif os(visionOS) +// static let defaultValue: Platform = .vision +// #elseif os(iOS) +// static let defaultValue: Platform = .iPhone +// #else +// static let defaultValue: Platform = .other +// #endif +// +// } + public extension EnvironmentValues { var platform: Platform { get { self[PlatformKey.self] } diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/PortraitEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/PortraitEnvironment.swift index 5ae6981..caf3f8d 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/PortraitEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/PortraitEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct PortraitStateKey: EnvironmentKey { - public static var defaultValue: Bool = false + public static let defaultValue: Bool = false } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/PremiumEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/PremiumEnvironment.swift index 5e8e041..d89f80a 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/PremiumEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/PremiumEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct PremiumStateKey: EnvironmentKey { - public static var defaultValue: Bool = false + public static let defaultValue: Bool = false } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/RadiusEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/RadiusEnvironment.swift index ba6ba34..37f1541 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/RadiusEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/RadiusEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct ControlRadiusKey: EnvironmentKey { - public static var defaultValue: Radius = .medium + public static let defaultValue: Radius = .medium } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/ScreenSizeEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/ScreenSizeEnvironment.swift index 64430d1..cc86468 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/ScreenSizeEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/ScreenSizeEnvironment.swift @@ -5,7 +5,7 @@ import SwiftUI -public struct ScreenSize { +public struct ScreenSize: Sendable { public let safeAreaWidth: CGFloat public let safeAreaHeight: CGFloat public let safeAreaTop: CGFloat diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/SectionViewStyleEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/SectionViewStyleEnvironment.swift index b17dfd1..fd3bb93 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/SectionViewStyleEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/SectionViewStyleEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct SectionViewStyleKey: EnvironmentKey { - public static var defaultValue: SectionViewStyle = .default + public static let defaultValue: SectionViewStyle = .default } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/SelectPickerStyleEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/SelectPickerStyleEnvironment.swift index 464cebc..422b5f1 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/SelectPickerStyleEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/SelectPickerStyleEnvironment.swift @@ -5,7 +5,7 @@ import SwiftUI -public enum SelectStyle { +public enum SelectStyle: Sendable { case `default` case section @available(macOS, unavailable) @@ -13,7 +13,7 @@ public enum SelectStyle { } private struct SelectStyleKey: EnvironmentKey { - public static var defaultValue: SelectStyle = .default + public static let defaultValue: SelectStyle = .default } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/SurfaceElevationEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/SurfaceElevationEnvironment.swift index 1dae333..24b0810 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/SurfaceElevationEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/SurfaceElevationEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct SurfaceElevationStateKey: EnvironmentKey { - public static var defaultValue: Elevation = .z0 + public static let defaultValue: Elevation = .z0 } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/SurfaceRadiusEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/SurfaceRadiusEnvironment.swift index a34a9af..75c6634 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/SurfaceRadiusEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/SurfaceRadiusEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct SurfaceRadiusKey: EnvironmentKey { - public static var defaultValue: Radius = .medium + public static let defaultValue: Radius = .medium } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/EnvironmentKeys/ThemeEnvironment.swift b/Sources/OversizeUI/Core/EnvironmentKeys/ThemeEnvironment.swift index 6c11667..f242edf 100644 --- a/Sources/OversizeUI/Core/EnvironmentKeys/ThemeEnvironment.swift +++ b/Sources/OversizeUI/Core/EnvironmentKeys/ThemeEnvironment.swift @@ -6,7 +6,7 @@ import SwiftUI private struct ThemeStateKey: EnvironmentKey { - public static var defaultValue = ThemeSettings() + public static let defaultValue = ThemeSettings() } public extension EnvironmentValues { diff --git a/Sources/OversizeUI/Core/Palette.swift b/Sources/OversizeUI/Core/Palette.swift index 93a5cb9..3f65e28 100644 --- a/Sources/OversizeUI/Core/Palette.swift +++ b/Sources/OversizeUI/Core/Palette.swift @@ -5,7 +5,7 @@ import SwiftUI -public enum Palette: String { +public enum Palette: String, Sendable { case red case orange case yellow @@ -39,8 +39,8 @@ public enum Palette: String { } } - public static var base: [Palette] = [.red, .orange, .yellow, .green, .blue, .pink, .gray, .black] - public static var baseColors: [Color] = base.compactMap { color in + public static let base: [Palette] = [.red, .orange, .yellow, .green, .blue, .pink, .gray, .black] + public static let baseColors: [Color] = base.compactMap { color in color.color } } diff --git a/Sources/OversizeUI/Core/PreferenceKeys/ScrollOffsetPreferenceKey.swift b/Sources/OversizeUI/Core/PreferenceKeys/ScrollOffsetPreferenceKey.swift index 612c37c..c2d296a 100644 --- a/Sources/OversizeUI/Core/PreferenceKeys/ScrollOffsetPreferenceKey.swift +++ b/Sources/OversizeUI/Core/PreferenceKeys/ScrollOffsetPreferenceKey.swift @@ -6,6 +6,6 @@ import SwiftUI public struct ScrollOffsetPreferenceKey: PreferenceKey { - public static var defaultValue: CGPoint = .zero + public static let defaultValue: CGPoint = .zero public static func reduce(value _: inout CGPoint, nextValue _: () -> CGPoint) {} } diff --git a/Sources/OversizeUI/Core/PreferenceKeys/SizePreferenceKey.swift b/Sources/OversizeUI/Core/PreferenceKeys/SizePreferenceKey.swift index b74d21d..05517b9 100644 --- a/Sources/OversizeUI/Core/PreferenceKeys/SizePreferenceKey.swift +++ b/Sources/OversizeUI/Core/PreferenceKeys/SizePreferenceKey.swift @@ -6,6 +6,6 @@ import SwiftUI public struct SizePreferenceKey: PreferenceKey { - public static var defaultValue: CGSize = .zero + public static let defaultValue: CGSize = .zero public static func reduce(value _: inout CGSize, nextValue _: () -> CGSize) {} } diff --git a/Sources/OversizeUI/Core/Radius.swift b/Sources/OversizeUI/Core/Radius.swift index 51d37e3..df7ea16 100644 --- a/Sources/OversizeUI/Core/Radius.swift +++ b/Sources/OversizeUI/Core/Radius.swift @@ -5,7 +5,7 @@ import SwiftUI -public enum Radius { +public enum Radius: Sendable { private var theme: ThemeSettings { ThemeSettings() } diff --git a/Sources/OversizeUI/Core/Space.swift b/Sources/OversizeUI/Core/Space.swift index 4704e29..550f79a 100644 --- a/Sources/OversizeUI/Core/Space.swift +++ b/Sources/OversizeUI/Core/Space.swift @@ -5,7 +5,7 @@ import SwiftUI -public enum Space: CGFloat { +public enum Space: CGFloat, Sendable { /// 0 case zero = 0 diff --git a/Sources/OversizeUI/Core/Typography.swift b/Sources/OversizeUI/Core/Typography.swift index b779820..2d3dc1f 100644 --- a/Sources/OversizeUI/Core/Typography.swift +++ b/Sources/OversizeUI/Core/Typography.swift @@ -1,11 +1,6 @@ -// -// Copyright © 2021 Alexander Romanov -// Typography.swift, created on 07.06.2020 -// - import SwiftUI -public enum FontDesignType: String, CaseIterable { +public enum FontDesignType: String, CaseIterable, Sendable { case `default`, serif, round, mono public var system: Font.Design { @@ -24,13 +19,12 @@ public enum FontDesignType: String, CaseIterable { public struct Typography: ViewModifier { @Environment(\.theme) private var theme: ThemeSettings - @Environment(\.isLoading) var isLoading private let fontStyle: Font.TextStyle private let isBold: Bool? private let weight: Font.Weight? - public init(fontStyle: Font.TextStyle, isBold: Bool? = nil, weight: Font.Weight? = nil) { + public nonisolated init(fontStyle: Font.TextStyle, isBold: Bool? = nil, weight: Font.Weight? = nil) { self.fontStyle = fontStyle self.isBold = isBold self.weight = weight @@ -49,62 +43,13 @@ public struct Typography: ViewModifier { private var lineHeight: CGFloat { switch fontStyle { - case .largeTitle: - #if os(macOS) - return 40 - #else - return 44 - #endif - case .title: - #if os(macOS) - return 32 - #else - return 36 - #endif - case .title2: - #if os(macOS) - return 24 - #else - return 28 - #endif - case .title3: - #if os(macOS) - return 20 - #else - return 24 - #endif - case .headline: - #if os(macOS) - return 20 - #else - return 24 - #endif - case .subheadline: - #if os(macOS) - return 16 - #else - return 20 - #endif - case .body: - #if os(macOS) - return 20 - #else - return 24 - #endif - case .callout: - #if os(macOS) - return 16 - #else - return 20 - #endif - case .footnote: - return 16 - case .caption: - return 16 - case .caption2: - return 16 - @unknown default: - return 16 + case .largeTitle: return 44 + case .title: return 36 + case .title2: return 28 + case .title3, .headline: return 24 + case .subheadline, .body: return 20 + case .callout, .footnote, .caption, .caption2: return 16 + @unknown default: return 16 } } @@ -123,119 +68,116 @@ public struct Typography: ViewModifier { private var fontWeight: Font.Weight { if let weight { - weight - } else { - switch fontStyle { - case .largeTitle, .title: - isBold ?? true ? .bold : .regular - case .headline: - isBold ?? true ? .bold : .semibold - default: - isBold ?? false ? .bold : .regular - } + return weight + } + switch fontStyle { + case .largeTitle, .title: + return (isBold ?? true) ? .bold : .regular + case .headline: + return (isBold ?? true) ? .bold : .semibold + default: + return (isBold ?? false) ? .bold : .regular } } } public extension View { - func largeTitle(_ bold: Bool = true) -> some View { + // Large Title + nonisolated func largeTitle(_ bold: Bool = true) -> some View { modifier(Typography(fontStyle: .largeTitle, isBold: bold)) } - func title(_ bold: Bool = true) -> some View { - modifier(Typography(fontStyle: .title, isBold: bold)) - } - - func title2(_ bold: Bool = true) -> some View { - modifier(Typography(fontStyle: .title2, isBold: bold)) - } - - func title3(_ bold: Bool = true) -> some View { - modifier(Typography(fontStyle: .title3, isBold: bold)) + nonisolated func largeTitle(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .largeTitle, weight: weight)) } - func headline(_ bold: Bool = true) -> some View { - modifier(Typography(fontStyle: .headline, isBold: bold)) + // Title + nonisolated func title(_ bold: Bool = true) -> some View { + modifier(Typography(fontStyle: .title, isBold: bold)) } - func subheadline(_ bold: Bool = false) -> some View { - modifier(Typography(fontStyle: .subheadline, isBold: bold)) + nonisolated func title(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .title, weight: weight)) } - func body(_ bold: Bool = false) -> some View { - modifier(Typography(fontStyle: .body, isBold: bold)) + // Title 2 + nonisolated func title2(_ bold: Bool = true) -> some View { + modifier(Typography(fontStyle: .title2, isBold: bold)) } - func callout(_ bold: Bool = false) -> some View { - modifier(Typography(fontStyle: .callout, isBold: bold)) + nonisolated func title2(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .title2, weight: weight)) } - func footnote(_ bold: Bool = false) -> some View { - modifier(Typography(fontStyle: .footnote, isBold: bold)) + // Title 3 + nonisolated func title3(_ bold: Bool = true) -> some View { + modifier(Typography(fontStyle: .title3, isBold: bold)) } - func caption(_ bold: Bool = false) -> some View { - modifier(Typography(fontStyle: .caption, isBold: bold)) + nonisolated func title3(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .title3, weight: weight)) } - func caption2(_ bold: Bool = false) -> some View { - modifier(Typography(fontStyle: .caption2, isBold: bold)) + // Headline + nonisolated func headline(_ bold: Bool = true) -> some View { + modifier(Typography(fontStyle: .headline, isBold: bold)) } - func largeTitle(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .largeTitle, weight: weight)) + nonisolated func headline(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .headline, weight: weight)) } - func title(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .title, weight: weight)) + // Subheadline + nonisolated func subheadline(_ bold: Bool = false) -> some View { + modifier(Typography(fontStyle: .subheadline, isBold: bold)) } - func title2(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .title2, weight: weight)) + nonisolated func subheadline(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .subheadline, weight: weight)) } - func title3(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .title3, weight: weight)) + // Body + nonisolated func body(_ bold: Bool = false) -> some View { + modifier(Typography(fontStyle: .body, isBold: bold)) } - func headline(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .headline, weight: weight)) + nonisolated func body(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .body, weight: weight)) } - func subheadline(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .subheadline, weight: weight)) + // Callout + nonisolated func callout(_ bold: Bool = false) -> some View { + modifier(Typography(fontStyle: .callout, isBold: bold)) } - func body(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .body, weight: weight)) + nonisolated func callout(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .callout, weight: weight)) } - func callout(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .callout, weight: weight)) + // Footnote + nonisolated func footnote(_ bold: Bool = false) -> some View { + modifier(Typography(fontStyle: .footnote, isBold: bold)) } - func footnote(_ weight: Font.Weight) -> some View { + nonisolated func footnote(_ weight: Font.Weight) -> some View { modifier(Typography(fontStyle: .footnote, weight: weight)) } - func caption(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .caption, weight: weight)) + // Caption + nonisolated func caption(_ bold: Bool = false) -> some View { + modifier(Typography(fontStyle: .caption, isBold: bold)) } - func caption2(_ weight: Font.Weight) -> some View { - modifier(Typography(fontStyle: .caption2, weight: weight)) + nonisolated func caption(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .caption, weight: weight)) } -} -public extension View { - @available(*, deprecated, message: "Use native modificator", renamed: "font") - func fontStyle(_ style: Font.TextStyle) -> some View { - modifier(Typography(fontStyle: style)) + // Caption 2 + nonisolated func caption2(_ bold: Bool = false) -> some View { + modifier(Typography(fontStyle: .caption2, isBold: bold)) } - @available(*, deprecated, message: "Use native color modificator", renamed: "font") - func fontStyle(_ style: Font.TextStyle, color: Color) -> some View { - modifier(Typography(fontStyle: style)) - .foregroundColor(color) + nonisolated func caption2(_ weight: Font.Weight) -> some View { + modifier(Typography(fontStyle: .caption2, weight: weight)) } } diff --git a/Sources/OversizeUI/Core/Validation.swift b/Sources/OversizeUI/Core/Validation.swift index 93ca1ad..617d812 100644 --- a/Sources/OversizeUI/Core/Validation.swift +++ b/Sources/OversizeUI/Core/Validation.swift @@ -5,7 +5,7 @@ import Foundation -public enum Validation { +public enum Validation: Sendable { case success case failure(message: String) diff --git a/Sources/OversizeUI/Core/ViewModifier/HalfSheet/HalfSheet.swift b/Sources/OversizeUI/Core/ViewModifier/HalfSheet/HalfSheet.swift index 991661a..4c44e26 100644 --- a/Sources/OversizeUI/Core/ViewModifier/HalfSheet/HalfSheet.swift +++ b/Sources/OversizeUI/Core/ViewModifier/HalfSheet/HalfSheet.swift @@ -8,13 +8,14 @@ import SwiftUI import UIKit #endif -public enum Detents: Hashable { +public enum Detents: Hashable, Sendable { case large case medium case height(CGFloat) #if os(iOS) @available(iOS 15, *) + @MainActor public var uiViewDetents: UISheetPresentationController.Detent { switch self { case .large: @@ -44,6 +45,7 @@ public enum Detents: Hashable { #if os(iOS) public struct SheetModifier: ViewModifier { public let detents: [Detents] + public func body(content: Content) -> some View { SheetView(detents: detents) { content diff --git a/Sources/OversizeUI/Deprecated/Icon.swift b/Sources/OversizeUI/Deprecated/Icon.swift index e51cfec..6e150fe 100644 --- a/Sources/OversizeUI/Deprecated/Icon.swift +++ b/Sources/OversizeUI/Deprecated/Icon.swift @@ -30,12 +30,12 @@ public enum IconSizes: CaseIterable { } public struct IconDeprecated: View { - private enum Constants { + private enum Constants: Sendable { /// Size - static var small: CGFloat = Space.small.rawValue - static var medium: CGFloat = Space.medium.rawValue - static var large: CGFloat = Space.large.rawValue - static var xLarge: CGFloat = Space.xLarge.rawValue + static let small: CGFloat = Space.small.rawValue + static let medium: CGFloat = Space.medium.rawValue + static let large: CGFloat = Space.large.rawValue + static let xLarge: CGFloat = Space.xLarge.rawValue } let name: IconsNames? diff --git a/Sources/OversizeUI/Deprecated/TextFieldDeprecated.swift b/Sources/OversizeUI/Deprecated/TextFieldDeprecated.swift deleted file mode 100644 index 464b5b6..0000000 --- a/Sources/OversizeUI/Deprecated/TextFieldDeprecated.swift +++ /dev/null @@ -1,173 +0,0 @@ -// -// -// Copyright © 2023 Aleksandr Romanov -// File.swift, created on 07.03.2023 -// - -import SwiftUI - -public struct DefaultPlaceholderTextFieldStyle: TextFieldStyle { - @Environment(\.theme) private var theme: ThemeSettings - - private let isFocused: Bool - - public init(focused: Bool = false) { - isFocused = focused - } - - public func _body(configuration: TextField<_Label>) -> some View { - VStack(alignment: .leading) { - configuration - .headline() - .foregroundColor(.onSurfaceHighEmphasis) - } - .padding() - .background( - RoundedRectangle( - cornerRadius: Radius.medium, - style: .continuous - ) - .fill(isFocused ? Color.surfacePrimary : Color.surfaceSecondary) - .overlay(overlay) - ) - } - - @ViewBuilder - var overlay: some View { - RoundedRectangle(cornerRadius: Radius.medium, - style: .continuous) - .stroke(overlayBorderColor, lineWidth: isFocused ? 2 : CGFloat(theme.borderSize)) - } - - var overlayBorderColor: Color { - if isFocused { - Color.accentColor - } else if theme.borderTextFields { - Color.border - } else { - Color.clear - } - } -} - -// swiftlint:disable identifier_name -public struct OverPlaceholderTextFieldStyle: TextFieldStyle { - @Environment(\.theme) private var theme: ThemeSettings - - public let placeholder: String - private let isFocused: Bool - - public init(placeholder: String, focused: Bool = false) { - self.placeholder = placeholder - isFocused = focused - } - - public func _body(configuration: TextField<_Label>) -> some View { - VStack(alignment: .leading) { - HStack { - Text(placeholder) - .subheadline(.semibold) - .foregroundColor(.onSurfaceHighEmphasis) - Spacer() - } - - VStack(alignment: .leading) { - configuration - .headline() - .foregroundColor(.onSurfaceHighEmphasis) - } - .padding() - .background( - RoundedRectangle(cornerRadius: Radius.medium, - style: .continuous) - .fill(isFocused ? Color.surfacePrimary : Color.surfaceSecondary) - .overlay(overlay) - ) - } - } - - @ViewBuilder - var overlay: some View { - RoundedRectangle(cornerRadius: Radius.medium, - style: .continuous) - .stroke(overlayBorderColor, lineWidth: isFocused ? 2 : CGFloat(theme.borderSize)) - } - - var overlayBorderColor: Color { - if isFocused { - Color.accentColor - } else if theme.borderTextFields { - Color.border - } else { - Color.clear - } - } -} - -// swiftlint:disable identifier_name -public struct InsidePlaceholderTextFieldStyle: TextFieldStyle { - @Environment(\.theme) private var theme: ThemeSettings - - public let placeholder: String - private let isFocused: Bool - - public init(placeholder: String, focused: Bool = false) { - self.placeholder = placeholder - isFocused = focused - } - - public func _body(configuration: TextField<_Label>) -> some View { - VStack(alignment: .leading, spacing: .zero) { - VStack(alignment: .leading) { - HStack { - Text(placeholder) - .subheadline(.semibold) - .foregroundColor(.onSurfaceMediumEmphasis) - Spacer() - } - - configuration - .headline() - .foregroundColor(.onSurfaceHighEmphasis) - } - .padding() - .background( - RoundedRectangle(cornerRadius: Radius.medium, - style: .continuous) - .fill(isFocused ? Color.surfacePrimary : Color.surfaceSecondary) - .overlay(overlay) - ) - } - } - - @ViewBuilder - var overlay: some View { - RoundedRectangle(cornerRadius: Radius.medium, - style: .continuous) - .stroke(overlayBorderColor, lineWidth: isFocused ? 2 : CGFloat(theme.borderSize)) - } - - var overlayBorderColor: Color { - if isFocused { - Color.accentColor - } else if theme.borderTextFields { - Color.border - } else { - Color.clear - } - } -} - -public extension TextFieldStyle where Self == DefaultPlaceholderTextFieldStyle { - @available(*, deprecated, message: "Use native @FocusState") - static func `default`(focused: Bool) -> DefaultPlaceholderTextFieldStyle { - DefaultPlaceholderTextFieldStyle(focused: focused) - } -} - -public extension TextFieldStyle where Self == InsidePlaceholderTextFieldStyle { - @available(*, deprecated, message: "Use .fieldLabelPosition(.overInput)") - static func placeholderInside(_ placeholder: String, focused: Bool = false) -> InsidePlaceholderTextFieldStyle { - InsidePlaceholderTextFieldStyle(placeholder: placeholder, focused: focused) - } -} diff --git a/Sources/OversizeUI/Deprecated/ViewOffsetKey.swift b/Sources/OversizeUI/Deprecated/ViewOffsetKey.swift index 276f75a..d46c314 100644 --- a/Sources/OversizeUI/Deprecated/ViewOffsetKey.swift +++ b/Sources/OversizeUI/Deprecated/ViewOffsetKey.swift @@ -6,7 +6,7 @@ import SwiftUI public struct ViewOffsetKey: PreferenceKey { - public static var defaultValue = CGFloat.zero + public static let defaultValue = CGFloat.zero public static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { value += nextValue() } diff --git a/Sources/OversizeUI/Extensions/Padding/Padding.swift b/Sources/OversizeUI/Extensions/Padding/Padding.swift index 752152d..8efd8ad 100644 --- a/Sources/OversizeUI/Extensions/Padding/Padding.swift +++ b/Sources/OversizeUI/Extensions/Padding/Padding.swift @@ -8,7 +8,7 @@ import SwiftUI public struct PaddingModifier: ViewModifier { private let edges: Edge.Set private let length: Space - public init(edges: Edge.Set, length: Space) { + public nonisolated init(edges: Edge.Set, length: Space) { self.edges = edges self.length = length } @@ -20,7 +20,7 @@ public struct PaddingModifier: ViewModifier { public struct PaddingEdgeInsetsModifier: ViewModifier { private let insets: EdgeSpaceInsets - public init(insets: EdgeSpaceInsets) { + public nonisolated init(insets: EdgeSpaceInsets) { self.insets = insets } @@ -55,22 +55,22 @@ public struct ContentPaddingModifier: ViewModifier { public extension View { @_disfavoredOverload - func padding(_ edges: Edge.Set, _ length: Space) -> some View { + nonisolated func padding(_ edges: Edge.Set, _ length: Space) -> some View { modifier(PaddingModifier(edges: edges, length: length)) } @_disfavoredOverload - func padding(_ length: Space) -> some View { + nonisolated func padding(_ length: Space) -> some View { modifier(PaddingModifier(edges: Edge.Set.all, length: length)) } - func padding(_ insets: EdgeSpaceInsets) -> some View { + nonisolated func padding(_ insets: EdgeSpaceInsets) -> some View { modifier(PaddingEdgeInsetsModifier(insets: insets)) } } public extension View { - func paddingContent(_ edges: Edge.Set = .all) -> some View { + nonisolated func paddingContent(_ edges: Edge.Set = .all) -> some View { modifier(ContentPaddingModifier(edges: edges)) } } diff --git a/Sources/OversizeUI/Extensions/Spacing/Spacing.swift b/Sources/OversizeUI/Extensions/Spacing/Spacing.swift index ea583fd..5653638 100644 --- a/Sources/OversizeUI/Extensions/Spacing/Spacing.swift +++ b/Sources/OversizeUI/Extensions/Spacing/Spacing.swift @@ -7,49 +7,49 @@ import SwiftUI // swiftlint:disable line_length public extension HStack { - @inlinable init(alignment: VerticalAlignment = .center, spacing: Space, @ViewBuilder content: () -> Content) { + @inlinable nonisolated init(alignment: VerticalAlignment = .center, spacing: Space, @ViewBuilder content: () -> Content) { self = .init(alignment: alignment, spacing: spacing.rawValue, content: content) } } public extension VStack { - @inlinable init(alignment: HorizontalAlignment = .center, spacing: Space, @ViewBuilder content: () -> Content) { + @inlinable nonisolated init(alignment: HorizontalAlignment = .center, spacing: Space, @ViewBuilder content: () -> Content) { self = .init(alignment: alignment, spacing: spacing.rawValue, content: content) } } public extension LazyHStack { - @inlinable init(alignment: VerticalAlignment = .center, spacing: Space, @ViewBuilder content: () -> Content) { + @inlinable nonisolated init(alignment: VerticalAlignment = .center, spacing: Space, @ViewBuilder content: () -> Content) { self = .init(alignment: alignment, spacing: spacing.rawValue, content: content) } } public extension LazyVStack { - @inlinable init(alignment: HorizontalAlignment = .center, spacing: Space, @ViewBuilder content: () -> Content) { + @inlinable nonisolated init(alignment: HorizontalAlignment = .center, spacing: Space, @ViewBuilder content: () -> Content) { self = .init(alignment: alignment, spacing: spacing.rawValue, content: content) } } public extension LazyVGrid { - @inlinable init(columns: [GridItem], alignment: HorizontalAlignment = .center, spacing: Space, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content) { + @inlinable nonisolated init(columns: [GridItem], alignment: HorizontalAlignment = .center, spacing: Space, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content) { self = .init(columns: columns, alignment: alignment, spacing: spacing.rawValue, pinnedViews: pinnedViews, content: content) } } public extension Spacer { - @inlinable init(minLength: Space) { + @MainActor @inlinable @preconcurrency init(minLength: Space) { self = .init(minLength: minLength.rawValue) } } public extension GridItem { - @inlinable init(_ size: GridItem.Size = .flexible(), spacing: Space, alignment: Alignment? = nil) { + @inlinable nonisolated init(_ size: GridItem.Size = .flexible(), spacing: Space, alignment: Alignment? = nil) { self = .init(size, spacing: spacing.rawValue, alignment: alignment) } } public extension RoundedRectangle { - @inlinable init(cornerRadius: Radius, style: RoundedCornerStyle = .circular) { + @inlinable nonisolated init(cornerRadius: Radius, style: RoundedCornerStyle = .circular) { self = .init(cornerRadius: cornerRadius.rawValue, style: style) } } diff --git a/Sources/OversizeUI/Extensions/View/View+If.swift b/Sources/OversizeUI/Extensions/View/View+If.swift index ba9d399..624ccc6 100644 --- a/Sources/OversizeUI/Extensions/View/View+If.swift +++ b/Sources/OversizeUI/Extensions/View/View+If.swift @@ -7,7 +7,7 @@ import SwiftUI public extension View { @ViewBuilder - func `if`(_ condition: Bool, _ modifications: (Self) -> some View) -> some View { + nonisolated func `if`(_ condition: Bool, _ modifications: (Self) -> some View) -> some View { if condition { modifications(self) } else { diff --git a/Sources/OversizeUI/Shapes/RoundedRectangleCorner.swift b/Sources/OversizeUI/Shapes/RoundedRectangleCorner.swift index c41437c..3ec5799 100644 --- a/Sources/OversizeUI/Shapes/RoundedRectangleCorner.swift +++ b/Sources/OversizeUI/Shapes/RoundedRectangleCorner.swift @@ -66,7 +66,7 @@ public struct RoundedRectangleCorner: Shape { controlPoint1: CGPoint(x: rect.maxX, y: rect.maxY - bottomRightRadius / 2), controlPoint2: CGPoint(x: rect.maxX - bottomRightRadius / 2, y: rect.maxY)) } - + path.line(to: CGPoint(x: rect.minX + bottomLeftRadius, y: rect.maxY)) if bottomLeftRadius > 0 { path.curve(to: CGPoint(x: rect.minX, y: rect.maxY - bottomLeftRadius),