diff --git a/Action Extension/ContentView.swift b/Action Extension/ContentView.swift index f57d101..98f67ab 100644 --- a/Action Extension/ContentView.swift +++ b/Action Extension/ContentView.swift @@ -21,7 +21,7 @@ struct ContentView: View { Image(systemName: "xmark.circle") .imageScale(.large) } - .accessibility(label: Text("Cancel")) + .accessibilityLabel("Cancel") Spacer() Button { saveImage() @@ -29,7 +29,7 @@ struct ContentView: View { Image(systemName: "square.and.arrow.down") .imageScale(.large) } - .accessibility(label: Text("Save Image")) + .accessibilityLabel("Save Image") } .shadow(radius: Constants.buttonShadowRadius) .accentColor(.white) diff --git a/Blear.xcodeproj/project.pbxproj b/Blear.xcodeproj/project.pbxproj index 8d4ccbb..db7afa5 100644 --- a/Blear.xcodeproj/project.pbxproj +++ b/Blear.xcodeproj/project.pbxproj @@ -387,7 +387,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.2; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_VERSION = 5.0; @@ -437,7 +437,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.2; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; diff --git a/Blear/ContentView.swift b/Blear/ContentView.swift index e8ae46f..2c50920 100644 --- a/Blear/ContentView.swift +++ b/Blear/ContentView.swift @@ -38,8 +38,8 @@ struct ContentView: View { } } label: { Image(systemName: "ellipsis.circle") - .accessibility(label: Text("More")) - // TODO: Workaround for iOS 14.1 where the tap target is tiny. + .accessibilityLabel("More") + // TODO: Workaround for iOS 14.5 where the tap target is tiny. .imageScale(.large) .padding(.trailing, 2) .contentShape(Rectangle()) @@ -54,7 +54,7 @@ struct ContentView: View { SinglePhotoPickerButton { pickedImage in image = Utilities.resizeImage(pickedImage) } - .accessibility(label: Text("Pick Image")) + .accessibilityLabel("Pick Image") .shadow(radius: Constants.buttonShadowRadius) Spacer() // TODO: Use a custom slider like the iOS brightness control. @@ -67,7 +67,7 @@ struct ContentView: View { } label: { Image(systemName: "square.and.arrow.down") } - .accessibility(label: Text("Save Image")) + .accessibilityLabel("Save Image") .shadow(radius: Constants.buttonShadowRadius) } .imageScale(.large) @@ -106,13 +106,13 @@ struct ContentView: View { ) } .alert(error: $saveError) - .sheet2(isPresented: $isShowingAboutSheet) { + .sheet(isPresented: $isShowingAboutSheet) { AboutView() } .onAppear { showShakeTipIfNeeded() } - .onReceive(UIDevice.current.didShakePublisher) { _ in + .onDeviceShake { image = Self.getRandomImage() } .accessNativeWindow { diff --git a/Blear/EditorView.swift b/Blear/EditorView.swift index ecb47b0..c684051 100644 --- a/Blear/EditorView.swift +++ b/Blear/EditorView.swift @@ -1,6 +1,8 @@ import SwiftUI struct EditorView: View { + private static let updateImageQueue = DispatchQueue(label: "\(SSApp.id).updateImage", qos: .userInteractive) + @ViewStorage private var workItem: DispatchWorkItem? @State private var blurredImage: UIImage? @@ -52,7 +54,7 @@ struct EditorView: View { } self.workItem = workItem - DispatchQueue.global(qos: .userInteractive).async(execute: workItem) + Self.updateImageQueue.async(execute: workItem) } } diff --git a/Blear/Utilities.swift b/Blear/Utilities.swift index ec4021a..a05a088 100644 --- a/Blear/Utilities.swift +++ b/Blear/Utilities.swift @@ -138,7 +138,7 @@ extension UIView { @objc func toImage() -> UIImage { UIGraphicsImageRenderer(size: bounds.size).image { _ in - self.drawHierarchy(in: bounds, afterScreenUpdates: true) + drawHierarchy(in: bounds, afterScreenUpdates: true) } } } @@ -471,21 +471,6 @@ extension UIImage { extension View { - /// This allows multiple sheets on a single view, which `.sheet()` doesn't. - func sheet2( - isPresented: Binding, - onDismiss: (() -> Void)? = nil, - @ViewBuilder content: @escaping () -> Content - ) -> some View { - background( - EmptyView().sheet( - isPresented: isPresented, - onDismiss: onDismiss, - content: content - ) - ) - } - /// This allows multiple alerts on a single view, which `.alert()` doesn't. func alert2( isPresented: Binding, @@ -617,6 +602,25 @@ extension UIWindow { } } +private struct DeviceShakeViewModifier: ViewModifier { + let action: (() -> Void) + + func body(content: Content) -> some View { + content + .onAppear() // Shake doesn't work without this. (iOS 14.5) + .onReceive(UIDevice.current.didShakePublisher) { _ in + action() + } + } +} + +extension View { + /// Perform sn ction when the device is shaked. + func onDeviceShake(perform action: @escaping (() -> Void)) -> some View { + modifier(DeviceShakeViewModifier(action: action)) + } +} + extension CGSize { var longestSide: CGFloat { max(width, height) } diff --git a/readme.md b/readme.md index 4fbf136..48bfb2e 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@

Website     - App Store + App Store