[bookmarks][iOS] Enable sort and search for categories from the catalog.

This commit is contained in:
Daria Volvenkova 2019-08-30 19:40:34 +03:00 committed by Aleksey Belousov
parent df291a5ea5
commit 065d73b057
6 changed files with 59 additions and 17 deletions

View file

@ -60,9 +60,13 @@ using namespace std;
@property(weak, nonatomic) IBOutlet UIBarButtonItem * viewOnMapItem;
@property(nonatomic) UIActivityIndicatorView *sortSpinner;
@property(weak, nonatomic) IBOutlet UIBarButtonItem *sortItem;
@property(weak, nonatomic) IBOutlet UIBarButtonItem *sortSpinnerItem;
@property(weak, nonatomic) IBOutlet UIBarButtonItem *sortDownloadedItem;
@property(weak, nonatomic) IBOutlet UIBarButtonItem *sortDownloadedSpinnerItem;
@property(weak, nonatomic) IBOutlet UIBarButtonItem * moreItem;
@end
@ -184,13 +188,22 @@ using namespace std;
}
}
- (void)enableSortButton:(BOOL)enable
{
if ([self isEditable])
self.sortItem.enabled = enable;
else
self.sortDownloadedSpinnerItem.enabled = enable;
}
- (void)updateControlsVisibility {
if ([self isEditable] && [[MWMBookmarksManager sharedManager] isCategoryNotEmpty:self.categoryId]) {
self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.sortItem.enabled = YES;
if ([[MWMBookmarksManager sharedManager] isCategoryNotEmpty:self.categoryId]) {
if ([self isEditable])
self.navigationItem.rightBarButtonItem = self.editButtonItem;
[self enableSortButton:YES];
} else {
self.navigationItem.rightBarButtonItem = nil;
self.sortItem.enabled = NO;
[self enableSortButton:NO];
}
}
@ -216,12 +229,18 @@ using namespace std;
[self.moreItem setTitleTextAttributes:moreTitleAttributes forState:UIControlStateNormal];
[self.sortItem setTitleTextAttributes:regularTitleAttributes forState:UIControlStateNormal];
[self.sortDownloadedItem setTitleTextAttributes:regularTitleAttributes forState:UIControlStateNormal];
[self.viewOnMapItem setTitleTextAttributes:regularTitleAttributes forState:UIControlStateNormal];
self.moreItem.title = L(@"placepage_more_button");
self.sortItem.title = L(@"sort");
self.sortSpinnerItem.customView = self.sortSpinner;
self.viewOnMapItem.title = L(@"search_show_on_map");
self.sortDownloadedItem.title = L(@"sort");
if ([self isEditable])
self.sortSpinnerItem.customView = self.sortSpinner;
else
self.sortDownloadedSpinnerItem.customView = self.sortSpinner;
self.viewOnMapItem.title = L(@"view_on_map_bookmarks");
self.myCategoryToolbar.barTintColor = [UIColor white];
self.downloadedCategoryToolbar.barTintColor = [UIColor white];
@ -234,10 +253,10 @@ using namespace std;
- (void)viewWillAppear:(BOOL)animated {
[MWMLocationManager addObserver:self];
BOOL searchAllowed = NO;
BOOL searchAllowed = [[MWMBookmarksManager sharedManager] isCategoryNotEmpty:self.categoryId] &&
[[MWMBookmarksManager sharedManager] isSearchAllowed:self.categoryId];
if ([self isEditable]) {
if ([[MWMBookmarksManager sharedManager] isCategoryNotEmpty:self.categoryId])
searchAllowed = YES;
self.myCategoryToolbar.hidden = NO;
self.downloadedCategoryToolbar.hidden = YES;
} else {
@ -390,7 +409,8 @@ using namespace std;
[actionSheet addAction:[UIAlertAction actionWithTitle:L(@"cancel") style:UIAlertActionStyleCancel handler:nil]];
actionSheet.popoverPresentationController.barButtonItem = self.sortItem;
actionSheet.popoverPresentationController.barButtonItem = [self isEditable] ? self.sortItem
: self.sortDownloadedItem;
[self presentViewController:actionSheet
animated:YES
completion:^{
@ -441,7 +461,7 @@ using namespace std;
return;
[self showSortSpinner:NO];
self.sortItem.enabled = YES;
[self enableSortButton:YES];
if (status == BookmarkManager::SortParams::Status::Completed) {
[self setSortedSections:sortedBlocks];
@ -450,8 +470,8 @@ using namespace std;
};
[self showSortSpinner:YES];
self.sortItem.enabled = NO;
[self enableSortButton:NO];
bm.GetSortedCategory(sortParams);
}

View file

@ -20,6 +20,8 @@
<outlet property="noResultsContainer" destination="eGH-Rr-EJq" id="vaj-qX-IeS"/>
<outlet property="searchBar" destination="CQZ-YM-Mk4" id="1DX-m0-Vok"/>
<outlet property="showSearchBar" destination="GJx-FV-8CF" id="PkO-sS-pSv"/>
<outlet property="sortDownloadedItem" destination="q9W-1k-FcF" id="8cR-4a-7vi"/>
<outlet property="sortDownloadedSpinnerItem" destination="lqj-ym-l6h" id="eRf-zs-1mB"/>
<outlet property="sortItem" destination="U4v-rd-kcf" id="vlw-yQ-uUA"/>
<outlet property="sortSpinnerItem" destination="bgr-Fc-kub" id="7q1-gI-Wxt"/>
<outlet property="statusBarBackground" destination="S4A-UM-s8p" id="4DY-Of-VqX"/>
@ -58,13 +60,20 @@
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lox-EJ-BTW">
<rect key="frame" x="0.0" y="623" width="375" height="44"/>
<items>
<barButtonItem width="8" style="plain" systemItem="fixedSpace" id="Nx8-rO-Gnv"/>
<barButtonItem title="Sort" style="plain" id="q9W-1k-FcF">
<connections>
<action selector="onSort:" destination="-1" id="AG9-d5-JNZ"/>
</connections>
</barButtonItem>
<barButtonItem width="16" style="plain" id="lqj-ym-l6h"/>
<barButtonItem style="plain" systemItem="flexibleSpace" id="mgA-WK-Be8"/>
<barButtonItem title="View on map" id="zDI-L0-Fjj">
<connections>
<action selector="onViewOnMap:" destination="-1" id="93e-aP-Lza"/>
</connections>
</barButtonItem>
<barButtonItem style="plain" systemItem="flexibleSpace" id="tlq-gn-Jdq"/>
<barButtonItem width="8" style="plain" systemItem="fixedSpace" id="lFC-24-CEh"/>
</items>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>
@ -73,7 +82,7 @@
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uNd-fM-YVD">
<rect key="frame" x="0.0" y="623" width="375" height="44"/>
<items>
<barButtonItem width="16" style="plain" systemItem="fixedSpace" id="jsx-WU-dhT"/>
<barButtonItem width="8" style="plain" systemItem="fixedSpace" id="jsx-WU-dhT"/>
<barButtonItem title="Sort" style="plain" id="U4v-rd-kcf">
<connections>
<action selector="onSort:" destination="-1" id="Nvj-G6-K6X"/>
@ -86,7 +95,7 @@
<action selector="onMore:" destination="-1" id="lBH-EV-C9v"/>
</connections>
</barButtonItem>
<barButtonItem width="16" style="plain" systemItem="fixedSpace" id="YAt-eE-x2I"/>
<barButtonItem width="8" style="plain" systemItem="fixedSpace" id="YAt-eE-x2I"/>
</items>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="white"/>

View file

@ -25,6 +25,7 @@ typedef void (^PingCompletionBlock)(BOOL success);
- (BOOL)isCategoryEditable:(MWMMarkGroupID)groupId;
- (BOOL)isCategoryNotEmpty:(MWMMarkGroupID)groupId;
- (BOOL)isSearchAllowed:(MWMMarkGroupID)groupId;
- (NSString *)getCategoryName:(MWMMarkGroupID)groupId;
- (uint64_t)getCategoryMarksCount:(MWMMarkGroupID)groupId;
- (uint64_t)getCategoryTracksCount:(MWMMarkGroupID)groupId;

View file

@ -288,6 +288,10 @@ NSString * const CloudErrorToString(Cloud::SynchronizationResult result)
(self.bm.GetUserMarkIds(groupId).size() + self.bm.GetTrackIds(groupId).size());
}
- (BOOL)isSearchAllowed:(MWMMarkGroupID)groupId {
return self.bm.IsSearchAllowed(groupId);
}
- (MWMGroupIDCollection)groupsIdList
{
auto const & list = self.bm.GetBmGroupsIdList();

View file

@ -1540,6 +1540,13 @@ bool BookmarkManager::IsVisible(kml::MarkGroupId groupId) const
return GetGroup(groupId)->IsVisible();
}
bool BookmarkManager::IsSearchAllowed(kml::MarkGroupId groupId) const
{
// TODO(@darina) Implement.
CHECK_THREAD_CHECKER(m_threadChecker, ());
return true;
}
void BookmarkManager::SetDrapeEngine(ref_ptr<df::DrapeEngine> engine)
{
m_drapeEngine.Set(engine);

View file

@ -241,7 +241,8 @@ public:
void ResetLastSortingType(kml::MarkGroupId groupId);
bool IsVisible(kml::MarkGroupId groupId) const;
bool IsSearchAllowed(kml::MarkGroupId groupId) const;
kml::MarkGroupId CreateBookmarkCategory(kml::CategoryData && data, bool autoSave = true);
kml::MarkGroupId CreateBookmarkCategory(std::string const & name, bool autoSave = true);