Skip to content

Commit

Permalink
Merge branch '254-fix-color-picker-accessibility-label' into 'release…
Browse files Browse the repository at this point in the history
…/22.5'

Resolve "Fix color picker accessibility label"

Closes #254

See merge request highlighter/app!221
  • Loading branch information
Arclite committed Jul 2, 2022
2 parents 0d7dd7c + 3e447cc commit f894f78
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Editing/Editing View/PhotoEditingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class PhotoEditingViewController: UIViewController, UIScrollViewDelegate,
}

private func updateToolbarItems(animated: Bool = true) {
let actionSet = ActionSet(for: self, undoManager: undoManager, selectedTool: photoEditingView.highlighterTool, sizeClass: traitCollection.horizontalSizeClass)
let actionSet = ActionSet(for: self, undoManager: undoManager, selectedTool: photoEditingView.highlighterTool, sizeClass: traitCollection.horizontalSizeClass, currentColor: photoEditingView.color)

navigationItem.setLeftBarButtonItems(actionSet.leadingNavigationItems, animated: false)
navigationItem.setRightBarButtonItems(actionSet.trailingNavigationItems, animated: false)
Expand Down Expand Up @@ -239,6 +239,7 @@ public class PhotoEditingViewController: UIViewController, UIScrollViewDelegate,

public func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
photoEditingView.color = viewController.selectedColor
updateToolbarItems()
}

// MARK: Undo/Redo
Expand Down
8 changes: 5 additions & 3 deletions Editing/Editing View/Toolbar Items/ActionSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct ActionSet {
}

if sizeClass == .regular {
ColorPickerBarButtonItem(target: target)
ColorPickerBarButtonItem(target: target, color: currentColor)
HighlighterToolBarButtonItem(tool: selectedTool, target: target)
}
}
Expand All @@ -36,20 +36,22 @@ struct ActionSet {
SeekBarButtonItem(target: target)
}

ColorPickerBarButtonItem(target: target)
ColorPickerBarButtonItem(target: target, color: currentColor)
HighlighterToolBarButtonItem(tool: selectedTool, target: target)
}
}

init(for target: AnyObject, undoManager: UndoManager?, selectedTool: HighlighterTool, sizeClass: UIUserInterfaceSizeClass) {
init(for target: AnyObject, undoManager: UndoManager?, selectedTool: HighlighterTool, sizeClass: UIUserInterfaceSizeClass, currentColor: UIColor) {
self.target = target
self.undoManager = undoManager
self.selectedTool = selectedTool
self.sizeClass = sizeClass
self.currentColor = currentColor
}

private let target: AnyObject
private let undoManager: UndoManager?
private let selectedTool: HighlighterTool
private let sizeClass: UIUserInterfaceSizeClass
private let currentColor: UIColor
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import UIKit

class ColorPickerBarButtonItem: UIBarButtonItem {
convenience init(target: AnyObject?) {
convenience init(target: AnyObject?, color: UIColor) {
self.init(image: UIImage(systemName: "paintpalette"), style: .plain, target: target, action: #selector(ActionsBuilderActions.showColorPicker(_:)))
accessibilityLabel = NSLocalizedString("ColorPickerBarButtonItem.accessibilityLabel", comment: "Accessibility label for the color picker toolbar item")
accessibilityValue = color.accessibilityName
}
}
2 changes: 2 additions & 0 deletions Highlighter/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"CollectionsDataSource.userAlbumsHeader" = "Albums";
"CollectionsDataSource.smartAlbumsHeader" = "Library";

"ColorPickerBarButtonItem.accessibilityLabel" = "Color Picker";

"ContactMailViewController.emailSubject" = "Hello!";

"DesktopSaveAlertController.dismissButtonTitle" = "OK";
Expand Down

0 comments on commit f894f78

Please sign in to comment.