[iOS] show isolines status

This commit is contained in:
Aleksey Belousov 2020-01-31 19:04:10 +03:00 committed by Daria Volvenkova
parent 0f8ec4ee7d
commit 6edc589cc5
3 changed files with 35 additions and 7 deletions

View file

@ -17,6 +17,13 @@ typedef NS_ENUM(NSUInteger, MWMMapOverlayTransitState) {
MWMMapOverlayTransitStateNoData,
} NS_SWIFT_NAME(MapOverlayTransitState);
typedef NS_ENUM(NSUInteger, MWMMapOverlayIsolinesState) {
MWMMapOverlayIsolinesStateDisabled,
MWMMapOverlayIsolinesStateEnabled,
MWMMapOverlayIsolinesStateExpiredData,
MWMMapOverlayIsolinesStateNoData,
} NS_SWIFT_NAME(MapOverlayTransitState);
NS_SWIFT_NAME(MapOverlayManagerObserver)
@protocol MWMMapOverlayManagerObserver <NSObject>
@ -36,6 +43,7 @@ NS_SWIFT_NAME(MapOverlayManager)
+ (MWMMapOverlayTrafficState)trafficState;
+ (MWMMapOverlayTransitState)transitState;
+ (MWMMapOverlayIsolinesState)isolinesState;
+ (BOOL)trafficEnabled;
+ (BOOL)transitEnabled;

View file

@ -8,6 +8,7 @@
@property(nonatomic) TrafficManager::TrafficState trafficState;
@property(nonatomic) TransitReadManager::TransitSchemeState transitState;
@property(nonatomic) IsolinesManager::IsolinesState isolinesState;
@end
@ -42,6 +43,14 @@
}
}
});
GetFramework().GetIsolinesManager().SetStateListener([self](IsolinesManager::IsolinesState state) {
self.isolinesState = state;
for (id<MWMMapOverlayManagerObserver> observer in self.observers) {
if ([observer respondsToSelector:@selector(onIsoLinesStateUpdated)]) {
[observer onIsoLinesStateUpdated];
}
}
});
}
return self;
}
@ -88,6 +97,19 @@
}
}
+ (MWMMapOverlayIsolinesState)isolinesState {
switch ([MWMMapOverlayManager manager].isolinesState) {
case IsolinesManager::IsolinesState::Disabled:
return MWMMapOverlayIsolinesStateDisabled;
case IsolinesManager::IsolinesState::Enabled:
return MWMMapOverlayIsolinesStateEnabled;
case IsolinesManager::IsolinesState::ExpiredData:
return MWMMapOverlayIsolinesStateExpiredData;
case IsolinesManager::IsolinesState::NoData:
return MWMMapOverlayIsolinesStateNoData;
}
}
+ (BOOL)trafficEnabled {
return [MWMMapOverlayManager manager].trafficState != TrafficManager::TrafficState::Disabled;
}
@ -97,7 +119,7 @@
}
+ (BOOL)isoLinesEnabled {
return GetFramework().LoadIsolinesEnabled();
return [MWMMapOverlayManager manager].isolinesState != IsolinesManager::IsolinesState::Disabled;
}
+ (void)setTrafficEnabled:(BOOL)enable {
@ -131,12 +153,6 @@
auto &f = GetFramework();
f.GetIsolinesManager().SetEnabled(enable);
f.SaveIsolonesEnabled(enable);
for (id<MWMMapOverlayManagerObserver> observer in [MWMMapOverlayManager manager].observers) {
if ([observer respondsToSelector:@selector(onIsoLinesStateUpdated)]) {
[observer onIsoLinesStateUpdated];
}
}
}
@end

View file

@ -146,6 +146,10 @@ NSArray<UIImage *> * imagesWithName(NSString * name)
else if ([MWMMapOverlayManager isoLinesEnabled])
{
btn.imageName = @"btn_isoMap_on";
if ([MWMMapOverlayManager isolinesState] == MWMMapOverlayIsolinesStateNoData)
[[MWMToast toastWithText:L(@"isolines_location_error_dialog")] show];
else if ([MWMMapOverlayManager isolinesState] == MWMMapOverlayIsolinesStateExpiredData)
[MWMAlertViewController.activeAlertController presentInfoAlert:L(@"isolines_activation_error_dialog") text:@""];
}
else
{