forked from organicmaps/organicmaps
[ios] disable editing for categories from catalog
This commit is contained in:
parent
811ac5bf81
commit
98f8e50eba
15 changed files with 51 additions and 74 deletions
|
@ -245,7 +245,7 @@ extension BMCViewController: UITableViewDelegate {
|
|||
case .permissions: return permissionsHeader
|
||||
case .categories:
|
||||
let categoriesHeader = tableView.dequeueReusableHeaderFooterView(BMCCategoriesHeader.self)
|
||||
categoriesHeader.isShowAll = viewModel.areAllCategoriesInvisible()
|
||||
categoriesHeader.isShowAll = !viewModel.areAllCategoriesInvisible()
|
||||
categoriesHeader.delegate = self
|
||||
return categoriesHeader
|
||||
case .actions: return actionsHeader
|
||||
|
@ -290,7 +290,7 @@ extension BMCViewController: BMCCategoryCellDelegate {
|
|||
func visibilityAction(category: BMCCategory) {
|
||||
viewModel.updateCategoryVisibility(category: category)
|
||||
let categoriesHeader = tableView.headerView(forSection: viewModel.sectionIndex(section: .categories)) as! BMCCategoriesHeader
|
||||
categoriesHeader.isShowAll = viewModel.areAllCategoriesInvisible()
|
||||
categoriesHeader.isShowAll = !viewModel.areAllCategoriesInvisible()
|
||||
}
|
||||
|
||||
func moreAction(category: BMCCategory, anchor: UIView) {
|
||||
|
@ -318,6 +318,6 @@ extension BMCViewController: BMCPermissionsHeaderDelegate {
|
|||
extension BMCViewController: BMCCategoriesHeaderDelegate {
|
||||
func visibilityAction(_ categoriesHeader: BMCCategoriesHeader) {
|
||||
viewModel.updateAllCategoriesVisibility(isShowAll: categoriesHeader.isShowAll)
|
||||
categoriesHeader.isShowAll = viewModel.areAllCategoriesInvisible()
|
||||
categoriesHeader.isShowAll = !viewModel.areAllCategoriesInvisible()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,12 +118,16 @@ extension BMCDefaultViewModel: BMCViewModel {
|
|||
}
|
||||
|
||||
func areAllCategoriesInvisible() -> Bool {
|
||||
return BM.areAllCategoriesInvisible()
|
||||
var result = true;
|
||||
categories.forEach { if !$0.isVisible { result = false } }
|
||||
return result
|
||||
}
|
||||
|
||||
func updateAllCategoriesVisibility(isShowAll: Bool) {
|
||||
categories.forEach { $0.isVisible = isShowAll }
|
||||
BM.setAllCategoriesVisible(isShowAll)
|
||||
categories.forEach {
|
||||
$0.isVisible = isShowAll
|
||||
BM.setCategory($0.identifier, isVisible: isShowAll)
|
||||
}
|
||||
}
|
||||
|
||||
func updateCategoryVisibility(category: BMCCategory) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
}
|
||||
|
||||
@property (copy, nonatomic) NSString * category;
|
||||
@property (copy, nonatomic) MWMGroupIDCollection groupIds;
|
||||
@property (weak, nonatomic) id<MWMSelectSetDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
@ -36,6 +37,13 @@
|
|||
NSAssert(self.category, @"Category can't be nil!");
|
||||
NSAssert(self.delegate, @"Delegate can't be nil!");
|
||||
self.title = L(@"bookmark_sets");
|
||||
[self reloadData];
|
||||
|
||||
}
|
||||
|
||||
- (void)reloadData {
|
||||
self.groupIds = [MWMBookmarksManager groupsIdList];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
|
@ -49,7 +57,7 @@
|
|||
if (section == 0)
|
||||
return 1;
|
||||
|
||||
return GetFramework().GetBookmarkManager().GetBmGroupsIdList().size();
|
||||
return self.groupIds.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
|
@ -64,7 +72,7 @@
|
|||
else
|
||||
{
|
||||
auto & bmManager = GetFramework().GetBookmarkManager();
|
||||
auto categoryId = bmManager.GetBmGroupsIdList()[indexPath.row];
|
||||
auto categoryId = [self.groupIds[indexPath.row] unsignedLongLongValue];
|
||||
if (bmManager.HasBmCategory(categoryId))
|
||||
cell.textLabel.text = @(bmManager.GetCategoryName(categoryId).c_str());
|
||||
|
||||
|
@ -80,7 +88,7 @@
|
|||
{
|
||||
m_categoryId = categoryId;
|
||||
self.category = @(GetFramework().GetBookmarkManager().GetCategoryName(categoryId).c_str());
|
||||
[self.tableView reloadData];
|
||||
[self reloadData];
|
||||
[self.delegate didSelectCategory:self.category withCategoryId:categoryId];
|
||||
}
|
||||
|
||||
|
@ -104,7 +112,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
auto categoryId = GetFramework().GetBookmarkManager().GetBmGroupsIdList()[indexPath.row];
|
||||
auto categoryId = [self.groupIds[indexPath.row] unsignedLongLongValue];;
|
||||
[self moveBookmarkToSetWithCategoryId:categoryId];
|
||||
[self.delegate didSelectCategory:self.category withCategoryId:categoryId];
|
||||
[self backTap];
|
||||
|
|
|
@ -112,6 +112,17 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setEnabled:(BOOL)enabled {
|
||||
[super setEnabled:enabled];
|
||||
if (!enabled) {
|
||||
self.tintColor = [UIColor lightGrayColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setDefaultTintColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setDefaultTintColor
|
||||
{
|
||||
switch (self.coloring)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
+ (void)setCategory:(MWMMarkGroupID)groupId name:(NSString *)name;
|
||||
+ (BOOL)isCategoryVisible:(MWMMarkGroupID)groupId;
|
||||
+ (void)setCategory:(MWMMarkGroupID)groupId isVisible:(BOOL)isVisible;
|
||||
+ (void)setAllCategoriesVisible:(BOOL)isVisible;
|
||||
+ (void)deleteCategory:(MWMMarkGroupID)groupId;
|
||||
|
||||
+ (void)deleteBookmark:(MWMMarkID)bookmarkId;
|
||||
|
@ -37,8 +36,6 @@
|
|||
+ (NSUInteger)filesCountForConversion;
|
||||
+ (void)convertAll;
|
||||
|
||||
+ (BOOL)areAllCategoriesInvisible;
|
||||
|
||||
+ (void)setNotificationsEnabled:(BOOL)enabled;
|
||||
+ (BOOL)areNotificationsEnabled;
|
||||
|
||||
|
|
|
@ -307,12 +307,6 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
GetFramework().GetBookmarkManager().GetEditSession().SetIsVisible(groupId, isVisible);
|
||||
}
|
||||
|
||||
+ (void)setAllCategoriesVisible:(BOOL)isVisible
|
||||
{
|
||||
GetFramework().GetBookmarkManager().SetAllCategoriesVisibility(BookmarkManager::CategoryFilterType::All,
|
||||
isVisible);
|
||||
}
|
||||
|
||||
+ (void)deleteCategory:(MWMMarkGroupID)groupId
|
||||
{
|
||||
GetFramework().GetBookmarkManager().GetEditSession().DeleteBmCategory(groupId);
|
||||
|
@ -479,11 +473,6 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
[[UIViewController topViewController] presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
+ (BOOL)areAllCategoriesInvisible
|
||||
{
|
||||
return GetFramework().GetBookmarkManager().AreAllCategoriesInvisible(BookmarkManager::CategoryFilterType::All);
|
||||
}
|
||||
|
||||
+ (void)setNotificationsEnabled:(BOOL)enabled
|
||||
{
|
||||
GetFramework().GetBookmarkManager().SetNotificationsEnabled(enabled);
|
||||
|
@ -496,7 +485,7 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
|
||||
+ (NSURL * _Nullable )catalogFrontendUrl
|
||||
{
|
||||
NSString *urlString = @(GetFramework().GetBookmarkManager().GetCatalogFrontendUrl().c_str());
|
||||
NSString *urlString = @(GetFramework().GetBookmarkManager().GetCatalog().GetFrontendUrl().c_str());
|
||||
return urlString ? [NSURL URLWithString:urlString] : nil;
|
||||
}
|
||||
|
||||
|
|
|
@ -223,6 +223,7 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d
|
|||
- (NSString *)bookmarkCategory;
|
||||
- (kml::MarkId)bookmarkId;
|
||||
- (kml::MarkGroupId)bookmarkCategoryId;
|
||||
- (BOOL)isFromCatalog;
|
||||
|
||||
// Local Ads
|
||||
- (NSString *)localAdsURL;
|
||||
|
|
|
@ -736,6 +736,10 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS";
|
|||
return m_info.GetBookmarkCategoryId();
|
||||
}
|
||||
|
||||
- (BOOL)isFromCatalog {
|
||||
return self.isBookmark && [MWMBookmarksManager isCategoryFromCatalog:self.bookmarkCategoryId];
|
||||
}
|
||||
|
||||
#pragma mark - Local Ads
|
||||
- (NSString *)localAdsURL { return @(m_info.GetLocalAdsUrl().c_str()); }
|
||||
- (void)logLocalAdsEvent:(local_ads::EventType)type
|
||||
|
|
|
@ -31,7 +31,8 @@ NSString * titleForButton(EButton type, int partnerIndex, BOOL isSelected);
|
|||
+ (MWMActionBarButton *)buttonWithDelegate:(id<MWMActionBarButtonDelegate>)delegate
|
||||
buttonType:(EButton)type
|
||||
partnerIndex:(int)partnerIndex
|
||||
isSelected:(BOOL)isSelected;
|
||||
isSelected:(BOOL)isSelected
|
||||
isDisabled:(BOOL)isDisabled;
|
||||
|
||||
- (EButton)type;
|
||||
- (MWMCircularProgress *)mapDownloadProgress;
|
||||
|
|
|
@ -73,7 +73,7 @@ UIColor * backgroundColorForPartner(int partnerIndex)
|
|||
|
||||
@implementation MWMActionBarButton
|
||||
|
||||
- (void)configButton:(BOOL)isSelected
|
||||
- (void)configButton:(BOOL)isSelected disabled:(BOOL)isDisabled
|
||||
{
|
||||
self.label.text = titleForButton(self.type, self.partnerIndex, isSelected);
|
||||
self.extraBackground.hidden = YES;
|
||||
|
@ -157,19 +157,21 @@ UIColor * backgroundColorForPartner(int partnerIndex)
|
|||
self.backgroundColor = backgroundColorForPartner(self.partnerIndex);
|
||||
break;
|
||||
}
|
||||
self.button.enabled = !isDisabled;
|
||||
}
|
||||
|
||||
+ (MWMActionBarButton *)buttonWithDelegate:(id<MWMActionBarButtonDelegate>)delegate
|
||||
buttonType:(EButton)type
|
||||
partnerIndex:(int)partnerIndex
|
||||
isSelected:(BOOL)isSelected
|
||||
isDisabled:(BOOL)isDisabled
|
||||
{
|
||||
MWMActionBarButton * button =
|
||||
[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil].firstObject;
|
||||
button.delegate = delegate;
|
||||
button.type = type;
|
||||
button.partnerIndex = partnerIndex;
|
||||
[button configButton:isSelected];
|
||||
[button configButton:isSelected disabled:isDisabled];
|
||||
return button;
|
||||
}
|
||||
|
||||
|
@ -201,6 +203,7 @@ UIColor * backgroundColorForPartner(int partnerIndex)
|
|||
[btn setImage:[UIImage imageNamed:@"ic_bookmarks_off"] forState:UIControlStateNormal];
|
||||
[btn setImage:[UIImage imageNamed:@"ic_bookmarks_on"] forState:UIControlStateSelected];
|
||||
[btn setImage:[UIImage imageNamed:@"ic_bookmarks_on"] forState:UIControlStateHighlighted];
|
||||
[btn setImage:[UIImage imageNamed:@"ic_bookmarks_on"] forState:UIControlStateDisabled];
|
||||
|
||||
[self setBookmarkSelected:isSelected];
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
@protocol MWMActionBarSharedData<NSObject>
|
||||
|
||||
- (BOOL)isBookmark;
|
||||
- (BOOL)isFromCatalog;
|
||||
- (BOOL)isOpentable;
|
||||
- (BOOL)isPartner;
|
||||
- (BOOL)isBooking;
|
||||
|
|
|
@ -130,10 +130,12 @@
|
|||
for (auto const buttonType : m_visibleButtons)
|
||||
{
|
||||
auto const isSelected = (buttonType == EButton::Bookmark ? [data isBookmark] : NO);
|
||||
auto const isDisabled = (buttonType == EButton::Bookmark && data.isFromCatalog);
|
||||
auto button = [MWMActionBarButton buttonWithDelegate:self
|
||||
buttonType:buttonType
|
||||
partnerIndex:partnerIndex
|
||||
isSelected:isSelected];
|
||||
isSelected:isSelected
|
||||
isDisabled:isDisabled];
|
||||
[self.barButtons addArrangedSubview:button];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
return 0;
|
||||
switch (data.sections[section])
|
||||
{
|
||||
case Sections::Bookmark: return 1;
|
||||
case Sections::Bookmark: return data.isFromCatalog ? 0 : 1;
|
||||
case Sections::Preview: return data.previewRows.size();
|
||||
case Sections::SpecialProjects: return data.specialProjectRows.size();
|
||||
case Sections::Metainfo: return data.metainfoRows.size();
|
||||
|
|
|
@ -1784,47 +1784,6 @@ bool BookmarkManager::IsUsedCategoryName(std::string const & name) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BookmarkManager::AreAllCategoriesVisible(CategoryFilterType const filter) const
|
||||
{
|
||||
return CheckVisibility(filter, true /* isVisible */);
|
||||
}
|
||||
|
||||
bool BookmarkManager::AreAllCategoriesInvisible(CategoryFilterType const filter) const
|
||||
{
|
||||
return CheckVisibility(filter, false /* isVisible */);
|
||||
}
|
||||
|
||||
bool BookmarkManager::CheckVisibility(BookmarkManager::CategoryFilterType const filter,
|
||||
bool isVisible) const
|
||||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
for (auto const & category : m_categories)
|
||||
{
|
||||
auto const fromCatalog = IsCategoryFromCatalog(category.first);
|
||||
if (!IsValidFilterType(filter, fromCatalog))
|
||||
continue;
|
||||
if (category.second->IsVisible() != isVisible)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BookmarkManager::SetAllCategoriesVisibility(BookmarkManager::CategoryFilterType const filter,
|
||||
bool visible)
|
||||
{
|
||||
CHECK_THREAD_CHECKER(m_threadChecker, ());
|
||||
auto session = GetEditSession();
|
||||
|
||||
for (auto & c : m_categories)
|
||||
{
|
||||
auto const fromCatalog = IsCategoryFromCatalog(c.first);
|
||||
if (!IsValidFilterType(filter, fromCatalog))
|
||||
continue;
|
||||
c.second->SetIsVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
bool BookmarkManager::CanConvert() const
|
||||
{
|
||||
// The conversion available only after successful migration.
|
||||
|
|
|
@ -258,9 +258,6 @@ public:
|
|||
bool IsEditableCategory(kml::MarkGroupId groupId) const;
|
||||
|
||||
bool IsUsedCategoryName(std::string const & name) const;
|
||||
bool AreAllCategoriesVisible(CategoryFilterType const filter) const;
|
||||
bool AreAllCategoriesInvisible(CategoryFilterType const filter) const;
|
||||
void SetAllCategoriesVisibility(CategoryFilterType const filter, bool visible);
|
||||
|
||||
// Return number of files for the conversion to the binary format.
|
||||
size_t GetKmlFilesCountForConversion() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue