From 8ea7bb8a8a63e1423066395bed40f86c1bf85bc2 Mon Sep 17 00:00:00 2001 From: Alexandr Romanov Date: Fri, 13 Dec 2024 10:20:47 +0300 Subject: [PATCH] Update images --- .swiftformat | 2 +- Package.swift | 1 + .../OversizeUI/Controls/PageView/Page.swift | 5 +- .../SegmentedControl/SegmentedControl.swift | 31 +++++++----- .../TextField/LabeledTextFieldStyle.swift | 2 +- .../Core/Appearance/ThemeSettings.swift | 4 +- Sources/OversizeUI/Core/Illustrations.swift | 19 ++++++++ .../ViewModifier/DelayTask/DelayTask.swift | 32 +++++++++++++ Sources/OversizeUI/Deprecated/Icon.swift | 24 ++++++---- .../Extensions/View/View+SizeReader.swift | 2 +- .../Support/Success.colorset/Contents.json | 12 ++--- .../Images.xcassets/Status/Contents.json | 3 ++ .../Status/Error.imageset/Error.svg | 47 ++++++++++++------- .../Status/Success.imageset/Success.svg | 47 ++++++++++++------- .../Status/Test.imageset/Error.svg | 27 ----------- .../Status/Warning.imageset/Warning.svg | 47 ++++++++++++------- .../Status/Warning/Contents.json | 9 ++++ .../Triangle.imageset}/Contents.json | 2 +- .../Warning/Triangle.imageset/WarningT.svg | 38 +++++++++++++++ 19 files changed, 245 insertions(+), 109 deletions(-) create mode 100644 Sources/OversizeUI/Core/Illustrations.swift create mode 100644 Sources/OversizeUI/Core/ViewModifier/DelayTask/DelayTask.swift delete mode 100644 Sources/OversizeUI/Resources/Images.xcassets/Status/Test.imageset/Error.svg create mode 100644 Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Contents.json rename Sources/OversizeUI/Resources/Images.xcassets/Status/{Test.imageset => Warning/Triangle.imageset}/Contents.json (84%) create mode 100644 Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Triangle.imageset/WarningT.svg diff --git a/.swiftformat b/.swiftformat index ed5d06d..b12b883 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,3 +1,3 @@ ---swiftversion 5.9 +--swiftversion 6.0 --disable preferKeyPath --ifdef no-indent \ No newline at end of file diff --git a/Package.swift b/Package.swift index 96be672..61b2eca 100644 --- a/Package.swift +++ b/Package.swift @@ -12,6 +12,7 @@ let package = Package( .macOS(.v13), .tvOS(.v15), .watchOS(.v9), + .visionOS(.v2), ], products: [ .library( diff --git a/Sources/OversizeUI/Controls/PageView/Page.swift b/Sources/OversizeUI/Controls/PageView/Page.swift index ab1f07a..cbdd36f 100644 --- a/Sources/OversizeUI/Controls/PageView/Page.swift +++ b/Sources/OversizeUI/Controls/PageView/Page.swift @@ -96,9 +96,8 @@ public struct Page: V @Environment(\.segmentedControlStyle) private var style @Environment(\.controlRadius) var controlRadius: Radius @Environment(\.segmentedPickerMargins) var controlPadding: EdgeSpaceInsets + @Environment(\.platform) var platform: Platform public typealias Data = [Element] @@ -224,7 +225,8 @@ public struct SegmentedPickerSelector: V ? Color.border : Color.surfaceSecondary, lineWidth: CGFloat(theme.borderSize)) ) - .shadowElevaton(.z2) + .shadowElevaton(platform == .macOS ? .z0 : .z2) + case .graySurface: if style.unseletionStyle == .clean { @@ -246,6 +248,7 @@ public struct SegmentedPickerSelector: V style: .continuous) .strokeBorder(Color.onSurfaceSecondary, lineWidth: 2) } + case .accentSurface: RoundedRectangle( cornerRadius: style.isShowBackground ? controlRadius.rawValue - 4 : controlRadius.rawValue, @@ -261,17 +264,23 @@ public struct SegmentedPickerSelector: V case .clean: EmptyView() case .surface: - - RoundedRectangle(cornerRadius: controlRadius, - style: .continuous) - .fill(Color.surfaceSecondary) - .overlay( - RoundedRectangle(cornerRadius: controlRadius, - style: .continuous) - .stroke(theme.borderControls - ? Color.border - : Color.surfaceSecondary, lineWidth: CGFloat(theme.borderSize)) + RoundedRectangle( + cornerRadius: controlRadius, + style: .continuous + ) + .fill(Color.surfaceSecondary) + .overlay( + RoundedRectangle( + cornerRadius: controlRadius, + style: .continuous + ) + .stroke( + theme.borderControls + ? Color.border + : Color.surfaceSecondary, + lineWidth: CGFloat(theme.borderSize) ) + ) } } } diff --git a/Sources/OversizeUI/Controls/TextField/LabeledTextFieldStyle.swift b/Sources/OversizeUI/Controls/TextField/LabeledTextFieldStyle.swift index 09444cf..b68e086 100644 --- a/Sources/OversizeUI/Controls/TextField/LabeledTextFieldStyle.swift +++ b/Sources/OversizeUI/Controls/TextField/LabeledTextFieldStyle.swift @@ -122,7 +122,7 @@ public struct LabeledTextFieldStyle: TextFieldStyle { private var fieldRadius: Radius { #if os(macOS) - return .xSmall + return .small #else return .medium #endif diff --git a/Sources/OversizeUI/Core/Appearance/ThemeSettings.swift b/Sources/OversizeUI/Core/Appearance/ThemeSettings.swift index 2003066..45603d5 100644 --- a/Sources/OversizeUI/Core/Appearance/ThemeSettings.swift +++ b/Sources/OversizeUI/Core/Appearance/ThemeSettings.swift @@ -43,14 +43,14 @@ public class ThemeSettings: ObservableObject, @unchecked Sendable { @AppStorage(ThemeSettingsNames.borderTextFields) public var borderTextFields: Bool = true @AppStorage(ThemeSettingsNames.borderSurface) public var borderSurface: Bool = true @AppStorage(ThemeSettingsNames.radius) public var radius: Double = 4 + @AppStorage(ThemeSettingsNames.borderControls) public var borderControls: Bool = true #else @AppStorage(ThemeSettingsNames.borderSurface) public var borderSurface: Bool = false @AppStorage(ThemeSettingsNames.borderTextFields) public var borderTextFields: Bool = false @AppStorage(ThemeSettingsNames.borderSize) public var borderSize: Double = 0.5 @AppStorage(ThemeSettingsNames.radius) public var radius: Double = 8 - #endif - @AppStorage(ThemeSettingsNames.borderControls) public var borderControls: Bool = false + #endif @AppStorage(ThemeSettingsNames.theme) public var theme: Int = 0 diff --git a/Sources/OversizeUI/Core/Illustrations.swift b/Sources/OversizeUI/Core/Illustrations.swift new file mode 100644 index 0000000..61004f0 --- /dev/null +++ b/Sources/OversizeUI/Core/Illustrations.swift @@ -0,0 +1,19 @@ +// +// Copyright © 2024 Alexander Romanov +// Illustration.swift, created on 16.11.2024 +// + +import SwiftUI + +public extension SwiftUI.Image { + enum Illustration { + public enum Status { + public static let success = Image("Status/Success", bundle: .module) + public static let error = Image("Status/Error", bundle: .module) + public static let warning = Image("Status/Warning", bundle: .module) + public enum Warning { + public static let fill = Image("Status/Warning/Triangle", bundle: .module) + } + } + } +} diff --git a/Sources/OversizeUI/Core/ViewModifier/DelayTask/DelayTask.swift b/Sources/OversizeUI/Core/ViewModifier/DelayTask/DelayTask.swift new file mode 100644 index 0000000..f83bed4 --- /dev/null +++ b/Sources/OversizeUI/Core/ViewModifier/DelayTask/DelayTask.swift @@ -0,0 +1,32 @@ +// +// Copyright © 2024 Alexander Romanov +// DelayTaskViewModifier.swift, created on 13.11.2024 +// + +import SwiftUI + +@available(iOS 16.0, tvOS 16.0, watchOS 9.0, macOS 13.0, *) +struct DelayTaskViewModifier: ViewModifier { + let delay: ContinuousClock.Instant.Duration + let action: @Sendable () async -> Void + + func body(content: Content) -> some View { + content + .task { + do { + try await Task.sleep(for: delay) + await action() + } catch {} + } + } +} + +@available(iOS 16.0, tvOS 16.0, watchOS 9.0, macOS 13.0, *) +public extension View { + func task( + delay: ContinuousClock.Duration, + action: @Sendable @escaping () async -> Void + ) -> some View { + modifier(DelayTaskViewModifier(delay: delay, action: action)) + } +} diff --git a/Sources/OversizeUI/Deprecated/Icon.swift b/Sources/OversizeUI/Deprecated/Icon.swift index 6eb0e89..361d4d8 100644 --- a/Sources/OversizeUI/Deprecated/Icon.swift +++ b/Sources/OversizeUI/Deprecated/Icon.swift @@ -6,6 +6,7 @@ import SwiftUI public enum IconSizes: CaseIterable { + case xSmall case small case medium case large @@ -13,6 +14,8 @@ public enum IconSizes: CaseIterable { public var rawValue: CGFloat { switch self { + case .xSmall: + Space.xSmall.rawValue case .small: Space.small.rawValue case .medium: @@ -32,6 +35,7 @@ public enum IconSizes: CaseIterable { public struct IconDeprecated: View { private enum Constants: Sendable { /// Size + static let xSmall: CGFloat = Space.xSmall.rawValue static let small: CGFloat = Space.small.rawValue static let medium: CGFloat = Space.medium.rawValue static let large: CGFloat = Space.large.rawValue @@ -74,10 +78,12 @@ public struct IconDeprecated: View { private var iconSize: CGFloat { switch size { - case .medium: - Constants.medium + case .xSmall: + Constants.xSmall case .small: Constants.small + case .medium: + Constants.medium case .large: Constants.large case .xLarge: @@ -95,12 +101,14 @@ public struct IconDeprecated: View { @available(tvOS, unavailable) struct IconAsset_Previews: PreviewProvider { static var previews: some View { - let grid = [GridItem(), - GridItem(), - GridItem(), - GridItem(), - GridItem(), - GridItem()] + let grid = [ + GridItem(), + GridItem(), + GridItem(), + GridItem(), + GridItem(), + GridItem(), + ] Button(role: .cancel, action: {}, label: { Text("Text") diff --git a/Sources/OversizeUI/Extensions/View/View+SizeReader.swift b/Sources/OversizeUI/Extensions/View/View+SizeReader.swift index 42265cb..c11f82e 100644 --- a/Sources/OversizeUI/Extensions/View/View+SizeReader.swift +++ b/Sources/OversizeUI/Extensions/View/View+SizeReader.swift @@ -6,7 +6,7 @@ import SwiftUI public extension View { - func readSize(onChange: @escaping (CGSize) -> Void) -> some View { + func readSize(onChange: @Sendable @escaping (CGSize) -> Void) -> some View { background( GeometryReader { geometryProxy in Color.clear diff --git a/Sources/OversizeUI/Resources/Colors.xcassets/Support/Success.colorset/Contents.json b/Sources/OversizeUI/Resources/Colors.xcassets/Support/Success.colorset/Contents.json index ae21d12..de2e634 100644 --- a/Sources/OversizeUI/Resources/Colors.xcassets/Support/Success.colorset/Contents.json +++ b/Sources/OversizeUI/Resources/Colors.xcassets/Support/Success.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.404", - "green" : "0.831", - "red" : "0.333" + "blue" : "0x5E", + "green" : "0xB3", + "red" : "0x5C" } }, "idiom" : "universal" @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0.294", - "green" : "0.745", - "red" : "0.220" + "blue" : "0x4B", + "green" : "0x99", + "red" : "0x4B" } }, "idiom" : "universal" diff --git a/Sources/OversizeUI/Resources/Images.xcassets/Status/Contents.json b/Sources/OversizeUI/Resources/Images.xcassets/Status/Contents.json index 73c0059..6e96565 100644 --- a/Sources/OversizeUI/Resources/Images.xcassets/Status/Contents.json +++ b/Sources/OversizeUI/Resources/Images.xcassets/Status/Contents.json @@ -2,5 +2,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "provides-namespace" : true } } diff --git a/Sources/OversizeUI/Resources/Images.xcassets/Status/Error.imageset/Error.svg b/Sources/OversizeUI/Resources/Images.xcassets/Status/Error.imageset/Error.svg index f1afdcd..a939d32 100644 --- a/Sources/OversizeUI/Resources/Images.xcassets/Status/Error.imageset/Error.svg +++ b/Sources/OversizeUI/Resources/Images.xcassets/Status/Error.imageset/Error.svg @@ -1,27 +1,42 @@ - - - - + + + + + + + - - + - - - - - + + + + + - - - + + + + + + + + + + + + + + + + - - + + diff --git a/Sources/OversizeUI/Resources/Images.xcassets/Status/Success.imageset/Success.svg b/Sources/OversizeUI/Resources/Images.xcassets/Status/Success.imageset/Success.svg index e44c6dc..4bbfbeb 100644 --- a/Sources/OversizeUI/Resources/Images.xcassets/Status/Success.imageset/Success.svg +++ b/Sources/OversizeUI/Resources/Images.xcassets/Status/Success.imageset/Success.svg @@ -1,27 +1,42 @@ - - - - + + + + + + + - - + - - - - - + + + + + - - - + + + + + + + + + + + + + + + + - - + + diff --git a/Sources/OversizeUI/Resources/Images.xcassets/Status/Test.imageset/Error.svg b/Sources/OversizeUI/Resources/Images.xcassets/Status/Test.imageset/Error.svg deleted file mode 100644 index f1afdcd..0000000 --- a/Sources/OversizeUI/Resources/Images.xcassets/Status/Test.imageset/Error.svg +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning.imageset/Warning.svg b/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning.imageset/Warning.svg index 7536759..10906ef 100644 --- a/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning.imageset/Warning.svg +++ b/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning.imageset/Warning.svg @@ -1,27 +1,42 @@ - - - - + + + + + + + - - + - - - - - + + + + + - - - + + + + + + + + + + + + + + + + - - + + diff --git a/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Contents.json b/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Contents.json new file mode 100644 index 0000000..6e96565 --- /dev/null +++ b/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Contents.json @@ -0,0 +1,9 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "provides-namespace" : true + } +} diff --git a/Sources/OversizeUI/Resources/Images.xcassets/Status/Test.imageset/Contents.json b/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Triangle.imageset/Contents.json similarity index 84% rename from Sources/OversizeUI/Resources/Images.xcassets/Status/Test.imageset/Contents.json rename to Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Triangle.imageset/Contents.json index eb31d0b..b3b8c5c 100644 --- a/Sources/OversizeUI/Resources/Images.xcassets/Status/Test.imageset/Contents.json +++ b/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Triangle.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "Error.svg", + "filename" : "WarningT.svg", "idiom" : "universal" } ], diff --git a/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Triangle.imageset/WarningT.svg b/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Triangle.imageset/WarningT.svg new file mode 100644 index 0000000..b97e71a --- /dev/null +++ b/Sources/OversizeUI/Resources/Images.xcassets/Status/Warning/Triangle.imageset/WarningT.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +