From 4e22e337817a8c4e6a2d1aa981ac25bc35319889 Mon Sep 17 00:00:00 2001 From: Geoff Pado Date: Wed, 30 Oct 2024 14:02:22 -0700 Subject: [PATCH 1/2] Update color picker to use color well instead --- .../PhotoEditingViewController.swift | 5 +++++ .../Toolbar Items/ActionsBuilderActions.swift | 1 + .../ColorPickerBarButtonItem.swift | 22 ++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift index 0e5ffaf1..786cde68 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/PhotoEditingViewController.swift @@ -300,6 +300,11 @@ public class PhotoEditingViewController: UIViewController, UIScrollViewDelegate, updateToolbarItems() } + @objc func selectedColorDidChange(_ sender: UIColorWell) { + guard let color = sender.selectedColor else { return } + photoEditingView.color = color + } + // MARK: Undo/Redo private let localUndoManager = UndoManager() diff --git a/Modules/Legacy/Editing/Sources/Editing View/Toolbar Items/ActionsBuilderActions.swift b/Modules/Legacy/Editing/Sources/Editing View/Toolbar Items/ActionsBuilderActions.swift index cf51a564..0659c35d 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/Toolbar Items/ActionsBuilderActions.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/Toolbar Items/ActionsBuilderActions.swift @@ -9,6 +9,7 @@ import Foundation func toggleHighlighterTool(_ sender: Any) func showColorPicker(_ sender: Any) func showAutoRedactAccess(_ sender: Any) + func selectedColorDidChange(_ sender: Any) func startSeeking(_ sender: Any) func showDebugPreferences(_ sender: Any) } diff --git a/Modules/Legacy/Editing/Sources/Editing View/Toolbar Items/ColorPickerBarButtonItem.swift b/Modules/Legacy/Editing/Sources/Editing View/Toolbar Items/ColorPickerBarButtonItem.swift index 878ab84a..03c603b0 100644 --- a/Modules/Legacy/Editing/Sources/Editing View/Toolbar Items/ColorPickerBarButtonItem.swift +++ b/Modules/Legacy/Editing/Sources/Editing View/Toolbar Items/ColorPickerBarButtonItem.swift @@ -5,8 +5,28 @@ import UIKit class ColorPickerBarButtonItem: UIBarButtonItem { convenience init(target: AnyObject?, color: UIColor) { - self.init(image: UIImage(systemName: "paintpalette"), style: .plain, target: target, action: #selector(ActionsBuilderActions.showColorPicker(_:))) + self.init(customView: ColorWell(target: target, color: color)) + + UIView.appearance(whenContainedInInstancesOf: [UIColorPickerViewController.self]).overrideUserInterfaceStyle = .dark accessibilityLabel = EditingStrings.ColorPickerBarButtonItem.accessibilityLabel accessibilityValue = color.accessibilityName } + + class ColorWell: UIColorWell { + init(target: AnyObject?, color: UIColor) { + super.init(frame: .zero) + addTarget(target, action: #selector(ActionsBuilderActions.selectedColorDidChange(_:)), for: .primaryActionTriggered) + selectedColor = color + overrideUserInterfaceStyle = .dark + translatesAutoresizingMaskIntoConstraints = false + } + + // MARK: Boilerplate + + @available(*, unavailable) + required init(coder: NSCoder) { + let typeName = NSStringFromClass(type(of: self)) + fatalError("\(typeName) does not implement init(coder:)") + } + } } From 918bbe807b55a9cc713a3672324ab4bda7075040 Mon Sep 17 00:00:00 2001 From: Geoff Pado Date: Wed, 30 Oct 2024 14:05:29 -0700 Subject: [PATCH 2/2] Disable SwiftLint false-positive --- .../Capabilities/SettingsUI/Sources/Web URLs/URLExtensions.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Capabilities/SettingsUI/Sources/Web URLs/URLExtensions.swift b/Modules/Capabilities/SettingsUI/Sources/Web URLs/URLExtensions.swift index e2b17c9a..619f4000 100644 --- a/Modules/Capabilities/SettingsUI/Sources/Web URLs/URLExtensions.swift +++ b/Modules/Capabilities/SettingsUI/Sources/Web URLs/URLExtensions.swift @@ -24,6 +24,7 @@ public extension URL { extension String { init(_ staticString: StaticString) { self = staticString.withUTF8Buffer { + // swiftlint:disable:next optional_data_string_conversion String(decoding: $0, as: UTF8.self) } }