diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h index a759a69fcb..7923215910 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h @@ -33,8 +33,8 @@ typedef void (^CloseAlertCompletion)(); - (void)presentnoWiFiAlertWithName:(nonnull NSString *)name downloadBlock:(nullable RightButtonAction)block; - (void)closeAlertWithCompletion:(nullable CloseAlertCompletion)completion; -- (nonnull instancetype)init __attribute__((unavailable("-init isn't available, call -initWithViewController: instead!"))); -+ (nonnull instancetype)new __attribute__((unavailable("+new isn't available, call -initWithViewController: instead!"))); -- (nonnull instancetype)initWithCoder:(nonnull NSCoder *)aDecoder __attribute__((unavailable("-initWithCoder: isn't available, call -initWithViewController: instead!"))); -- (nonnull instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil __attribute__((unavailable("-initWithNibName:bundle: isn't available, call -initWithViewController: instead!"))); +- (nonnull instancetype)init __attribute__((unavailable("call -initWithViewController: instead!"))); ++ (nonnull instancetype)new __attribute__((unavailable("call -initWithViewController: instead!"))); +- (nonnull instancetype)initWithCoder:(nonnull NSCoder *)aDecoder __attribute__((unavailable("call -initWithViewController: instead!"))); +- (nonnull instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil __attribute__((unavailable("call -initWithViewController: instead!"))); @end diff --git a/iphone/Maps/Classes/CustomViews/DownloadMapRequest/MWMDownloadMapRequest.h b/iphone/Maps/Classes/CustomViews/DownloadMapRequest/MWMDownloadMapRequest.h index 65b70dbb9f..bf44c018b4 100644 --- a/iphone/Maps/Classes/CustomViews/DownloadMapRequest/MWMDownloadMapRequest.h +++ b/iphone/Maps/Classes/CustomViews/DownloadMapRequest/MWMDownloadMapRequest.h @@ -23,7 +23,8 @@ NS_ENUM(NSUInteger, MWMDownloadMapRequestState) @interface MWMDownloadMapRequest : NSObject - (nonnull instancetype)init __attribute__((unavailable("init is not available"))); -- (nonnull instancetype)initWithParentView:(nonnull UIView *)parentView delegate:(nonnull id )delegate; +- (nonnull instancetype)initWithParentView:(nonnull UIView *)parentView + delegate:(nonnull id )delegate; - (void)showRequest; diff --git a/iphone/Maps/Classes/CustomViews/DownloadMapRequest/MWMDownloadMapRequest.mm b/iphone/Maps/Classes/CustomViews/DownloadMapRequest/MWMDownloadMapRequest.mm index cde86cfb0b..21961a535d 100644 --- a/iphone/Maps/Classes/CustomViews/DownloadMapRequest/MWMDownloadMapRequest.mm +++ b/iphone/Maps/Classes/CustomViews/DownloadMapRequest/MWMDownloadMapRequest.mm @@ -37,7 +37,8 @@ @implementation MWMDownloadMapRequest -- (nonnull instancetype)initWithParentView:(nonnull UIView *)parentView delegate:(nonnull id )delegate +- (nonnull instancetype)initWithParentView:(nonnull UIView *)parentView + delegate:(nonnull id )delegate { self = [super init]; if (self) @@ -76,11 +77,13 @@ if (self.currentCountryIndex.IsValid()) { - self.mapTitleLabel.text = [NSString stringWithUTF8String:activeMapLayout.GetFormatedCountryName(self.currentCountryIndex).c_str()]; + self.mapTitleLabel.text = @(activeMapLayout.GetFormatedCountryName(self.currentCountryIndex).c_str()); LocalAndRemoteSizeT const sizes = activeMapLayout.GetRemoteCountrySizes(self.currentCountryIndex); self.mapSize = formattedSize(sizes.first); self.mapAndRouteSize = formattedSize(sizes.first + sizes.second); - [self.downloadMapButton setTitle:[NSString stringWithFormat:@"%@ (%@)", L(@"downloader_download_map"), self.mapAndRouteSize] forState:UIControlStateNormal]; + [self.downloadMapButton setTitle:[NSString stringWithFormat:@"%@ (%@)", + L(@"downloader_download_map"), self.mapAndRouteSize] + forState:UIControlStateNormal]; [self updateState:MWMDownloadMapRequestStateRequestLocation]; } else @@ -129,7 +132,10 @@ - (IBAction)downloadRoutesTouchUpInside:(nonnull UIButton *)sender { sender.selected = !sender.selected; - [self.downloadMapButton setTitle:[NSString stringWithFormat:@"%@ (%@)", L(@"downloader_download_map"), sender.selected ? self.mapAndRouteSize : self.mapSize] forState:UIControlStateNormal]; + [self.downloadMapButton setTitle:[NSString stringWithFormat:@"%@ (%@)", + L(@"downloader_download_map"), + sender.selected ? self.mapAndRouteSize : self.mapSize] + forState:UIControlStateNormal]; } - (IBAction)selectMapTouchUpInside:(nonnull UIButton *)sender diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBar.h b/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBar.h index ea49a11b89..0a4008b6e7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBar.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBar.h @@ -8,23 +8,17 @@ @class SearchView; -typedef NS_ENUM(NSUInteger, MWMAPIBarState) -{ - MWMAPIBarStateHidden, - MWMAPIBarStateVisible -}; - @protocol MWMAPIBarProtocol @property (nonnull, nonatomic) SearchView * searchView; -- (void)apiBarDidEnterState:(MWMAPIBarState)state; +- (void)apiBarBecameVisible:(BOOL)visible; @end @interface MWMAPIBar : NSObject -@property (nonatomic, readonly) MWMAPIBarState state; +@property (nonatomic, readonly) BOOL isVisible; @property (nonatomic, readonly) CGRect frame; - (nonnull instancetype)init __attribute__((unavailable("init is not available"))); diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBar.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBar.mm index bfe3a58d62..87cdf4616e 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBar.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBar.mm @@ -19,7 +19,7 @@ @property (nonatomic) IBOutlet UILabel * titleLabel; @property (weak, nonatomic) UIViewController * delegate; -@property (nonatomic) MWMAPIBarState state; +@property (nonatomic, setter = setVisible:) BOOL isVisible; @end @@ -45,7 +45,7 @@ [UIView animateWithDuration:0.2 animations:^ { self.rootView.targetY = 0.0; - self.state = MWMAPIBarStateVisible; + self.isVisible = YES; }]; } @@ -54,7 +54,7 @@ [UIView animateWithDuration:animated ? 0.2 : 0.0 animations:^ { self.rootView.targetY = -self.rootView.height; - self.state = MWMAPIBarStateHidden; + self.isVisible = NO; } completion:^(BOOL finished) { @@ -84,10 +84,10 @@ #pragma mark - Properties -- (void)setState:(MWMAPIBarState)state +- (void)setVisible:(BOOL)visible { - _state = state; - [self.delegate apiBarDidEnterState:state]; + _isVisible = visible; + [self.delegate apiBarBecameVisible:visible]; } - (CGRect)frame diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBarView.xib b/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBarView.xib index c489aa0dca..154920e33a 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBarView.xib +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/APIBar/MWMAPIBarView.xib @@ -22,7 +22,7 @@ - + @@ -83,6 +83,6 @@ - + diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm index d38b9dabe6..09bdcd2df7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm @@ -18,7 +18,8 @@ #import "MWMZoomButtons.h" #import "RouteState.h" -@interface MWMMapViewControlsManager () +@interface MWMMapViewControlsManager () @property (nonatomic) MWMZoomButtons * zoomButtons; @property (nonatomic) MWMLocationButton * locationButton; @@ -115,7 +116,7 @@ - (void)handleRoutingError { - [self.navigationManager handleError]; + self.navigationManager.state = MWMNavigationDashboardStateError; } - (void)buildRouteWithType:(enum routing::RouterType)type @@ -128,11 +129,8 @@ - (void)navigationDashBoardDidUpdate { CGFloat const topBound = self.topBound + self.navigationManager.height; - [UIView animateWithDuration:0.2 animations:^ - { - [self.zoomButtons setTopBound:topBound]; - [self.placePageManager setTopBound:topBound]; - }]; + [self.zoomButtons setTopBound:topBound]; + [self.placePageManager setTopBound:topBound]; } - (void)didStartFollowing diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManagerDelegate.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManagerDelegate.h index 1c636d2fe0..643b9f6056 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManagerDelegate.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManagerDelegate.h @@ -10,4 +10,4 @@ - (void)sideMenuDidUpdateLayout; -@end \ No newline at end of file +@end diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.mm index 9b7c3eda8f..96beb4c092 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardEntity.mm @@ -11,6 +11,8 @@ #import "MWMNavigationDashboardEntity.h" #include "Framework.h" +#include "geometry/distance_on_sphere.hpp" +#include "platform/measurement_utils.hpp" @implementation MWMNavigationDashboardEntity @@ -36,15 +38,12 @@ if (f.GetRouter() == routing::RouterType::Pedestrian) { _isPedestrian = YES; - LocationManager * locationManager = [MapsAppDelegate theApp].m_locationManager; - double north = -1.0; - [locationManager getNorthRad:north]; string distance; - double azimut = -1.0; - CLLocationCoordinate2D const coordinate (locationManager.lastLocation.coordinate); - ms::LatLon const & latLon = info.m_pedestrianDirectionPos; - m2::PointD const point (MercatorBounds::LonToX(latLon.lon), MercatorBounds::LatToY(latLon.lat)); - f.GetDistanceAndAzimut(point, coordinate.latitude, coordinate.longitude, north, distance, azimut); + CLLocationCoordinate2D const & coordinate ([MapsAppDelegate theApp].m_locationManager.lastLocation.coordinate); + ms::LatLon const & directionPos = info.m_pedestrianDirectionPos; + //TODO: Not the best solution, but this solution is temporary and will be replaced in future + MeasurementUtils::FormatDistance(ms::DistanceOnEarth(coordinate.latitude, coordinate.longitude, + directionPos.lat, directionPos.lon), distance); istringstream is (distance); string dist; string units; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h index ec63fb9830..728b550de7 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.h @@ -7,6 +7,7 @@ // #import "LocationManager.h" +#import "MWMNavigationViewProtocol.h" #include "Framework.h" #include "platform/location.hpp" @@ -15,14 +16,14 @@ typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState) { MWMNavigationDashboardStateHidden, MWMNavigationDashboardStatePlanning, + MWMNavigationDashboardStateError, MWMNavigationDashboardStateReady, MWMNavigationDashboardStateNavigation }; -@protocol MWMNavigationDashboardManagerDelegate +@protocol MWMNavigationDashboardManagerProtocol - (void)buildRouteWithType:(enum routing::RouterType)type; -- (void)navigationDashBoardDidUpdate; - (void)didStartFollowing; - (void)didCancelRouting; - (void)updateStatusBarStyle; @@ -40,9 +41,8 @@ typedef NS_ENUM(NSUInteger, MWMNavigationDashboardState) - (instancetype)init __attribute__((unavailable("init is not available"))); -- (instancetype)initWithParentView:(UIView *)view delegate:(id)delegate; +- (instancetype)initWithParentView:(UIView *)view delegate:(id)delegate; - (void)setupDashboard:(location::FollowingInfo const &)info; -- (void)handleError; - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation; @end diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm index 8c3d9dae55..09274eefb1 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/MWMNavigationDashboardManager.mm @@ -25,14 +25,14 @@ @property (weak, nonatomic) MWMNavigationDashboard * navigationDashboard; @property (weak, nonatomic) UIView * ownerView; -@property (weak, nonatomic) id delegate; +@property (weak, nonatomic) id delegate; @property (nonatomic, readwrite) MWMNavigationDashboardEntity * entity; @end @implementation MWMNavigationDashboardManager -- (instancetype)initWithParentView:(UIView *)view delegate:(id)delegate +- (instancetype)initWithParentView:(UIView *)view delegate:(id)delegate { self = [super init]; if (self) @@ -44,10 +44,12 @@ [NSBundle.mainBundle loadNibNamed:@"MWMPortraitRoutePreview" owner:self options:nil]; [NSBundle.mainBundle loadNibNamed:@"MWMLandscapeRoutePreview" owner:self options:nil]; self.routePreview = isPortrait ? self.routePreviewPortrait : self.routePreviewLandscape; + self.routePreviewPortrait.delegate = self.routePreviewLandscape.delegate = delegate; [NSBundle.mainBundle loadNibNamed:@"MWMPortraitNavigationDashboard" owner:self options:nil]; [NSBundle.mainBundle loadNibNamed:@"MWMLandscapeNavigationDashboard" owner:self options:nil]; self.navigationDashboard = isPortrait ? self.navigationDashboardPortrait : self.navigationDashboardLandscape; + self.navigationDashboardPortrait.delegate = self.navigationDashboardLandscape.delegate = delegate; } return self; } @@ -56,7 +58,8 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { - BOOL const isPortrait = orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown; + BOOL const isPortrait = orientation == UIInterfaceOrientationPortrait || + orientation == UIInterfaceOrientationPortraitUpsideDown; MWMRoutePreview * routePreview = isPortrait ? self.routePreviewPortrait : self.routePreviewLandscape; if (self.routePreview.isVisible && ![routePreview isEqual:self.routePreview]) { @@ -65,7 +68,8 @@ } self.routePreview = routePreview; - MWMNavigationDashboard * navigationDashboard = isPortrait ? self.navigationDashboardPortrait : self.navigationDashboardLandscape; + MWMNavigationDashboard * navigationDashboard = isPortrait ? self.navigationDashboardPortrait : + self.navigationDashboardLandscape; if (self.navigationDashboard.isVisible && ![navigationDashboard isEqual:self.navigationDashboard]) { [self.navigationDashboard remove]; @@ -116,6 +120,7 @@ f.SetRouter(routing::RouterType::Vehicle); } f.CloseRouting(); + [self showStatePlanning]; [self.delegate buildRouteWithType:f.GetRouter()]; } @@ -182,7 +187,6 @@ { [self.routePreviewPortrait showGoButtonAnimated:show]; [self.routePreviewLandscape showGoButtonAnimated:show]; - [self.delegate navigationDashBoardDidUpdate]; } #pragma mark - Properties @@ -199,6 +203,10 @@ case MWMNavigationDashboardStatePlanning: [self showStatePlanning]; break; + case MWMNavigationDashboardStateError: + NSAssert(_state == MWMNavigationDashboardStatePlanning, @"Invalid state change"); + [self handleError]; + break; case MWMNavigationDashboardStateReady: NSAssert(_state == MWMNavigationDashboardStatePlanning, @"Invalid state change"); [self showStateReady]; @@ -209,13 +217,12 @@ } _state = state; [self.delegate updateStatusBarStyle]; - [self.delegate navigationDashBoardDidUpdate]; } - (void)setTopBound:(CGFloat)topBound { - _topBound = self.routePreviewLandscape.topBound = self.routePreviewPortrait.topBound = self.navigationDashboardLandscape.topBound = self.navigationDashboardPortrait.topBound = topBound; - [self.delegate navigationDashBoardDidUpdate]; + _topBound = self.routePreviewLandscape.topBound = self.routePreviewPortrait.topBound = + self.navigationDashboardLandscape.topBound = self.navigationDashboardPortrait.topBound = topBound; } - (CGFloat)height @@ -226,6 +233,7 @@ return 0.0; case MWMNavigationDashboardStatePlanning: case MWMNavigationDashboardStateReady: + case MWMNavigationDashboardStateError: return self.routePreview.visibleHeight; case MWMNavigationDashboardStateNavigation: return self.navigationDashboard.visibleHeight; @@ -234,6 +242,13 @@ #pragma mark - LocationObserver +- (void)onLocationUpdate:(const location::GpsInfo &)info +{ +// We don't need information about location update in this class, +// but in LocationObserver protocol this method is required +// since we don't want runtime overhead for introspection. +} + - (void)onCompassUpdate:(location::CompassInfo const &)info { auto & f = GetFramework(); @@ -249,9 +264,8 @@ if (!res.IsValid()) return; - ms::LatLon const dest (res.m_pedestrianDirectionPos); - CLLocationCoordinate2D const lastPosition (location.coordinate); - CGFloat const angle = ang::AngleTo(MercatorBounds::FromLatLon(lastPosition.latitude, lastPosition.longitude), MercatorBounds::FromLatLon(dest.lat, dest.lon)) + info.m_bearing; + CGFloat const angle = ang::AngleTo(ToMercator(location.coordinate), + ToMercator(res.m_pedestrianDirectionPos)) + info.m_bearing; CGAffineTransform const transform (CGAffineTransformMakeRotation(M_PI_2 - angle)); self.navigationDashboardPortrait.direction.transform = transform; self.navigationDashboardLandscape.direction.transform = transform; diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/Dashboard/MWMLandscapeNavigationDashboard.xib b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/Dashboard/MWMLandscapeNavigationDashboard.xib index a3e7c34620..0f9728ca95 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/Dashboard/MWMLandscapeNavigationDashboard.xib +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/Dashboard/MWMLandscapeNavigationDashboard.xib @@ -34,14 +34,14 @@ - - + + - +