[ios] make the bookmarks GropSelection screen modal

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn 2024-03-01 14:30:30 +04:00 committed by Alexander Borsuk
parent 598b4a70d9
commit e679e5ceac
5 changed files with 31 additions and 40 deletions

View file

@ -371,8 +371,7 @@ extension BookmarksListPresenter: SelectBookmarkGroupViewControllerDelegate {
didSelect groupTitle: String,
groupId: MWMMarkGroupID) {
let nc = viewController.navigationController
defer { nc?.popViewController(animated: true) }
defer { viewController.dismiss(animated: true) }
guard groupId != bookmarkGroup.categoryId else { return }
@ -392,7 +391,9 @@ extension BookmarksListPresenter: SelectBookmarkGroupViewControllerDelegate {
} else {
// if there are no bookmarks or tracks in current group no need to show this group
// e.g. popping view controller 2 times
nc?.popViewController(animated: false)
if let rootNavigationController = viewController.presentingViewController as? UINavigationController {
rootNavigationController.popViewController(animated: false)
}
}
}
}

View file

@ -65,7 +65,8 @@ extension BookmarksListRouter: IBookmarksListRouter {
delegate: SelectBookmarkGroupViewControllerDelegate?) {
let groupViewController = SelectBookmarkGroupViewController(groupName: groupName, groupId: groupId)
groupViewController.delegate = delegate
mapViewController.navigationController?.pushViewController(groupViewController, animated: true)
let navigationController = UINavigationController(rootViewController: groupViewController)
mapViewController.present(navigationController, animated: true, completion: nil)
}
func editBookmark(bookmarkId: MWMMarkID, completion: @escaping (Bool) -> Void) {

View file

@ -144,9 +144,7 @@ final class EditBookmarkViewController: MWMTableViewController {
case .color:
openColorPicker()
case .bookmarkGroup:
let groupViewController = SelectBookmarkGroupViewController(groupName: bookmarkGroupTitle ?? "", groupId: bookmarkGroupId)
groupViewController.delegate = self
navigationController?.pushViewController(groupViewController, animated: true)
openGroupPicker()
default:
break
}
@ -173,11 +171,16 @@ final class EditBookmarkViewController: MWMTableViewController {
@objc private func openColorPicker() {
ColorPicker.shared.present(from: self, pickerType: .bookmarkColorPicker(bookmarkColor), completionHandler: { [weak self] color in
self?.bookmarkColor = BookmarkColor.bookmarkColor(from: color)
self?.tableView.reloadRows(at: [IndexPath(row: InfoSectionRows.color.rawValue, section: Sections.info.rawValue)],
with: .none)
self?.tableView.reloadRows(at: [IndexPath(row: InfoSectionRows.color.rawValue, section: Sections.info.rawValue)], with: .none)
})
}
private func openGroupPicker() {
let groupViewController = SelectBookmarkGroupViewController(groupName: bookmarkGroupTitle ?? "", groupId: bookmarkGroupId)
let navigationController = UINavigationController(rootViewController: groupViewController)
groupViewController.delegate = self
present(navigationController, animated: true, completion: nil)
}
}
extension EditBookmarkViewController: BookmarkTitleCellDelegate {
@ -212,23 +215,13 @@ extension EditBookmarkViewController: MWMButtonCellDelegate {
}
}
extension EditBookmarkViewController: BookmarkColorViewControllerDelegate {
func bookmarkColorViewController(_ viewController: BookmarkColorViewController, didSelect color: BookmarkColor) {
goBack()
bookmarkColor = color
tableView.reloadRows(at: [IndexPath(row: InfoSectionRows.color.rawValue, section: Sections.info.rawValue)],
with: .none)
}
}
extension EditBookmarkViewController: SelectBookmarkGroupViewControllerDelegate {
func bookmarkGroupViewController(_ viewController: SelectBookmarkGroupViewController,
didSelect groupTitle: String,
groupId: MWMMarkGroupID) {
goBack()
viewController.dismiss(animated: true)
bookmarkGroupTitle = groupTitle
bookmarkGroupId = groupId
tableView.reloadRows(at: [IndexPath(row: InfoSectionRows.bookmarkGroup.rawValue, section: Sections.info.rawValue)],
with: .none)
tableView.reloadRows(at: [IndexPath(row: InfoSectionRows.bookmarkGroup.rawValue, section: Sections.info.rawValue)], with: .none)
}
}

View file

@ -116,9 +116,7 @@ final class EditTrackViewController: MWMTableViewController {
case .color:
openColorPicker()
case .bookmarkGroup:
let groupViewController = SelectBookmarkGroupViewController(groupName: trackGroupTitle ?? "", groupId: trackGroupId)
groupViewController.delegate = self
navigationController?.pushViewController(groupViewController, animated: true)
openGroupPicker()
default:
break
}
@ -145,6 +143,12 @@ final class EditTrackViewController: MWMTableViewController {
})
}
private func openGroupPicker() {
let groupViewController = SelectBookmarkGroupViewController(groupName: trackGroupTitle ?? "", groupId: trackGroupId)
groupViewController.delegate = self
let navigationController = UINavigationController(rootViewController: groupViewController)
present(navigationController, animated: true, completion: nil)
}
}
extension EditTrackViewController: BookmarkTitleCellDelegate {
@ -164,7 +168,7 @@ extension EditTrackViewController: MWMButtonCellDelegate {
extension EditTrackViewController: BookmarkColorViewControllerDelegate {
func bookmarkColorViewController(_ viewController: BookmarkColorViewController, didSelect bookmarkColor: BookmarkColor) {
goBack()
viewController.dismiss(animated: true)
updateColor(bookmarkColor.color)
}
}
@ -174,24 +178,10 @@ extension EditTrackViewController: SelectBookmarkGroupViewControllerDelegate {
func bookmarkGroupViewController(_ viewController: SelectBookmarkGroupViewController,
didSelect groupTitle: String,
groupId: MWMMarkGroupID) {
goBack()
viewController.dismiss(animated: true)
trackGroupTitle = groupTitle
trackGroupId = groupId
tableView.reloadRows(at: [IndexPath(row: InfoSectionRows.bookmarkGroup.rawValue, section: Sections.info.rawValue)],
with: .none)
}
}
// MARK: - UIColorPickerViewControllerDelegate
extension EditTrackViewController: UIColorPickerViewControllerDelegate {
@available(iOS 14.0, *)
func colorPickerViewControllerDidFinish(_ viewController: UIColorPickerViewController) {
updateColor(viewController.selectedColor)
dismiss(animated: true, completion: nil)
}
@available(iOS 14.0, *)
func colorPickerViewControllerDidSelectColor(_ viewController: UIColorPickerViewController) {
updateColor(viewController.selectedColor)
}
}

View file

@ -24,6 +24,7 @@ final class SelectBookmarkGroupViewController: MWMTableViewController {
super.init(style: .grouped)
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@ -31,6 +32,11 @@ final class SelectBookmarkGroupViewController: MWMTableViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = L("bookmark_sets");
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancelButtonDidTap))
}
@objc private func cancelButtonDidTap() {
dismiss(animated: true, completion: nil)
}
override func numberOfSections(in tableView: UITableView) -> Int {