[iOS] add download routes button to main menu

This commit is contained in:
Aleksey Belouosv 2018-07-27 16:05:33 +03:00 committed by Aleksey Belousov
parent 6478b53098
commit 8cdc483113
10 changed files with 88 additions and 19 deletions

View file

@ -26,6 +26,8 @@
- (void)openBookmarkEditorWithData:(MWMPlacePageData *)data;
- (void)showUGCAuth;
- (void)showBookmarksLoadedAlert:(UInt64)categoryId;
- (void)openCatalogAnimated:(BOOL)animated;
- (void)openCatalogDeeplink:(NSURL * _Nullable)deeplinkUrl animated:(BOOL)animated;
- (void)setPlacePageTopBound:(CGFloat)bound;

View file

@ -444,6 +444,27 @@ BOOL gIsFirstMyPositionMode = YES;
[[MWMToast toastWithText:L(@"bookmarks_webview_success_toast")] show];
}
- (void)openCatalogAnimated:(BOOL)animated
{
[self openCatalogDeeplink:nil animated:animated];
}
- (void)openCatalogDeeplink:(NSURL *)deeplinkUrl animated:(BOOL)animated
{
[self.navigationController popToRootViewControllerAnimated:NO];
auto bookmarks = [[MWMBookmarksTabViewController alloc] init];
bookmarks.activeTab = ActiveTabCatalog;
MWMCatalogWebViewController *catalog;
if (deeplinkUrl)
catalog = [[MWMCatalogWebViewController alloc] init:deeplinkUrl];
else
catalog = [[MWMCatalogWebViewController alloc] init];
NSMutableArray<UIViewController *> * controllers = [self.navigationController.viewControllers mutableCopy];
[controllers addObjectsFromArray:@[bookmarks, catalog]];
[self.navigationController setViewControllers:controllers animated:animated];
}
- (void)processMyPositionStateModeEvent:(MWMMyPositionMode)mode
{
[MWMLocationManager setMyPositionMode:mode];

View file

@ -215,20 +215,9 @@ using namespace osm_auth_ios;
{
case ParsedMapApi::ParsingResult::Incorrect:
if ([m_mwmURL rangeOfString:@"catalog"].location != NSNotFound)
{
auto navController = self.mapViewController.navigationController;
[navController popToRootViewControllerAnimated:NO];
auto bookmarks = [[MWMBookmarksTabViewController alloc] init];
bookmarks.activeTab = ActiveTabCatalog;
auto url = [[NSURL alloc] initWithString:m_mwmURL];
auto catalog = [[MWMCatalogWebViewController alloc] init:url];
[navController pushViewController:bookmarks animated:NO];
[navController pushViewController:catalog animated:NO];
}
[self.mapViewController openCatalogDeeplink:[[NSURL alloc] initWithString:m_mwmURL] animated:NO];
else
{
LOG(LWARNING, ("Incorrect parsing result for url:", url));
}
break;
case ParsedMapApi::ParsingResult::Route:
{

View file

@ -0,0 +1,26 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_menu_routes.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_menu_routes@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_menu_routes@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 988 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -8,6 +8,9 @@
badgeCount:(NSUInteger)badgeCount
isEnabled:(BOOL)isEnabled;
- (void)configurePromoWithImageName:(NSString *)imageName
label:(NSString *)label;
@end
@interface MWMBottomMenuCollectionViewPortraitCell : MWMBottomMenuCollectionViewCell

View file

@ -12,6 +12,7 @@
@property(nonatomic, readwrite) BOOL isEnabled;
@property(nonatomic) BOOL isWideMenu;
@property(nonatomic) BOOL promo;
@end
@ -38,6 +39,20 @@
self.isEnabled = isEnabled;
self.icon.mwm_coloring = isEnabled ? MWMImageColoringBlack : MWMImageColoringGray;
self.label.textColor = isEnabled ? [UIColor blackPrimaryText] : [UIColor blackHintText];
self.promo = NO;
}
- (void)configurePromoWithImageName:(NSString *)imageName
label:(NSString *)label
{
self.icon.image = [UIImage imageNamed:imageName];
self.label.text = label;
self.icon.mwm_coloring = MWMImageColoringBlue;
self.label.textColor = [UIColor linkBlue];
self.badgeBackground.hidden = YES;
self.badgeCount.hidden = YES;
self.isEnabled = YES;
self.promo = YES;
}
- (void)setHighlighted:(BOOL)highlighted
@ -46,7 +61,10 @@
return;
[super setHighlighted:highlighted];
self.label.textColor = highlighted ? [UIColor blackHintText] : [UIColor blackPrimaryText];
if (self.promo)
self.label.textColor = highlighted ? [UIColor linkBlueHighlighted] : [UIColor linkBlue];
else
self.label.textColor = highlighted ? [UIColor blackHintText] : [UIColor blackPrimaryText];
}
- (void)setSelected:(BOOL)selected

View file

@ -27,7 +27,8 @@ CGFloat constexpr kLayoutThreshold = 420.0;
typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
MWMBottomMenuViewCellAddPlace,
MWMBottomMenuViewCellDownload,
MWMBottomMenuViewCellDownloadRoutes,
MWMBottomMenuViewCellDownloadMaps,
MWMBottomMenuViewCellSettings,
MWMBottomMenuViewCellShare,
MWMBottomMenuViewCellCount
@ -175,14 +176,15 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
isEnabled:isEnabled];
break;
}
case MWMBottomMenuViewCellDownload:
{
case MWMBottomMenuViewCellDownloadRoutes:
[cell configurePromoWithImageName:@"ic_menu_routes" label:L(@"download_routes")];
break;
case MWMBottomMenuViewCellDownloadMaps:
[cell configureWithImageName:@"ic_menu_download"
label:L(@"download_maps")
badgeCount:[[MapsAppDelegate theApp] badgeNumber]
isEnabled:YES];
}
break;
break;
case MWMBottomMenuViewCellSettings:
[cell configureWithImageName:@"ic_menu_settings"
label:L(@"settings")
@ -211,7 +213,8 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
switch (indexPath.item)
{
case MWMBottomMenuViewCellAddPlace: [self menuActionAddPlace]; break;
case MWMBottomMenuViewCellDownload: [self menuActionDownloadMaps]; break;
case MWMBottomMenuViewCellDownloadRoutes: [self menuActionDownloadRoutes]; break;
case MWMBottomMenuViewCellDownloadMaps: [self menuActionDownloadMaps]; break;
case MWMBottomMenuViewCellSettings: [self menuActionOpenSettings]; break;
case MWMBottomMenuViewCellShare: [self menuActionShareLocation]; break;
}
@ -227,6 +230,13 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) {
[self.delegate addPlace:NO hasPoint:NO point:m2::PointD()];
}
- (void)menuActionDownloadRoutes
{
[Statistics logEvent:kStatMenu withParameters:@{kStatButton : kStatDownloadRoute}];
self.state = self.restoreState;
[self.mapViewController openCatalogAnimated:YES];
}
- (void)menuActionDownloadMaps
{
[Statistics logEvent:kStatMenu withParameters:@{kStatButton : kStatDownloadMaps}];