From 650bf561c7930b7e5fb3169b6d57e6706677c1c3 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Fri, 11 Mar 2016 18:39:35 +0300 Subject: [PATCH] [ios] Added zoom to current country support. --- .../Welcome/MWMFirstLaunchController.mm | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Welcome/MWMFirstLaunchController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/Welcome/MWMFirstLaunchController.mm index df01bc0c1f..dfca7fe7db 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/Welcome/MWMFirstLaunchController.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Welcome/MWMFirstLaunchController.mm @@ -1,3 +1,5 @@ +#import "LocationManager.h" +#import "MapsAppDelegate.h" #import "MWMFirstLaunchController.h" #import "MWMPageController.h" @@ -46,6 +48,20 @@ void requestNotifications() } } +void zoomToCurrentPosition() +{ + dispatch_async(dispatch_get_main_queue(), ^ + { + LocationManager * locationManager = MapsAppDelegate.theApp.m_locationManager; + if (![locationManager lastLocationIsValid]) + return; + m2::PointD const centerPt = locationManager.lastLocation.mercator; + int const zoom = 13; + bool const isAnim = true; + GetFramework().GetDrapeEngine()->SetModelViewCenter(centerPt, zoom, isAnim); + }); +} + NSArray * pagesConfigBlocks = @[ [^(MWMFirstLaunchController * controller) { @@ -69,7 +85,6 @@ NSArray * pagesConfigBlocks = @[ } copy], [^(MWMFirstLaunchController * controller) { - requestLocation(); controller.image.image = [UIImage imageNamed:@"img_onboarding_notification"]; controller.alertTitle.text = L(@"first_launch_need_push_title"); controller.alertText.text = L(@"first_launch_need_push_text"); @@ -80,7 +95,6 @@ NSArray * pagesConfigBlocks = @[ } copy], [^(MWMFirstLaunchController * controller) { - requestNotifications(); controller.image.image = [UIImage imageNamed:@"ic_placeholder"]; controller.alertTitle.text = L(@"first_launch_congrats_title"); controller.alertText.text = L(@"first_launch_congrats_text"); @@ -104,10 +118,19 @@ NSArray * pagesConfigBlocks = @[ return pagesConfigBlocks; } +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + if (self.pageIndex == 2) + requestLocation(); + else if (self.pageIndex == 3) + requestNotifications(); +} + - (void)close { [self.pageController close]; - //TODO(igrechuhin): Add zoom to my position animation call. + zoomToCurrentPosition(); } #pragma mark - Properties