From 899ee1c5ee889774c6ca0ff10d70c8c02c94bebd Mon Sep 17 00:00:00 2001 From: "o.bolovintseva" Date: Tue, 27 Nov 2018 18:34:01 +0300 Subject: [PATCH] [ios] [mapsme-9024] disable sharing options in action sheet and list settings when category is empty --- .../Categories/BMCView/BMCViewController.swift | 6 ++++-- .../CategorySettingsViewController.swift | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift b/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift index 1e9c4c9a13..4b5eca9e9f 100644 --- a/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift +++ b/iphone/Maps/Bookmarks/Categories/BMCView/BMCViewController.swift @@ -132,9 +132,11 @@ final class BMCViewController: MWMViewController { self.shareCategoryFile(category: category, anchor: anchor) })) let share = L("sharing_options").capitalized - actionSheet.addAction(UIAlertAction(title: share, style: .default, handler: { _ in + let shareAction = UIAlertAction(title: share, style: .default, handler: { _ in self.shareCategory(category: category, anchor: anchor) - })) + }) + shareAction.isEnabled = MWMBookmarksManager.shared().isCategoryNotEmpty(category.identifier) + actionSheet.addAction(shareAction) let delete = L("delete_list").capitalized let deleteAction = UIAlertAction(title: delete, style: .destructive, handler: { [viewModel] _ in viewModel!.deleteCategory(category: category) diff --git a/iphone/Maps/Bookmarks/Categories/Category settings/CategorySettingsViewController.swift b/iphone/Maps/Bookmarks/Categories/Category settings/CategorySettingsViewController.swift index 32772a1eb2..fc1ee2223c 100644 --- a/iphone/Maps/Bookmarks/Categories/Category settings/CategorySettingsViewController.swift +++ b/iphone/Maps/Bookmarks/Categories/Category settings/CategorySettingsViewController.swift @@ -38,6 +38,16 @@ class CategorySettingsViewController: MWMTableViewController { navigationItem.rightBarButtonItem = saveButton } + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + switch section { + case 0: + // if there are no bookmarks in category, hide 'sharing options' row + return MWMBookmarksManager.shared().isCategoryNotEmpty(categoryId) ? 2 : 1 + default: + return 1 + } + } + func configureAccessStatus() { switch MWMBookmarksManager.shared().getCategoryAccessStatus(categoryId) { case .local: