forked from organicmaps/organicmaps
[ios] put user's shared category to "my" tab
This commit is contained in:
parent
a46c98aea6
commit
8f329ca2ac
3 changed files with 16 additions and 6 deletions
|
@ -226,7 +226,7 @@ CGFloat const kPinDiameter = 18.0f;
|
|||
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
auto const s = m_sections.at(indexPath.section);
|
||||
return !GetFramework().GetBookmarkManager().IsCategoryFromCatalog(m_categoryId) && s != Section::Info;
|
||||
return [[MWMBookmarksManager sharedManager] isCategoryEditable:m_categoryId] && s != Section::Info;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
|
@ -330,9 +330,8 @@ CGFloat const kPinDiameter = 18.0f;
|
|||
[MWMLocationManager addObserver:self];
|
||||
|
||||
// Display Edit button only if table is not empty
|
||||
auto & bm = GetFramework().GetBookmarkManager();
|
||||
if (bm.HasBmCategory(m_categoryId) && !bm.IsCategoryFromCatalog(m_categoryId)
|
||||
&& (bm.GetUserMarkIds(m_categoryId).size() + bm.GetTrackIds(m_categoryId).size()))
|
||||
if ([[MWMBookmarksManager sharedManager] isCategoryEditable:m_categoryId] &&
|
||||
[[MWMBookmarksManager sharedManager] isCategoryNotEmpty:m_categoryId])
|
||||
self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
||||
else
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
|
|
|
@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (BOOL)areBookmarksLoaded;
|
||||
- (void)loadBookmarks;
|
||||
|
||||
- (BOOL)isCategoryEditable:(MWMMarkGroupID)groupId;
|
||||
- (BOOL)isCategoryNotEmpty:(MWMMarkGroupID)groupId;
|
||||
- (MWMGroupIDCollection)groupsIdList;
|
||||
- (NSString *)getCategoryName:(MWMMarkGroupID)groupId;
|
||||
- (uint64_t)getCategoryMarksCount:(MWMMarkGroupID)groupId;
|
||||
|
|
|
@ -271,13 +271,22 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
|
||||
#pragma mark - Categories
|
||||
|
||||
- (BOOL)isCategoryEditable:(MWMMarkGroupID)groupId {
|
||||
return self.bm.IsEditableCategory(groupId);
|
||||
}
|
||||
|
||||
- (BOOL)isCategoryNotEmpty:(MWMMarkGroupID)groupId {
|
||||
return self.bm.HasBmCategory(groupId) &&
|
||||
(self.bm.GetUserMarkIds(groupId).size() + self.bm.GetTrackIds(groupId).size());
|
||||
}
|
||||
|
||||
- (MWMGroupIDCollection)groupsIdList
|
||||
{
|
||||
auto const & list = self.bm.GetBmGroupsIdList();
|
||||
NSMutableArray<NSNumber *> * collection = @[].mutableCopy;
|
||||
for (auto const & groupId : list)
|
||||
{
|
||||
if (!self.bm.IsCategoryFromCatalog(groupId))
|
||||
if ([self isCategoryEditable:groupId])
|
||||
[collection addObject:@(groupId)];
|
||||
}
|
||||
return collection.copy;
|
||||
|
@ -540,7 +549,7 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
|
|||
auto const & list = self.bm.GetBmGroupsIdList();
|
||||
for (auto const & groupId : list)
|
||||
{
|
||||
if ([self isCategoryFromCatalog:groupId])
|
||||
if (![self isCategoryEditable:groupId])
|
||||
{
|
||||
kml::CategoryData categoryData = self.bm.GetCategoryData(groupId);
|
||||
uint64_t bookmarksCount = [self getCategoryMarksCount:groupId] + [self getCategoryTracksCount:groupId];
|
||||
|
|
Loading…
Add table
Reference in a new issue