[MAPSME-4881] [ios] Fixed route planning toast view display logic.

This commit is contained in:
Ilya Grechuhin 2017-07-06 17:11:27 +03:00 committed by r.kuznetsov
parent 3a19fe7cf2
commit a1ccdc0266
3 changed files with 53 additions and 32 deletions

View file

@ -99,18 +99,12 @@ using TInfoDisplays = NSHashTable<__kindof TInfoDisplay>;
- (IBAction)addLocationRoutePoint
{
if (![MWMRouter startPoint])
{
[MWMRouter
buildFromPoint:[[MWMRoutePoint alloc] initWithLastLocationAndType:MWMRoutePointTypeStart]
bestRouter:NO];
}
else if (![MWMRouter finishPoint])
{
[MWMRouter
buildToPoint:[[MWMRoutePoint alloc] initWithLastLocationAndType:MWMRoutePointTypeFinish]
NSAssert(![MWMRouter startPoint], @"Action button is active while start point is available");
NSAssert([MWMLocationManager lastLocation],
@"Action button is active while my location is not available");
[MWMRouter
buildFromPoint:[[MWMRoutePoint alloc] initWithLastLocationAndType:MWMRoutePointTypeStart]
bestRouter:NO];
}
}
#pragma mark - MWMRoutePreview
@ -225,7 +219,7 @@ using TInfoDisplays = NSHashTable<__kindof TInfoDisplay>;
[startButton setTitle:t forState:UIControlStateDisabled];
}
- (void)onRoutePointsUpdated { [self.navigationInfoView onRoutePointsUpdated]; }
- (void)onRoutePointsUpdated { [self.navigationInfoView updateToastView]; }
- (void)setMenuErrorStateWithErrorMessage:(NSString *)message
{
[self.delegate setRoutingErrorMessage:message];

View file

@ -32,6 +32,6 @@ typedef NS_ENUM(NSUInteger, MWMNavigationInfoViewState) {
- (void)setMapSearch;
- (void)onRoutePointsUpdated;
- (void)updateToastView;
@end

View file

@ -91,6 +91,8 @@ BOOL defaultOrientation(CGSize const & size)
@property(weak, nonatomic) MWMNavigationDashboardEntity * navigationInfo;
@property(nonatomic) BOOL hasLocation;
@end
@implementation MWMNavigationInfoView
@ -117,29 +119,47 @@ BOOL defaultOrientation(CGSize const & size)
}
- (void)setMapSearch { [self setSearchState:NavigationSearchState::MinimizedSearch animated:YES]; }
- (void)onRoutePointsUpdated
- (void)updateToastView
{
if (![MWMRouter startPoint])
{
if ([MWMLocationManager lastLocation])
{
[self.toastView configWithText:L(@"routing_add_start_point") withActionButton:YES];
[self setToastViewHidden:NO];
}
else
{
[self setToastViewHidden:YES];
}
}
else if (![MWMRouter finishPoint])
{
[self.toastView configWithText:L(@"routing_add_finish_point") withActionButton:NO];
[self setToastViewHidden:NO];
}
else
// -S-F-L -> Start
// -S-F+L -> Finish
// -S+F-L -> Start
// -S+F+L -> Start + Use
// +S-F-L -> Finish
// +S-F+L -> Finish
// +S+F-L -> Hide
// +S+F+L -> Hide
BOOL const hasStart = ([MWMRouter startPoint] != nil);
BOOL const hasFinish = ([MWMRouter finishPoint] != nil);
self.hasLocation = ([MWMLocationManager lastLocation] != nil);
if (hasStart && hasFinish)
{
[self setToastViewHidden:YES];
return;
}
[self setToastViewHidden:NO];
auto toastView = self.toastView;
if (hasStart)
{
[toastView configWithText:L(@"routing_add_finish_point") withActionButton:NO];
return;
}
if (hasFinish)
{
[toastView configWithText:L(@"routing_add_start_point") withActionButton:self.hasLocation];
return;
}
if (self.hasLocation)
[toastView configWithText:L(@"routing_add_finish_point") withActionButton:NO];
else
[toastView configWithText:L(@"routing_add_start_point") withActionButton:NO];
}
#pragma mark - Search
@ -303,6 +323,13 @@ BOOL defaultOrientation(CGSize const & size)
#pragma mark - MWMLocationObserver
- (void)onLocationUpdate:(location::GpsInfo const &)gpsInfo
{
BOOL const hasLocation = ([MWMLocationManager lastLocation] != nil);
if (self.hasLocation != hasLocation)
[self updateToastView];
}
- (void)onHeadingUpdate:(location::CompassInfo const &)info
{
CLLocation * lastLocation = [MWMLocationManager lastLocation];