[ios] Added functions for build route.

This commit is contained in:
Ilya Grechuhin 2015-07-21 12:28:16 +03:00 committed by Alex Zolotarev
parent 85f1467a9f
commit 552f96a10b
8 changed files with 66 additions and 19 deletions

View file

@ -16,7 +16,7 @@
#import "MWMSideMenuManager.h"
#import "MWMZoomButtons.h"
@interface MWMMapViewControlsManager () <MWMPlacePageViewManagerDelegate>
@interface MWMMapViewControlsManager () <MWMPlacePageViewManagerDelegate, MWMNavigationDashboardManagerDelegate>
@property (nonatomic) MWMZoomButtons * zoomButtons;
@property (nonatomic) MWMLocationButton * locationButton;
@ -26,6 +26,8 @@
@property (weak, nonatomic) MapViewController * ownerController;
@property (nonatomic) m2::PointD routeDestination;
@end
@implementation MWMMapViewControlsManager
@ -42,7 +44,7 @@
self.locationButton = [[MWMLocationButton alloc] initWithParentView:controller.view];
self.menuManager = [[MWMSideMenuManager alloc] initWithParentController:controller];
self.placePageManager = [[MWMPlacePageViewManager alloc] initWithViewController:controller delegate:self];
self.navigationManager = [[MWMNavigationDashboardManager alloc] init];
self.navigationManager = [[MWMNavigationDashboardManager alloc] initWithParentView:controller.view delegate:self];
self.hidden = NO;
self.zoomHidden = NO;
self.menuState = MWMSideMenuStateInactive;
@ -96,6 +98,21 @@
[self.ownerController updateStatusBarStyle];
}
- (void)buildRoute:(m2::PointD)destination
{
self.routeDestination = destination;
// Determine route type
enum MWMNavigationRouteType type = MWMNavigationRouteTypeVehicle;
[self buildRouteWithType:type];
}
#pragma mark - MWMNavigationDashboardManager
- (void)buildRouteWithType:(enum MWMNavigationRouteType)type
{
GetFramework().BuildRoute(self.routeDestination, 0 /* timeoutSec */);
}
#pragma mark - Properties
@synthesize menuState = _menuState;

View file

@ -6,8 +6,21 @@
// Copyright (c) 2015 MapsWithMe. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, MWMNavigationRouteType)
{
MWMNavigationRouteTypePedestrian,
MWMNavigationRouteTypeVehicle
};
@protocol MWMNavigationDashboardManagerDelegate <NSObject>
- (void)buildRouteWithType:(enum MWMNavigationRouteType)type;
@end
@interface MWMNavigationDashboardManager : NSObject
- (instancetype)init __attribute__((unavailable("init is not available")));
- (instancetype)initWithParentView:(UIView *)view delegate:(id<MWMNavigationDashboardManagerDelegate>)delegate;
@end

View file

@ -18,22 +18,30 @@
@property (nonatomic) IBOutlet MWMNavigationDashboard * navigationDashboard;
@property (nonatomic) IBOutlet MWMNavigationGo * navigatonGo;
@property (weak, nonatomic) UIView * ownerView;
@property (weak, nonatomic) id<MWMNavigationDashboardManagerDelegate> delegate;
@end
@implementation MWMNavigationDashboardManager
- (instancetype)initWithParentView:(UIView *)view delegate:(id<MWMNavigationDashboardManagerDelegate>)delegate
{
self = [super init];
if (self)
{
self.ownerView = view;
self.delegate = delegate;
}
return self;
}
#pragma mark - MWMRoutePreview
- (IBAction)routePreviewChange:(UIButton *)sender
{
if ([sender isEqual:self.routePreview.walk])
{
// Build walk route
}
else
{
// Build drive route
}
enum MWMNavigationRouteType const type = [sender isEqual:self.routePreview.pedestrian] ? MWMNavigationRouteTypePedestrian : MWMNavigationRouteTypeVehicle;
[self.delegate buildRouteWithType:type];
}
#pragma mark - MWMNavigationDashboard
@ -53,21 +61,21 @@
- (MWMRoutePreview *)routePreview
{
if (!_routePreview)
[[NSBundle mainBundle] loadNibNamed:MWMRoutePreview.className owner:self options:nil];
[NSBundle.mainBundle loadNibNamed:MWMRoutePreview.className owner:self options:nil];
return _routePreview;
}
- (MWMNavigationDashboard *)navigationDashboard
{
if (!_navigationDashboard)
[[NSBundle mainBundle] loadNibNamed:MWMNavigationDashboard.className owner:self options:nil];
[NSBundle.mainBundle loadNibNamed:MWMNavigationDashboard.className owner:self options:nil];
return _navigationDashboard;
}
- (MWMNavigationGo *)navigatonGo
{
if (!_navigatonGo)
[[NSBundle mainBundle] loadNibNamed:MWMNavigationGo.className owner:self options:nil];
[NSBundle.mainBundle loadNibNamed:MWMNavigationGo.className owner:self options:nil];
return _navigatonGo;
}

View file

@ -11,7 +11,7 @@
@interface MWMRoutePreview : SolidTouchView
@property (weak, nonatomic) IBOutlet UILabel * status;
@property (weak, nonatomic) IBOutlet UIButton * walk;
@property (weak, nonatomic) IBOutlet UIButton * drive;
@property (weak, nonatomic) IBOutlet UIButton * pedestrian;
@property (weak, nonatomic) IBOutlet UIButton * vehicle;
@end

View file

@ -15,4 +15,10 @@
self.frame = CGRectMake(0.0, 0.0, self.superview.width, 76.0);
}
- (IBAction)routeTypePressed:(UIButton *)sender
{
self.pedestrian.selected = self.vehicle.selected = NO;
sender.selected = YES;
}
@end

View file

@ -44,6 +44,7 @@
</state>
<connections>
<action selector="routePreviewChange:" destination="-1" eventType="touchUpInside" id="2Yh-CE-Sq2"/>
<action selector="routeTypePressed:" destination="iN0-l3-epB" eventType="touchUpInside" id="w9W-9i-JXg"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KDI-3e-888" userLabel="Drive Button">
@ -53,6 +54,7 @@
</state>
<connections>
<action selector="routePreviewChange:" destination="-1" eventType="touchUpInside" id="9Pu-OX-NOL"/>
<action selector="routeTypePressed:" destination="iN0-l3-epB" eventType="touchUpInside" id="1tR-7d-1af"/>
</connections>
</button>
</subviews>
@ -84,9 +86,9 @@
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="drive" destination="KDI-3e-888" id="89j-XQ-qYp"/>
<outlet property="pedestrian" destination="BhZ-YH-NR4" id="tPi-D3-IUF"/>
<outlet property="status" destination="kPQ-m5-bML" id="O4H-Ld-GZg"/>
<outlet property="walk" destination="BhZ-YH-NR4" id="IVv-IB-z4z"/>
<outlet property="vehicle" destination="KDI-3e-888" id="bTw-F4-5xc"/>
</connections>
<point key="canvasLocation" x="330" y="261"/>
</view>

View file

@ -170,7 +170,7 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
- (void)buildRoute
{
GetFramework().BuildRoute(m_userMark->GetUserMark()->GetOrg(), 0 /* timeoutSec */);
[self.delegate buildRoute:m_userMark->GetUserMark()->GetOrg()];
}
- (void)stopBuildingRoute

View file

@ -11,5 +11,6 @@
- (void)dragPlacePage:(CGPoint)point;
- (void)addPlacePageViews:(NSArray *)views;
- (void)updateStatusBarStyle;
- (void)buildRoute:(m2::PointD)destination;
@end