forked from organicmaps/organicmaps
[ios] Fixed duplicate alerts bug.
This commit is contained in:
parent
e6d20d5fae
commit
0241eebabf
2 changed files with 64 additions and 52 deletions
|
@ -23,8 +23,8 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
|
||||
{
|
||||
MWMAlert * alert = self.view.subviews.firstObject;
|
||||
[alert rotate:toInterfaceOrientation duration:duration];
|
||||
for (MWMAlert * alert in self.view.subviews)
|
||||
[alert rotate:toInterfaceOrientation duration:duration];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
@ -137,28 +137,6 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert alert:type]];
|
||||
}
|
||||
|
||||
- (void)displayAlert:(MWMAlert *)alert
|
||||
{
|
||||
[self removeFromParentViewController];
|
||||
alert.alertController = self;
|
||||
[self.ownerViewController addChildViewController:self];
|
||||
self.view.alpha = 0.;
|
||||
alert.alpha = 0.;
|
||||
if (!isIOS7)
|
||||
{
|
||||
CGFloat const scale = 1.1;
|
||||
alert.transform = CGAffineTransformMakeScale(scale, scale);
|
||||
}
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.view.alpha = 1.;
|
||||
alert.alpha = 1.;
|
||||
if (!isIOS7)
|
||||
alert.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
[MapsAppDelegate.theApp.window endEditing:YES];
|
||||
}
|
||||
|
||||
- (void)presentDisableAutoDownloadAlertWithOkBlock:(nonnull TMWMVoidBlock)okBlock
|
||||
{
|
||||
[self displayAlert:[MWMAlert disableAutoDownloadAlertWithOkBlock:okBlock]];
|
||||
|
@ -209,21 +187,61 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
[self displayAlert:[MWMAlert osmAuthAlert]];
|
||||
}
|
||||
|
||||
- (void)displayAlert:(MWMAlert *)alert
|
||||
{
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
for (MWMAlert * view in self.view.subviews)
|
||||
view.alpha = 0.0;
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
for (MWMAlert * view in self.view.subviews)
|
||||
{
|
||||
if (view != alert)
|
||||
view.hidden = YES;
|
||||
}
|
||||
}];
|
||||
|
||||
[self removeFromParentViewController];
|
||||
alert.alertController = self;
|
||||
[self.ownerViewController addChildViewController:self];
|
||||
self.view.alpha = 0.;
|
||||
alert.alpha = 0.;
|
||||
if (!isIOS7)
|
||||
{
|
||||
CGFloat const scale = 1.1;
|
||||
alert.transform = CGAffineTransformMakeScale(scale, scale);
|
||||
}
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.view.alpha = 1.;
|
||||
alert.alpha = 1.;
|
||||
if (!isIOS7)
|
||||
alert.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
[MapsAppDelegate.theApp.window endEditing:YES];
|
||||
}
|
||||
|
||||
- (void)closeAlert
|
||||
{
|
||||
NSArray * subviews = self.view.subviews;
|
||||
MWMAlert * alert = subviews.firstObject;
|
||||
BOOL const isLastAlert = (subviews.count == 1);
|
||||
MWMAlert * closeAlert = subviews.lastObject;
|
||||
MWMAlert * showAlert = (subviews.count >= 2 ? subviews[subviews.count - 2] : nil);
|
||||
if (showAlert)
|
||||
showAlert.hidden = NO;
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
alert.alpha = 0.;
|
||||
if (isLastAlert)
|
||||
closeAlert.alpha = 0.;
|
||||
if (showAlert)
|
||||
showAlert.alpha = 1.;
|
||||
else
|
||||
self.view.alpha = 0.;
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
[alert removeFromSuperview];
|
||||
if (isLastAlert)
|
||||
[closeAlert removeFromSuperview];
|
||||
if (!showAlert)
|
||||
{
|
||||
[self.view removeFromSuperview];
|
||||
[self removeFromParentViewController];
|
||||
|
|
|
@ -628,21 +628,8 @@ NSString * const kUDViralAlertWasShown = @"ViralAlertWasShown";
|
|||
case routing::IRouter::NeedMoreMaps:
|
||||
case routing::IRouter::FileTooOld:
|
||||
case routing::IRouter::RouteNotFound:
|
||||
{
|
||||
if (platform::migrate::NeedMigrate())
|
||||
{
|
||||
[self presentRoutingMigrationAlertWithOkBlock:^
|
||||
{
|
||||
[Statistics logEvent:kStatDownloaderMigrationDialogue withParameters:@{kStatFrom : kStatRouting}];
|
||||
[self openMigration];
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self presentDownloaderAlert:code countries:absentCountries];
|
||||
}
|
||||
[self presentDownloaderAlert:code countries:absentCountries];
|
||||
break;
|
||||
}
|
||||
case routing::IRouter::Cancelled:
|
||||
break;
|
||||
default:
|
||||
|
@ -776,25 +763,32 @@ NSString * const kUDViralAlertWasShown = @"ViralAlertWasShown";
|
|||
|
||||
#pragma mark - ShowDialog callback
|
||||
|
||||
- (void)presentRoutingMigrationAlertWithOkBlock:(TMWMVoidBlock)okBlock
|
||||
{
|
||||
[self.alertController presentRoutingMigrationAlertWithOkBlock:okBlock];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderAlert:(routing::IRouter::ResultCode)code
|
||||
countries:(storage::TCountriesVec const &)countries
|
||||
{
|
||||
if (countries.size())
|
||||
if (platform::migrate::NeedMigrate())
|
||||
{
|
||||
[self.alertController presentRoutingMigrationAlertWithOkBlock:^
|
||||
{
|
||||
[Statistics logEvent:kStatDownloaderMigrationDialogue
|
||||
withParameters:@{kStatFrom : kStatRouting}];
|
||||
[self openMigration];
|
||||
}];
|
||||
}
|
||||
else if (!countries.empty())
|
||||
{
|
||||
[self.alertController presentDownloaderAlertWithCountries:countries
|
||||
code:code
|
||||
cancelBlock:^
|
||||
{
|
||||
[self.controlsManager routingHidden];
|
||||
if (code != routing::IRouter::NeedMoreMaps)
|
||||
[self.controlsManager routingHidden];
|
||||
}
|
||||
downloadBlock:^(storage::TCountriesVec const & downloadCountries, TMWMVoidBlock onSuccess)
|
||||
{
|
||||
[MWMStorage downloadNodes:downloadCountries alertController:self.alertController onSuccess:onSuccess];
|
||||
[MWMStorage downloadNodes:downloadCountries
|
||||
alertController:self.alertController
|
||||
onSuccess:onSuccess];
|
||||
}
|
||||
downloadCompleteBlock:^
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue