From bd9830108af04ddb540ad02d60cb15f401574dfb Mon Sep 17 00:00:00 2001 From: Hiroshi Kimura Date: Mon, 29 Aug 2022 01:10:06 +0900 Subject: [PATCH] iOS 13 + (#178) * :evergreen_tree: Update * :evergreen_tree: Update * :evergreen_tree: Update --- Brightroom.podspec | 8 +- Brightroom.xcodeproj/project.pbxproj | 40 ++---- .../xcshareddata/swiftpm/Package.resolved | 78 +++++------ Package.resolved | 4 +- Package.swift | 4 +- .../BrightroomEngine/Core/EditingStack.swift | 8 +- ...er.swift => BrightRoomImageRenderer.swift} | 7 +- .../ClassicImageEditPresetListControl.swift | 2 +- .../PhotosCrop/PhotosCropViewController.swift | 6 +- .../Shared/Components/Crop/CropView.swift | 4 +- .../Drawing/BlurryMaskingView.swift | 4 +- .../ImageViews/ImagePreviewView.swift | 2 +- Sources/SwiftUIDemo/ContentView.swift | 131 ++++++++++++------ Sources/SwiftUIDemo/IsolatedEditingView.swift | 27 ++-- .../RendererOrientationTests.swift | 4 +- .../BrightroomEngineTests/RendererTests.swift | 18 +-- 16 files changed, 181 insertions(+), 166 deletions(-) rename Sources/BrightroomEngine/Engine/{ImageRenderer.swift => BrightRoomImageRenderer.swift} (97%) diff --git a/Brightroom.podspec b/Brightroom.podspec index af252c91..571ae0f7 100644 --- a/Brightroom.podspec +++ b/Brightroom.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Brightroom" - s.version = "2.7.0" + s.version = "2.8.0" s.summary = "A component-oriented image editor on top of CoreImage." s.homepage = "https://github.com/muukii/Brightroom" @@ -8,12 +8,12 @@ Pod::Spec.new do |s| s.author = "muukii" s.source = { :git => "https://github.com/muukii/Brightroom.git", :tag => s.version } - s.swift_version = "5.3" + s.swift_version = "5.6" s.module_name = s.name s.requires_arc = true - s.ios.deployment_target = "12.0" + s.ios.deployment_target = "13.0" s.ios.frameworks = ["UIKit", "CoreImage"] - s.ios.dependency "Verge/Store", ">= 8.9.1" + s.ios.dependency "Verge/Store", ">= 8.19.0" s.subspec "Engine" do |ss| ss.source_files = "Sources/BrightroomEngine/**/*.swift" diff --git a/Brightroom.xcodeproj/project.pbxproj b/Brightroom.xcodeproj/project.pbxproj index 453fc7e3..00276332 100644 --- a/Brightroom.xcodeproj/project.pbxproj +++ b/Brightroom.xcodeproj/project.pbxproj @@ -85,7 +85,7 @@ 4B58E831260F0027004A834F /* orientation_up.HEIC in Resources */ = {isa = PBXBuildFile; fileRef = 4B254FED260BB32600F77E9A /* orientation_up.HEIC */; }; 4B58E889260F0DEA004A834F /* DemoPreviewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B58E888260F0DEA004A834F /* DemoPreviewViewController.swift */; }; 4B600B02216B7A94001E1456 /* BrightroomEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B600B00216B7A94001E1456 /* BrightroomEngine.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B600B19216B7BB9001E1456 /* ImageRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B600B18216B7BB9001E1456 /* ImageRenderer.swift */; }; + 4B600B19216B7BB9001E1456 /* BrightRoomImageRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B600B18216B7BB9001E1456 /* BrightRoomImageRenderer.swift */; }; 4B600B23216B7C9C001E1456 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B600B22216B7C9C001E1456 /* AppDelegate.swift */; }; 4B600B2A216B7C9E001E1456 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B600B29216B7C9E001E1456 /* Assets.xcassets */; }; 4B600B2D216B7C9E001E1456 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B600B2B216B7C9E001E1456 /* LaunchScreen.storyboard */; }; @@ -795,7 +795,7 @@ 4B600AFD216B7A94001E1456 /* BrightroomEngine.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BrightroomEngine.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4B600B00216B7A94001E1456 /* BrightroomEngine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BrightroomEngine.h; sourceTree = ""; }; 4B600B01216B7A94001E1456 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 4B600B18216B7BB9001E1456 /* ImageRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageRenderer.swift; sourceTree = ""; }; + 4B600B18216B7BB9001E1456 /* BrightRoomImageRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrightRoomImageRenderer.swift; sourceTree = ""; }; 4B600B20216B7C9C001E1456 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4B600B22216B7C9C001E1456 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4B600B29216B7C9E001E1456 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -1290,8 +1290,6 @@ FC110F162660FE0B00CC45EA /* m1-cb265e4ae8967567fca5b0ecd58b90cb.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "m1-cb265e4ae8967567fca5b0ecd58b90cb.png"; sourceTree = ""; }; FC394020266E0FCA00A1698E /* UIImage+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+.swift"; sourceTree = ""; }; FC4B7D81E5A0A734CEBB2036 /* Pods_Demo_Apps_Demo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Demo_Apps_Demo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - FCA2BEA2278E976000050FA4 /* AssetsPicker */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = AssetsPicker; path = ../AssetsPicker; sourceTree = ""; }; - FCA2BEA3278E982F00050FA4 /* AssetsPicker */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = AssetsPicker; path = ../AssetsPicker; sourceTree = ""; }; FCC7962523C58209009ACD8A /* LoadingBlurryOverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingBlurryOverlayView.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1589,7 +1587,6 @@ 4B600AF3216B7A94001E1456 = { isa = PBXGroup; children = ( - FCA2BEA1278E976000050FA4 /* Packages */, 4BE9B3D1260BA72D000A3D09 /* Bundle */, 4B4C7C8E260A6EF70082240A /* Archives */, 4B6A5F5B2179D43A004D68DC /* Sources */, @@ -1756,7 +1753,7 @@ 4B9B02EA216BBB6B001593B9 /* Engine */ = { isa = PBXGroup; children = ( - 4B600B18216B7BB9001E1456 /* ImageRenderer.swift */, + 4B600B18216B7BB9001E1456 /* BrightRoomImageRenderer.swift */, 4B135F752613767E003B5152 /* CoreGraphics+.swift */, 4B112F14216C9B5400EF8E25 /* ImageTool.swift */, ); @@ -2301,15 +2298,6 @@ name = ImageSamples; sourceTree = ""; }; - FCA2BEA1278E976000050FA4 /* Packages */ = { - isa = PBXGroup; - children = ( - FCA2BEA2278E976000050FA4 /* AssetsPicker */, - FCA2BEA3278E982F00050FA4 /* AssetsPicker */, - ); - name = Packages; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -3214,7 +3202,7 @@ 4B135F762613767E003B5152 /* CoreGraphics+.swift in Sources */, 4B66C9702171D6F8008F2A54 /* EditingStack.swift in Sources */, 4B04B3EE2177B0C70032356A /* FilterSaturation.swift in Sources */, - 4B600B19216B7BB9001E1456 /* ImageRenderer.swift in Sources */, + 4B600B19216B7BB9001E1456 /* BrightRoomImageRenderer.swift in Sources */, 4B9369EE25F94A1300B18571 /* EditingCrop.swift in Sources */, 4B112F15216C9B5400EF8E25 /* ImageTool.swift in Sources */, 4B9B02E7216BBA56001593B9 /* GraphicDrawing.swift in Sources */, @@ -3376,7 +3364,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Sources/$(TARGET_NAME)/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3403,7 +3390,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Sources/$(TARGET_NAME)/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3467,7 +3453,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -3527,7 +3513,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "app.muukii.brightroom.$(TARGET_NAME)"; @@ -3555,7 +3541,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Sources/$(TARGET_NAME)/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3584,7 +3569,6 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Sources/$(TARGET_NAME)/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3608,7 +3592,6 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = KU2QEJ9K3Z; INFOPLIST_FILE = "$(SRCROOT)/Sources/Demo/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3630,7 +3613,6 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = KU2QEJ9K3Z; INFOPLIST_FILE = "$(SRCROOT)/Sources/Demo/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3653,7 +3635,7 @@ DEVELOPMENT_TEAM = KU2QEJ9K3Z; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = Sources/SwiftUIDemo/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3676,7 +3658,7 @@ DEVELOPMENT_TEAM = KU2QEJ9K3Z; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = Sources/SwiftUIDemo/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; + IPHONEOS_DEPLOYMENT_TARGET = 14.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3695,7 +3677,6 @@ DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = GKNHX9R5U2; INFOPLIST_FILE = "Tests/$(TARGET_NAME)/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3715,7 +3696,6 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = GKNHX9R5U2; INFOPLIST_FILE = "Tests/$(TARGET_NAME)/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3734,7 +3714,6 @@ DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = KU2QEJ9K3Z; INFOPLIST_FILE = "$(SRCROOT)/Bundle/LUTs/Import LUT/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3755,7 +3734,6 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = KU2QEJ9K3Z; INFOPLIST_FILE = "$(SRCROOT)/Bundle/LUTs/Import LUT/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3776,7 +3754,6 @@ DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = KU2QEJ9K3Z; INFOPLIST_FILE = Bundle/LUTs/ShareLUT/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3797,7 +3774,6 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = KU2QEJ9K3Z; INFOPLIST_FILE = Bundle/LUTs/ShareLUT/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Brightroom.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Brightroom.xcworkspace/xcshareddata/swiftpm/Package.resolved index d19bf506..9f999a7d 100644 --- a/Brightroom.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Brightroom.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,43 +1,41 @@ { - "object": { - "pins": [ - { - "package": "MosaiqueAssetsPicker", - "repositoryURL": "https://github.com/eure/AssetsPicker.git", - "state": { - "branch": "master", - "revision": "fdc6c4654eaf85649414034aa0907144d0e330bb", - "version": null - } - }, - { - "package": "RxSwift", - "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", - "state": { - "branch": null, - "revision": "7e01c05f25c025143073eaa3be3532f9375c614b", - "version": "6.1.0" - } - }, - { - "package": "TransitionPatch", - "repositoryURL": "https://github.com/muukii/TransitionPatch.git", - "state": { - "branch": null, - "revision": "1f2e5930a68b11dae764ee7ffda14b2b7ffa8fce", - "version": "1.0.3" - } - }, - { - "package": "Verge", - "repositoryURL": "https://github.com/VergeGroup/Verge.git", - "state": { - "branch": null, - "revision": "3f9dca1d48d9381f4d05a923dd4ca59d77d1b4a6", - "version": "8.13.0" - } + "pins" : [ + { + "identity" : "assetspicker", + "kind" : "remoteSourceControl", + "location" : "https://github.com/eure/AssetsPicker.git", + "state" : { + "branch" : "master", + "revision" : "fdc6c4654eaf85649414034aa0907144d0e330bb" } - ] - }, - "version": 1 + }, + { + "identity" : "rxswift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ReactiveX/RxSwift.git", + "state" : { + "revision" : "7e01c05f25c025143073eaa3be3532f9375c614b", + "version" : "6.1.0" + } + }, + { + "identity" : "transitionpatch", + "kind" : "remoteSourceControl", + "location" : "https://github.com/muukii/TransitionPatch.git", + "state" : { + "revision" : "1f2e5930a68b11dae764ee7ffda14b2b7ffa8fce", + "version" : "1.0.3" + } + }, + { + "identity" : "verge", + "kind" : "remoteSourceControl", + "location" : "https://github.com/VergeGroup/Verge.git", + "state" : { + "revision" : "e066eb7dbaa9b55d2285af27dad2000cd905938d", + "version" : "8.19.0" + } + } + ], + "version" : 2 } diff --git a/Package.resolved b/Package.resolved index 65d823fd..a80526db 100644 --- a/Package.resolved +++ b/Package.resolved @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/VergeGroup/Verge.git", "state": { "branch": null, - "revision": "472a0273f6adf67132bb07f52ca4547ede6c9f6c", - "version": "8.8.0" + "revision": "e066eb7dbaa9b55d2285af27dad2000cd905938d", + "version": "8.19.0" } } ] diff --git a/Package.swift b/Package.swift index 73aa1916..f64e72c7 100644 --- a/Package.swift +++ b/Package.swift @@ -4,14 +4,14 @@ import PackageDescription let package = Package( name: "Brightroom", platforms: [ - .iOS(.v12) + .iOS(.v13) ], products: [ .library(name: "BrightroomEngine", targets: ["BrightroomUI"]), .library(name: "BrightroomUI", targets: ["BrightroomUI"]), ], dependencies: [ - .package(name: "Verge", url: "https://github.com/VergeGroup/Verge.git", from: "8.8.0"), + .package(name: "Verge", url: "https://github.com/VergeGroup/Verge.git", from: "8.19.0"), .package(url: "https://github.com/muukii/TransitionPatch.git", from: "1.0.3") ], targets: [ diff --git a/Sources/BrightroomEngine/Core/EditingStack.swift b/Sources/BrightroomEngine/Core/EditingStack.swift index cc7fa28f..0d09a98c 100644 --- a/Sources/BrightroomEngine/Core/EditingStack.swift +++ b/Sources/BrightroomEngine/Core/EditingStack.swift @@ -418,7 +418,7 @@ open class EditingStack: Hashable, StoreComponentType { commit { (modifyingState: inout InoutRef) in - if let loadedState = state._beta_map(\.loadedState) { + if let loadedState = state.mapIfPresent(\.loadedState) { modifyingState.map(keyPath: \.loadedState!) { (nextState) -> Void in loadedState.ifChanged(\.thumbnailImage) { image in @@ -548,7 +548,7 @@ open class EditingStack: Hashable, StoreComponentType { } } - public func makeRenderer() throws -> ImageRenderer { + public func makeRenderer() throws -> BrightRoomImageRenderer { let stateSnapshot = state guard let loaded = stateSnapshot.loadedState else { @@ -557,7 +557,7 @@ open class EditingStack: Hashable, StoreComponentType { let imageSource = loaded.imageSource - let renderer = ImageRenderer(source: imageSource, orientation: loaded.metadata.orientation) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: loaded.metadata.orientation) // TODO: Clean up ImageRenderer.Edit @@ -617,7 +617,7 @@ open class EditingStack: Hashable, StoreComponentType { orientation: CGImagePropertyOrientation ) throws -> CGImage { - let renderer = ImageRenderer(source: source, orientation: orientation) + let renderer = BrightRoomImageRenderer(source: source, orientation: orientation) renderer.edit.modifiers = filters let result = try renderer.render().cgImage diff --git a/Sources/BrightroomEngine/Engine/ImageRenderer.swift b/Sources/BrightroomEngine/Engine/BrightRoomImageRenderer.swift similarity index 97% rename from Sources/BrightroomEngine/Engine/ImageRenderer.swift rename to Sources/BrightroomEngine/Engine/BrightRoomImageRenderer.swift index e83b8488..ca8e73b7 100644 --- a/Sources/BrightroomEngine/Engine/ImageRenderer.swift +++ b/Sources/BrightroomEngine/Engine/BrightRoomImageRenderer.swift @@ -23,8 +23,11 @@ import CoreImage import SwiftUI import UIKit +@available(*, deprecated, renamed: "BrightRoomImageRenderer", message: "Renamed in favor of SwiftUI.ImageRenderer") +public typealias ImageRenderer = BrightRoomImageRenderer + /// It renders an image with options -public final class ImageRenderer { +public final class BrightRoomImageRenderer { public struct Options { @@ -42,7 +45,7 @@ public final class ImageRenderer { /// - workingFormat: /// - workingColorSpace: public init( - resolution: ImageRenderer.Resolution = .full, + resolution: BrightRoomImageRenderer.Resolution = .full, workingFormat: CIFormat = .ARGB8, workingColorSpace: CGColorSpace? = nil ) { diff --git a/Sources/BrightroomUI/Built-in UI/ClassicImageEdit/Components/ClassicImageEditPresetListControl.swift b/Sources/BrightroomUI/Built-in UI/ClassicImageEdit/Components/ClassicImageEditPresetListControl.swift index c293af0d..8c5c361a 100644 --- a/Sources/BrightroomUI/Built-in UI/ClassicImageEdit/Components/ClassicImageEditPresetListControl.swift +++ b/Sources/BrightroomUI/Built-in UI/ClassicImageEdit/Components/ClassicImageEditPresetListControl.swift @@ -81,7 +81,7 @@ open class ClassicImageEditPresetListControl: ClassicImageEditPresetListControlB self.store.commit { viewState in - if let state = state._beta_map(\.editingState.loadedState) { + if let state = state.mapIfPresent(\.editingState.loadedState) { state.ifChanged(\.thumbnailImage, \.previewFilterPresets) { image, filters in diff --git a/Sources/BrightroomUI/Built-in UI/PhotosCrop/PhotosCropViewController.swift b/Sources/BrightroomUI/Built-in UI/PhotosCrop/PhotosCropViewController.swift index f1812a70..a0f8f680 100644 --- a/Sources/BrightroomUI/Built-in UI/PhotosCrop/PhotosCropViewController.swift +++ b/Sources/BrightroomUI/Built-in UI/PhotosCrop/PhotosCropViewController.swift @@ -139,7 +139,7 @@ public final class PhotosCropViewController: UIViewController { - Attension: This operation can be run background-thread. */ - public func renderImage(options: BrightroomEngine.ImageRenderer.Options, completion: @escaping (Result) -> Void) { + public func renderImage(options: BrightRoomImageRenderer.Options, completion: @escaping (Result) -> Void) { do { try editingStack.makeRenderer().render(options: options, completion: completion) } catch { @@ -256,8 +256,8 @@ public final class PhotosCropViewController: UIViewController { editingStack.sinkState { [weak self] state in guard let self = self else { return } - - if let state = state._beta_map(\.loadedState) { + + if let state = state.mapIfPresent(\.loadedState) { /// Loaded diff --git a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift index 6c90917d..02d213e4 100644 --- a/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift +++ b/Sources/BrightroomUI/Shared/Components/Crop/CropView.swift @@ -285,7 +285,7 @@ public final class CropView: UIView, UIScrollViewDelegate { guard let self = self else { return } - if let loaded = state._beta_map(\.loadedState) { + if let loaded = state.mapIfPresent(\.loadedState) { loaded.ifChanged(\.imageForCrop) { image in self.setImage(image) @@ -354,7 +354,7 @@ public final class CropView: UIView, UIScrollViewDelegate { - Attension: This operation can be run background-thread. */ - public func renderImage() throws -> ImageRenderer.Rendered? { + public func renderImage() throws -> BrightRoomImageRenderer.Rendered? { applyEditingStack() return try editingStack.makeRenderer().render() } diff --git a/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift b/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift index 203435b6..fa51ed22 100644 --- a/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift +++ b/Sources/BrightroomUI/Shared/Components/Drawing/BlurryMaskingView.swift @@ -213,7 +213,7 @@ public final class BlurryMaskingView: PixelEditorCodeBasedView, UIScrollViewDele guard let self = self else { return } - if let state = state._beta_map(\.loadedState) { + if let state = state.mapIfPresent(\.loadedState) { state.ifChanged(\.currentEdit.crop) { cropRect in @@ -301,7 +301,7 @@ public final class BlurryMaskingView: PixelEditorCodeBasedView, UIScrollViewDele self.updateLoadingOverlay(displays: isLoading) } - if let state = state._beta_map(\.loadedState) { + if let state = state.mapIfPresent(\.loadedState) { state.ifChanged(\.editingPreviewImage) { image in self.backdropImageView.display(image: image) diff --git a/Sources/BrightroomUI/Shared/Components/ImageViews/ImagePreviewView.swift b/Sources/BrightroomUI/Shared/Components/ImageViews/ImagePreviewView.swift index c9ac43d2..641766a4 100644 --- a/Sources/BrightroomUI/Shared/Components/ImageViews/ImagePreviewView.swift +++ b/Sources/BrightroomUI/Shared/Components/ImageViews/ImagePreviewView.swift @@ -110,7 +110,7 @@ public final class ImagePreviewView: PixelEditorCodeBasedView { } UIView.performWithoutAnimation { - if let state = state._beta_map(\.loadedState) { + if let state = state.mapIfPresent(\.loadedState) { if state.hasChanges({ ($0.currentEdit) }, .init(==)) { self.requestPreviewImage(state: state.primitive) } diff --git a/Sources/SwiftUIDemo/ContentView.swift b/Sources/SwiftUIDemo/ContentView.swift index 8a8ff118..79feb40a 100644 --- a/Sources/SwiftUIDemo/ContentView.swift +++ b/Sources/SwiftUIDemo/ContentView.swift @@ -1,4 +1,4 @@ - +import BrightroomEngine import BrightroomUI import SwiftUI @@ -8,19 +8,27 @@ struct ContentView: View { @State private var sharedStack = Mocks.makeEditingStack(image: Mocks.imageHorizontal()) @State private var fullScreenView: FullscreenIdentifiableView? - @State private var stackForHorizontal: EditingStack = Mocks.makeEditingStack(image: Asset.horizontalRect.image) - @State private var stackForVertical: EditingStack = Mocks.makeEditingStack(image: Asset.verticalRect.image) - @State private var stackForSquare: EditingStack = Mocks.makeEditingStack(image: Asset.squareRect.image) + @State private var stackForHorizontal: EditingStack = Mocks.makeEditingStack( + image: Asset.horizontalRect.image + ) + @State private var stackForVertical: EditingStack = Mocks.makeEditingStack( + image: Asset.verticalRect.image + ) + @State private var stackForSquare: EditingStack = Mocks.makeEditingStack( + image: Asset.squareRect.image + ) @State private var stackForNasa: EditingStack = Mocks.makeEditingStack( fileURL: - Bundle.main.path( - forResource: "nasa", - ofType: "jpg" - ).map { - URL(fileURLWithPath: $0) - }! + Bundle.main.path( + forResource: "nasa", + ofType: "jpg" + ).map { + URL(fileURLWithPath: $0) + }! + ) + @State private var stackForSmall: EditingStack = Mocks.makeEditingStack( + image: Asset.superSmall.image ) - @State private var stackForSmall: EditingStack = Mocks.makeEditingStack(image: Asset.superSmall.image) var body: some View { NavigationView { @@ -35,6 +43,7 @@ struct ContentView: View { } } .frame(width: 120, height: 120, alignment: .center) + Form { NavigationLink("Isolated", destination: IsolatedEditinView()) @@ -45,76 +54,110 @@ struct ContentView: View { Section(content: { Button("Crop: Horizontal") { fullScreenView = .init { - SwiftUIPhotosCropView(editingStack: stackForHorizontal, onCompleted: { - self.image = try! stackForHorizontal.makeRenderer().render().swiftUIImage - self.fullScreenView = nil - }) + SwiftUIPhotosCropView( + editingStack: stackForHorizontal, + onDone: { + self.image = try! stackForHorizontal.makeRenderer().render().swiftUIImage + self.fullScreenView = nil + }, + onCancel: {} + ) } } Button("Crop: Vertical") { fullScreenView = .init { - SwiftUIPhotosCropView(editingStack: stackForVertical, onCompleted: { - self.image = try! stackForVertical.makeRenderer().render().swiftUIImage - self.fullScreenView = nil - }) + SwiftUIPhotosCropView( + editingStack: stackForVertical, + onDone: { + self.image = try! stackForVertical.makeRenderer().render().swiftUIImage + self.fullScreenView = nil + }, + onCancel: {} + ) } } Button("Crop: Square") { fullScreenView = .init { - SwiftUIPhotosCropView(editingStack: stackForSquare, onCompleted: { - self.image = try! stackForSquare.makeRenderer().render().swiftUIImage - self.fullScreenView = nil - }) + SwiftUIPhotosCropView( + editingStack: stackForSquare, + onDone: { + self.image = try! stackForSquare.makeRenderer().render().swiftUIImage + self.fullScreenView = nil + }, + onCancel: {} + ) } } Button("Crop: Nasa") { fullScreenView = .init { - SwiftUIPhotosCropView(editingStack: stackForNasa, onCompleted: { - self.image = try! stackForNasa.makeRenderer().render().swiftUIImage - self.fullScreenView = nil - }) + SwiftUIPhotosCropView( + editingStack: stackForNasa, + onDone: { + self.image = try! stackForNasa.makeRenderer().render().swiftUIImage + self.fullScreenView = nil + }, + onCancel: {} + ) } } Button("Crop: Super small") { fullScreenView = .init { - SwiftUIPhotosCropView(editingStack: stackForSmall, onCompleted: { - self.image = try! stackForSmall.makeRenderer().render().swiftUIImage - self.fullScreenView = nil - }) + SwiftUIPhotosCropView( + editingStack: stackForSmall, + onDone: { + self.image = try! stackForSmall.makeRenderer().render().swiftUIImage + self.fullScreenView = nil + }, + onCancel: {} + ) } } Button("Crop: Remote") { let stack = EditingStack( imageProvider: .init( - editableRemoteURL: URL(string: "https://images.unsplash.com/photo-1604456930969-37f67bcd6e1e?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1")! + editableRemoteURL: URL( + string: + "https://images.unsplash.com/photo-1604456930969-37f67bcd6e1e?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1" + )! ) ) fullScreenView = .init { - SwiftUIPhotosCropView(editingStack: stack, onCompleted: { - self.image = try! stack.makeRenderer().render().swiftUIImage - self.fullScreenView = nil - }) + SwiftUIPhotosCropView( + editingStack: stack, + onDone: { + self.image = try! stack.makeRenderer().render().swiftUIImage + self.fullScreenView = nil + }, + onCancel: {} + ) } } Button("Crop: Remote - preview") { let stack = EditingStack( imageProvider: .init( - editableRemoteURL: URL(string: "https://images.unsplash.com/photo-1597522781074-9a05ab90638e?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D")! + editableRemoteURL: URL( + string: + "https://images.unsplash.com/photo-1597522781074-9a05ab90638e?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D" + )! ) ) fullScreenView = .init { - SwiftUIPhotosCropView(editingStack: stack, onCompleted: { - self.image = try! stack.makeRenderer().render().swiftUIImage - self.fullScreenView = nil - }) + SwiftUIPhotosCropView( + editingStack: stack, + onDone: { + self.image = try! stack.makeRenderer().render().swiftUIImage + self.fullScreenView = nil + }, + onCancel: {} + ) } } }) @@ -154,7 +197,8 @@ struct ContentView: View { .navigationTitle("Pixel") .fullScreenCover( item: $fullScreenView, - onDismiss: {}, content: { + onDismiss: {}, + content: { $0 } ) @@ -165,9 +209,6 @@ struct ContentView: View { } } -import BrightroomUI -import BrightroomEngine - struct PixelEditWrapper: UIViewControllerRepresentable { typealias UIViewControllerType = UINavigationController diff --git a/Sources/SwiftUIDemo/IsolatedEditingView.swift b/Sources/SwiftUIDemo/IsolatedEditingView.swift index 4e27c879..0017fa80 100644 --- a/Sources/SwiftUIDemo/IsolatedEditingView.swift +++ b/Sources/SwiftUIDemo/IsolatedEditingView.swift @@ -1,26 +1,22 @@ - import BrightroomEngine -import SwiftUI import BrightroomUI +import SwiftUI struct IsolatedEditinView: View { @StateObject var editingStack = Mocks.makeEditingStack(image: Mocks.imageHorizontal()) -// @StateObject var editingStack = Mocks.makeEditingStack(fileURL: -// Bundle.main.path( -// forResource: "gaku", -// ofType: "jpeg" -// ).map { -// URL(fileURLWithPath: $0) -// }!) @State private var fullScreenView: FullscreenIdentifiableView? var body: some View { - Form { + Form.init { Button("Crop") { - fullScreenView = .init { SwiftUIPhotosCropView( - editingStack: editingStack, - onCompleted: {} - ) } + fullScreenView = .init { + SwiftUIPhotosCropView( + editingStack: editingStack, + onDone: {}, + onCancel: {} + ) + + } } Button("Custom Crop") { @@ -34,7 +30,8 @@ struct IsolatedEditinView: View { .navigationTitle("Isolated-Editing") .fullScreenCover( item: $fullScreenView, - onDismiss: {}, content: { + onDismiss: {}, + content: { $0 } ) diff --git a/Tests/BrightroomEngineTests/RendererOrientationTests.swift b/Tests/BrightroomEngineTests/RendererOrientationTests.swift index ba4bcd7d..d5727b20 100644 --- a/Tests/BrightroomEngineTests/RendererOrientationTests.swift +++ b/Tests/BrightroomEngineTests/RendererOrientationTests.swift @@ -13,11 +13,11 @@ import XCTest final class RendererOrientationTests: XCTestCase { private func run(image: UIImage, orientation: CGImagePropertyOrientation) throws - -> ImageRenderer.Rendered + -> BrightRoomImageRenderer.Rendered { let imageSource = ImageSource(image: image) - let renderer = ImageRenderer(source: imageSource, orientation: orientation) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: orientation) let rendered = try renderer.render() XCTAssert(rendered.engine == .coreGraphics) diff --git a/Tests/BrightroomEngineTests/RendererTests.swift b/Tests/BrightroomEngineTests/RendererTests.swift index 66fc73f6..c2ad690a 100644 --- a/Tests/BrightroomEngineTests/RendererTests.swift +++ b/Tests/BrightroomEngineTests/RendererTests.swift @@ -34,7 +34,7 @@ final class RendererTests: XCTestCase { func testCropping() throws { let imageSource = ImageSource(image: Asset.l1000069.image) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) var crop = EditingCrop(imageSize: imageSource.readImageSize()) crop.updateCropExtent(toFitAspectRatio: .square) @@ -55,7 +55,7 @@ final class RendererTests: XCTestCase { let inputCGImage = imageSource.loadOriginalCGImage() XCTAssertEqual(inputCGImage.colorSpace, ColorSpaces.displayP3) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) let image = try renderer.render(options: .init(workingColorSpace: ColorSpaces.displayP3)).cgImage @@ -68,7 +68,7 @@ final class RendererTests: XCTestCase { let inputCGImage = imageSource.loadOriginalCGImage() XCTAssertEqual(inputCGImage.colorSpace, ColorSpaces.sRGB) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) let image = try renderer.render(options: .init(workingColorSpace: ColorSpaces.displayP3)).cgImage @@ -81,7 +81,7 @@ final class RendererTests: XCTestCase { let inputCGImage = imageSource.loadOriginalCGImage() XCTAssertEqual(inputCGImage.colorSpace, ColorSpaces.sRGB) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) var filter = FilterExposure() filter.value = 0.72 @@ -99,7 +99,7 @@ final class RendererTests: XCTestCase { let inputCGImage = imageSource.loadOriginalCGImage() XCTAssertEqual(inputCGImage.colorSpace, ColorSpaces.sRGB) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) var filter = FilterExposure() filter.value = 0.72 @@ -124,7 +124,7 @@ final class RendererTests: XCTestCase { let inputCGImage = imageSource.loadOriginalCGImage() XCTAssertEqual(inputCGImage.colorSpace, ColorSpaces.sRGB) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) var filter = FilterExposure() filter.value = 0.72 @@ -150,7 +150,7 @@ final class RendererTests: XCTestCase { let inputCGImage = imageSource.loadOriginalCGImage() XCTAssertEqual(inputCGImage.colorSpace, ColorSpaces.sRGB) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) var crop = EditingCrop(imageSize: imageSource.readImageSize()) crop.rotation = .angle_90 @@ -171,7 +171,7 @@ final class RendererTests: XCTestCase { func testV2_drawing() throws { let imageSource = ImageSource(image: Asset.leica.image) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) var crop = EditingCrop(imageSize: imageSource.readImageSize()) // crop.rotation = .angle_90 @@ -218,7 +218,7 @@ final class RendererTests: XCTestCase { let inputCGImage = imageSource.loadOriginalCGImage() XCTAssertEqual(inputCGImage.colorSpace, ColorSpaces.displayP3) - let renderer = ImageRenderer(source: imageSource, orientation: .up) + let renderer = BrightRoomImageRenderer(source: imageSource, orientation: .up) let image = try renderer.render(options: .init(workingColorSpace: ColorSpaces.displayP3)).cgImage