Skip to content

Commit

Permalink
Fix an issue with clear navigation bar background in revision browser (
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Jan 3, 2025
2 parents 87ff4b6 + 56ef3a7 commit 7b36ced
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 111 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [*] Add "Share" action to site link context menu on dashboard [#23935]
* [*] Fix layout issues in Privacy Settings section of App Settings [#23936]
* [*] Fix incorrect chevron icons direction in RTL languages [#23940]
* [*] Fix an issue with clear navigation bar background in revision browser [#23941]

25.6
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,7 @@ class RevisionDiffsBrowserViewController: UIViewController {
@IBOutlet private var previousButton: UIButton!
@IBOutlet private var nextButton: UIButton!

private lazy var doneBarButtonItem: UIBarButtonItem = {
let doneItem = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: nil)
doneItem.title = NSLocalizedString("Done", comment: "Label on button to dismiss revisions view")
doneItem.on() { [weak self] _ in
WPAnalytics.track(.postRevisionsDetailCancelled)
self?.dismiss(animated: true)
}
return doneItem
}()

private lazy var moreBarButtonItem: UIBarButtonItem = {
let image = UIImage(systemName: "ellipsis")
let button = UIButton(type: .system)
button.setImage(image, for: .normal)
button.frame = CGRect(origin: .zero, size: image?.size ?? .zero)
button.accessibilityLabel = NSLocalizedString("More", comment: "Action button to display more available options")
button.on(.touchUpInside) { [weak self] _ in
self?.moreWasPressed()
}
button.setContentHuggingPriority(.required, for: .horizontal)
return UIBarButtonItem(customView: button)
}()
private lazy var moreBarButtonItem = UIBarButtonItem(image: UIImage(systemName: "ellipsis"), menu: makeMoreMenu())

private lazy var loadBarButtonItem: UIBarButtonItem = {
let title = NSLocalizedString("Load", comment: "Title of the screen that load selected the revisions.")
Expand Down Expand Up @@ -111,6 +90,13 @@ class RevisionDiffsBrowserViewController: UIViewController {
}
}
}

// MARK: - Actions

@objc private func buttonCloseTapped() {
WPAnalytics.track(.postRevisionsDetailCancelled)
dismiss(animated: true)
}
}

private extension RevisionDiffsBrowserViewController {
Expand Down Expand Up @@ -141,7 +127,7 @@ private extension RevisionDiffsBrowserViewController {
}

private func setupNavbarItems() {
navigationItem.leftBarButtonItems = [doneBarButtonItem]
navigationItem.leftBarButtonItem = UIBarButtonItem(title: SharedStrings.Button.close, style: .plain, target: self, action: #selector(buttonCloseTapped))
navigationItem.rightBarButtonItems = [moreBarButtonItem, loadBarButtonItem]
navigationItem.title = NSLocalizedString("Revision", comment: "Title of the screen that shows the revisions.")
strokeView.backgroundColor = .separator
Expand Down Expand Up @@ -234,14 +220,19 @@ private extension RevisionDiffsBrowserViewController {
})
}

private func moreWasPressed() {
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
alert.addDefaultActionWithTitle(contentPreviewState.toggle().title) { [unowned self] _ in
self.triggerPreviewState()
private func makeMoreMenu() -> UIMenu {
UIMenu(options: .displayInline, children: [
UIDeferredMenuElement.uncached { [weak self] in
$0(self?.makeMoreMenuActions() ?? [])
}
])
}

private func makeMoreMenuActions() -> [UIAction] {
let toggleMode = UIAction(title: contentPreviewState.toggle().title) { [weak self] _ in
self?.triggerPreviewState()
}
alert.addCancelActionWithTitle(NSLocalizedString("Not Now", comment: "Nicer dialog answer for \"No\"."))
alert.popoverPresentationController?.barButtonItem = moreBarButtonItem
present(alert, animated: true)
return [toggleMode]
}

private func trackRevisionsDetailViewed(with source: ShowRevisionSource) {
Expand Down
Loading

0 comments on commit 7b36ced

Please sign in to comment.