Skip to content

Commit

Permalink
Fix#6118 - Wrong title of navbarButtonItem on edit mode after rotation (
Browse files Browse the repository at this point in the history
#6119)

* Fix#6118 - Wrong title of navbarButtonItem on edit mode after rotation

* Remove this extra space
  • Loading branch information
yusadogru committed Feb 18, 2020
1 parent a4f1957 commit cedb7b1
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Client/Frontend/Library/BookmarksPanel.swift
Expand Up @@ -84,16 +84,11 @@ class BookmarksPanel: SiteTableViewController, LibraryPanel {
tableView.allowsSelectionDuringEditing = true

self.editBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit) { _ in
self.tableView.setEditing(true, animated: true)
self.navigationItem.leftBarButtonItem = self.newBarButtonItem
self.navigationItem.rightBarButtonItem = self.doneBarButtonItem
self.enableEditMode()
}

self.doneBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done) { _ in
self.tableView.setEditing(false, animated: true)
self.navigationItem.leftBarButtonItem = nil
self.navigationItem.rightBarButtonItem = self.editBarButtonItem
self.setupBackButtonGestureRecognizer()
self.disableEditMode()
}

self.newBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add) { _ in
Expand Down Expand Up @@ -151,6 +146,13 @@ class BookmarksPanel: SiteTableViewController, LibraryPanel {

setupBackButtonGestureRecognizer()
}

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
if tableView.isEditing {
disableEditMode()
}
super.viewWillTransition(to: size, with: coordinator)
}

override func applyTheme() {
super.applyTheme()
Expand Down Expand Up @@ -194,6 +196,19 @@ class BookmarksPanel: SiteTableViewController, LibraryPanel {
}
}
}

fileprivate func enableEditMode() {
self.tableView.setEditing(true, animated: true)
self.navigationItem.leftBarButtonItem = self.newBarButtonItem
self.navigationItem.rightBarButtonItem = self.doneBarButtonItem
}

fileprivate func disableEditMode() {
self.tableView.setEditing(false, animated: true)
self.navigationItem.leftBarButtonItem = nil
self.navigationItem.rightBarButtonItem = self.editBarButtonItem
self.setupBackButtonGestureRecognizer()
}

fileprivate func setupBackButtonGestureRecognizer() {
if let backButtonView = self.backButtonView() {
Expand Down

0 comments on commit cedb7b1

Please sign in to comment.