[ios] Format all Obj C code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 16:37:15 +07:00
parent 52e9ddc038
commit aea784ddd7
109 changed files with 5113 additions and 4270 deletions

View File

@@ -6,24 +6,26 @@
#import "MapsAppDelegate.h"
#import "SwiftBridge.h"
static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController";
static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController";
@interface MWMAlertViewController () <UIGestureRecognizerDelegate>
@property(weak, nonatomic, readwrite) UIViewController *ownerViewController;
@property(weak, nonatomic, readwrite) UIViewController * ownerViewController;
@end
@implementation MWMAlertViewController
+ (nonnull MWMAlertViewController *)activeAlertController {
UIViewController *tvc = [MapViewController sharedController];
+ (nonnull MWMAlertViewController *)activeAlertController
{
UIViewController * tvc = [MapViewController sharedController];
ASSERT([tvc conformsToProtocol:@protocol(MWMController)], ());
UIViewController<MWMController> *mwmController = static_cast<UIViewController<MWMController> *>(tvc);
UIViewController<MWMController> * mwmController = static_cast<UIViewController<MWMController> *>(tvc);
return mwmController.alertController;
}
- (nonnull instancetype)initWithViewController:(nonnull UIViewController *)viewController {
- (nonnull instancetype)initWithViewController:(nonnull UIViewController *)viewController
{
self = [super initWithNibName:kAlertControllerNibIdentifier bundle:nil];
if (self)
_ownerViewController = viewController;
@@ -31,53 +33,63 @@ static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController"
}
- (void)viewWillTransitionToSize:(CGSize)size
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
auto const orient = size.width > size.height ? UIInterfaceOrientationLandscapeLeft : UIInterfaceOrientationPortrait;
[coordinator
animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
for (MWMAlert *alert in self.view.subviews)
[alert rotate:orient duration:context.transitionDuration];
}
completion:^(id<UIViewControllerTransitionCoordinatorContext> context){
}];
animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
for (MWMAlert * alert in self.view.subviews)
[alert rotate:orient duration:context.transitionDuration];
}
completion:^(id<UIViewControllerTransitionCoordinatorContext> context){}];
}
#pragma mark - Actions
- (void)presentLocationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock {
- (void)presentLocationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock
{
[self displayAlert:[MWMAlert locationAlertWithCancelBlock:cancelBlock]];
}
- (void)presentPoint2PointAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild {
- (void)presentPoint2PointAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild
{
[self displayAlert:[MWMAlert point2PointAlertWithOkBlock:okBlock needToRebuild:needToRebuild]];
}
- (void)presentLocationServiceNotSupportedAlert {
- (void)presentLocationServiceNotSupportedAlert
{
[self displayAlert:[MWMAlert locationServiceNotSupportedAlert]];
}
- (void)presentNoConnectionAlert {
- (void)presentNoConnectionAlert
{
[self displayAlert:[MWMAlert noConnectionAlert]];
}
- (void)presentDeleteMapProhibitedAlert {
- (void)presentDeleteMapProhibitedAlert
{
[self displayAlert:[MWMAlert deleteMapProhibitedAlert]];
}
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock {
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
{
[self displayAlert:[MWMAlert unsavedEditsAlertWithOkBlock:okBlock]];
}
- (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock {
- (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock
{
[self displayAlert:[MWMAlert noWiFiAlertWithOkBlock:okBlock andCancelBlock:cancelBlock]];
}
- (void)presentIncorrectFeauturePositionAlert {
- (void)presentIncorrectFeauturePositionAlert
{
[self displayAlert:[MWMAlert incorrectFeaturePositionAlert]];
}
- (void)presentNotEnoughSpaceAlert {
- (void)presentNotEnoughSpaceAlert
{
[self displayAlert:[MWMAlert notEnoughSpaceAlert]];
}
- (void)presentInvalidUserNameOrPasswordAlert {
- (void)presentInvalidUserNameOrPasswordAlert
{
[self displayAlert:[MWMAlert invalidUserNameOrPasswordAlert]];
}
@@ -85,7 +97,8 @@ static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController"
code:(routing::RouterResultCode)code
cancelBlock:(MWMVoidBlock)cancelBlock
downloadBlock:(MWMDownloadBlock)downloadBlock
downloadCompleteBlock:(MWMVoidBlock)downloadCompleteBlock {
downloadCompleteBlock:(MWMVoidBlock)downloadCompleteBlock
{
[self displayAlert:[MWMAlert downloaderAlertWithAbsentCountries:countries
code:code
cancelBlock:cancelBlock
@@ -93,95 +106,113 @@ static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController"
downloadCompleteBlock:downloadCompleteBlock]];
}
- (void)presentRoutingDisclaimerAlertWithOkBlock:(MWMVoidBlock)block {
- (void)presentRoutingDisclaimerAlertWithOkBlock:(MWMVoidBlock)block
{
[self displayAlert:[MWMAlert routingDisclaimerAlertWithOkBlock:block]];
}
- (void)presentDisabledLocationAlert {
- (void)presentDisabledLocationAlert
{
[self displayAlert:[MWMAlert disabledLocationAlert]];
}
- (void)presentLocationServicesDisabledAlert; {
- (void)presentLocationServicesDisabledAlert;
{
[self displayAlert:[MWMAlert locationServicesDisabledAlert]];
}
- (void)presentAlert:(routing::RouterResultCode)type {
- (void)presentAlert:(routing::RouterResultCode)type
{
[self displayAlert:[MWMAlert alert:type]];
}
- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
cancelBlock:(nonnull MWMVoidBlock)cancelBlock {
cancelBlock:(nonnull MWMVoidBlock)cancelBlock
{
[self displayAlert:[MWMAlert downloaderNoConnectionAlertWithOkBlock:okBlock cancelBlock:cancelBlock]];
}
- (void)presentDownloaderNotEnoughSpaceAlert {
- (void)presentDownloaderNotEnoughSpaceAlert
{
[self displayAlert:[MWMAlert downloaderNotEnoughSpaceAlert]];
}
- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
cancelBlock:(nonnull MWMVoidBlock)cancelBlock {
cancelBlock:(nonnull MWMVoidBlock)cancelBlock
{
[self displayAlert:[MWMAlert downloaderInternalErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]];
}
- (void)presentPlaceDoesntExistAlertWithBlock:(MWMStringBlock)block {
- (void)presentPlaceDoesntExistAlertWithBlock:(MWMStringBlock)block
{
[self displayAlert:[MWMAlert placeDoesntExistAlertWithBlock:block]];
}
- (void)presentResetChangesAlertWithBlock:(MWMVoidBlock)block {
- (void)presentResetChangesAlertWithBlock:(MWMVoidBlock)block
{
[self displayAlert:[MWMAlert resetChangesAlertWithBlock:block]];
}
- (void)presentDeleteFeatureAlertWithBlock:(MWMVoidBlock)block {
- (void)presentDeleteFeatureAlertWithBlock:(MWMVoidBlock)block
{
[self displayAlert:[MWMAlert deleteFeatureAlertWithBlock:block]];
}
- (void)presentPersonalInfoWarningAlertWithBlock:(nonnull MWMVoidBlock)block {
- (void)presentPersonalInfoWarningAlertWithBlock:(nonnull MWMVoidBlock)block
{
[self displayAlert:[MWMAlert personalInfoWarningAlertWithBlock:block]];
}
- (void)presentTrackWarningAlertWithCancelBlock:(nonnull MWMVoidBlock)block {
- (void)presentTrackWarningAlertWithCancelBlock:(nonnull MWMVoidBlock)block
{
[self displayAlert:[MWMAlert trackWarningAlertWithCancelBlock:block]];
}
- (void)presentMobileInternetAlertWithBlock:(nonnull MWMMobileInternetAlertCompletionBlock)block {
- (void)presentMobileInternetAlertWithBlock:(nonnull MWMMobileInternetAlertCompletionBlock)block
{
[self displayAlert:[MWMMobileInternetAlert alertWithBlock:block]];
}
- (void)presentInfoAlert:(nonnull NSString *)title text:(nonnull NSString *)text {
- (void)presentInfoAlert:(nonnull NSString *)title text:(nonnull NSString *)text
{
[self displayAlert:[MWMAlert infoAlert:title text:text]];
}
- (void)presentInfoAlert:(nonnull NSString *)title {
- (void)presentInfoAlert:(nonnull NSString *)title
{
[self displayAlert:[MWMAlert infoAlert:title text:nil]];
}
- (void)presentCreateBookmarkCategoryAlertWithMaxCharacterNum:(NSUInteger)max
minCharacterNum:(NSUInteger)min
callback:(nonnull MWMCheckStringBlock)callback {
callback:(nonnull MWMCheckStringBlock)callback
{
auto alert =
static_cast<MWMBCCreateCategoryAlert *>([MWMAlert createBookmarkCategoryAlertWithMaxCharacterNum:max
minCharacterNum:min
callback:callback]);
static_cast<MWMBCCreateCategoryAlert *>([MWMAlert createBookmarkCategoryAlertWithMaxCharacterNum:max
minCharacterNum:min
callback:callback]);
[self displayAlert:alert];
dispatch_async(dispatch_get_main_queue(), ^{
[alert.textField becomeFirstResponder];
});
dispatch_async(dispatch_get_main_queue(), ^{ [alert.textField becomeFirstResponder]; });
}
- (void)presentSpinnerAlertWithTitle:(nonnull NSString *)title cancel:(nullable MWMVoidBlock)cancel {
- (void)presentSpinnerAlertWithTitle:(nonnull NSString *)title cancel:(nullable MWMVoidBlock)cancel
{
[self displayAlert:[MWMAlert spinnerAlertWithTitle:title cancel:cancel]];
}
- (void)presentBookmarkConversionErrorAlert {
- (void)presentBookmarkConversionErrorAlert
{
[self displayAlert:[MWMAlert bookmarkConversionErrorAlert]];
}
- (void)presentTagsLoadingErrorAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
cancelBlock:(nonnull MWMVoidBlock)cancelBlock {
cancelBlock:(nonnull MWMVoidBlock)cancelBlock
{
[self displayAlert:[MWMAlert tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]];
}
- (void)presentBugReportAlertWithTitle:(nonnull NSString *)title {
- (void)presentBugReportAlertWithTitle:(nonnull NSString *)title
{
[self displayAlert:[MWMAlert bugReportAlertWithTitle:title]];
}
@@ -189,7 +220,8 @@ static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController"
message:(nullable NSString *)message
rightButtonTitle:(nonnull NSString *)rightButtonTitle
leftButtonTitle:(nullable NSString *)leftButtonTitle
rightButtonAction:(nullable MWMVoidBlock)action {
rightButtonAction:(nullable MWMVoidBlock)action
{
[self displayAlert:[MWMAlert defaultAlertWithTitle:title
message:message
rightButtonTitle:rightButtonTitle
@@ -197,46 +229,44 @@ static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController"
rightButtonAction:action]];
}
- (void)displayAlert:(MWMAlert *)alert {
UIViewController *ownerVC = self.ownerViewController;
if (ownerVC.navigationController != nil) {
- (void)displayAlert:(MWMAlert *)alert
{
UIViewController * ownerVC = self.ownerViewController;
if (ownerVC.navigationController != nil)
ownerVC = ownerVC.navigationController;
}
BOOL isOwnerLoaded = ownerVC.isViewLoaded;
if (!isOwnerLoaded) {
if (!isOwnerLoaded)
return;
}
// TODO(igrechuhin): Remove this check on location manager refactoring.
// Workaround for current location manager duplicate error alerts.
if ([alert isKindOfClass:[MWMLocationAlert class]]) {
for (MWMAlert *view in self.view.subviews) {
if ([alert isKindOfClass:[MWMLocationAlert class]])
{
for (MWMAlert * view in self.view.subviews)
if ([view isKindOfClass:[MWMLocationAlert class]])
return;
}
}
[UIView animateWithDuration:kDefaultAnimationDuration
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
for (MWMAlert *view in self.view.subviews) {
for (MWMAlert * view in self.view.subviews)
if (view != alert)
view.alpha = 0.0;
}
}
completion:nil];
[self willMoveToParentViewController:NULL];
[self.view removeFromSuperview];
[self removeFromParentViewController];
alert.alertController = self;
[ownerVC addChildViewController:self];
self.view.frame = CGRectMake(0, 0, ownerVC.view.frame.size.width, ownerVC.view.frame.size.height);
[ownerVC.view addSubview:self.view];
[self didMoveToParentViewController:ownerVC];
alert.alpha = 0.;
[self.view addSubview:alert];
CGFloat const scale = 1.1;
@@ -250,29 +280,31 @@ static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController"
[[MapsAppDelegate theApp].window endEditing:YES];
}
- (void)closeAlert:(nullable MWMVoidBlock)completion {
NSArray *subviews = self.view.subviews;
MWMAlert *closeAlert = subviews.lastObject;
MWMAlert *showAlert = (subviews.count >= 2 ? subviews[subviews.count - 2] : nil);
- (void)closeAlert:(nullable MWMVoidBlock)completion
{
NSArray * subviews = self.view.subviews;
MWMAlert * closeAlert = subviews.lastObject;
MWMAlert * showAlert = (subviews.count >= 2 ? subviews[subviews.count - 2] : nil);
[UIView animateWithDuration:kDefaultAnimationDuration
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
closeAlert.alpha = 0.;
if (showAlert)
showAlert.alpha = 1.;
else
self.view.alpha = 0.;
}
completion:^(BOOL finished) {
[closeAlert removeFromSuperview];
if (!showAlert) {
[self.view removeFromSuperview];
[self removeFromParentViewController];
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
closeAlert.alpha = 0.;
if (showAlert)
showAlert.alpha = 1.;
else
self.view.alpha = 0.;
}
if (completion)
completion();
}];
completion:^(BOOL finished) {
[closeAlert removeFromSuperview];
if (!showAlert)
{
[self.view removeFromSuperview];
[self removeFromParentViewController];
}
if (completion)
completion();
}];
}
@end

View File

@@ -10,42 +10,52 @@
@implementation MWMAlert
+ (MWMAlert *)locationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock {
+ (MWMAlert *)locationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock
{
return [MWMLocationAlert alertWithCancelBlock:cancelBlock];
}
+ (MWMAlert *)point2PointAlertWithOkBlock:(MWMVoidBlock)block needToRebuild:(BOOL)needToRebuild {
+ (MWMAlert *)point2PointAlertWithOkBlock:(MWMVoidBlock)block needToRebuild:(BOOL)needToRebuild
{
return [MWMDefaultAlert point2PointAlertWithOkBlock:block needToRebuild:needToRebuild];
}
+ (MWMAlert *)routingDisclaimerAlertWithOkBlock:(MWMVoidBlock)block {
+ (MWMAlert *)routingDisclaimerAlertWithOkBlock:(MWMVoidBlock)block
{
return [MWMRoutingDisclaimerAlert alertWithOkBlock:block];
}
+ (MWMAlert *)disabledLocationAlert {
+ (MWMAlert *)disabledLocationAlert
{
return [MWMDefaultAlert disabledLocationAlert];
}
+ (MWMAlert *)locationServicesDisabledAlert {
+ (MWMAlert *)locationServicesDisabledAlert
{
return [LocationServicesDisabledAlert alert];
}
+ (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock {
+ (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock
{
return [MWMDefaultAlert noWiFiAlertWithOkBlock:okBlock andCancelBlock:cancelBlock];
}
+ (MWMAlert *)noConnectionAlert {
+ (MWMAlert *)noConnectionAlert
{
return [MWMDefaultAlert noConnectionAlert];
}
+ (MWMAlert *)deleteMapProhibitedAlert {
+ (MWMAlert *)deleteMapProhibitedAlert
{
return [MWMDefaultAlert deleteMapProhibitedAlert];
}
+ (MWMAlert *)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock {
+ (MWMAlert *)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock
{
return [MWMDefaultAlert unsavedEditsAlertWithOkBlock:okBlock];
}
+ (MWMAlert *)locationServiceNotSupportedAlert {
+ (MWMAlert *)locationServiceNotSupportedAlert
{
return [MWMDefaultAlert locationServiceNotSupportedAlert];
}
@@ -53,7 +63,8 @@
code:(routing::RouterResultCode)code
cancelBlock:(MWMVoidBlock)cancelBlock
downloadBlock:(MWMDownloadBlock)downloadBlock
downloadCompleteBlock:(MWMVoidBlock)downloadCompleteBlock {
downloadCompleteBlock:(MWMVoidBlock)downloadCompleteBlock
{
return [MWMDownloadTransitMapAlert downloaderAlertWithMaps:countries
code:code
cancelBlock:cancelBlock
@@ -61,105 +72,115 @@
downloadCompleteBlock:downloadCompleteBlock];
}
+ (MWMAlert *)alert:(routing::RouterResultCode)type {
switch (type) {
case routing::RouterResultCode::NoCurrentPosition:
return [MWMDefaultAlert noCurrentPositionAlert];
case routing::RouterResultCode::StartPointNotFound:
return [MWMDefaultAlert startPointNotFoundAlert];
case routing::RouterResultCode::EndPointNotFound:
return [MWMDefaultAlert endPointNotFoundAlert];
case routing::RouterResultCode::PointsInDifferentMWM:
return [MWMDefaultAlert pointsInDifferentMWMAlert];
case routing::RouterResultCode::TransitRouteNotFoundNoNetwork:
return [MWMDefaultAlert routeNotFoundNoPublicTransportAlert];
case routing::RouterResultCode::TransitRouteNotFoundTooLongPedestrian:
return [MWMDefaultAlert routeNotFoundTooLongPedestrianAlert];
case routing::RouterResultCode::RouteNotFoundRedressRouteError:
case routing::RouterResultCode::RouteNotFound:
case routing::RouterResultCode::InconsistentMWMandRoute:
return [MWMDefaultAlert routeNotFoundAlert];
case routing::RouterResultCode::RouteFileNotExist:
case routing::RouterResultCode::FileTooOld:
return [MWMDefaultAlert routeFileNotExistAlert];
case routing::RouterResultCode::InternalError:
return [MWMDefaultAlert internalRoutingErrorAlert];
case routing::RouterResultCode::Cancelled:
case routing::RouterResultCode::NoError:
case routing::RouterResultCode::HasWarnings:
case routing::RouterResultCode::NeedMoreMaps:
return nil;
case routing::RouterResultCode::IntermediatePointNotFound:
return [MWMDefaultAlert intermediatePointNotFoundAlert];
+ (MWMAlert *)alert:(routing::RouterResultCode)type
{
switch (type)
{
case routing::RouterResultCode::NoCurrentPosition: return [MWMDefaultAlert noCurrentPositionAlert];
case routing::RouterResultCode::StartPointNotFound: return [MWMDefaultAlert startPointNotFoundAlert];
case routing::RouterResultCode::EndPointNotFound: return [MWMDefaultAlert endPointNotFoundAlert];
case routing::RouterResultCode::PointsInDifferentMWM: return [MWMDefaultAlert pointsInDifferentMWMAlert];
case routing::RouterResultCode::TransitRouteNotFoundNoNetwork:
return [MWMDefaultAlert routeNotFoundNoPublicTransportAlert];
case routing::RouterResultCode::TransitRouteNotFoundTooLongPedestrian:
return [MWMDefaultAlert routeNotFoundTooLongPedestrianAlert];
case routing::RouterResultCode::RouteNotFoundRedressRouteError:
case routing::RouterResultCode::RouteNotFound:
case routing::RouterResultCode::InconsistentMWMandRoute: return [MWMDefaultAlert routeNotFoundAlert];
case routing::RouterResultCode::RouteFileNotExist:
case routing::RouterResultCode::FileTooOld: return [MWMDefaultAlert routeFileNotExistAlert];
case routing::RouterResultCode::InternalError: return [MWMDefaultAlert internalRoutingErrorAlert];
case routing::RouterResultCode::Cancelled:
case routing::RouterResultCode::NoError:
case routing::RouterResultCode::HasWarnings:
case routing::RouterResultCode::NeedMoreMaps: return nil;
case routing::RouterResultCode::IntermediatePointNotFound: return [MWMDefaultAlert intermediatePointNotFoundAlert];
}
}
+ (MWMAlert *)incorrectFeaturePositionAlert {
+ (MWMAlert *)incorrectFeaturePositionAlert
{
return [MWMDefaultAlert incorrectFeaturePositionAlert];
}
+ (MWMAlert *)notEnoughSpaceAlert {
+ (MWMAlert *)notEnoughSpaceAlert
{
return [MWMDefaultAlert notEnoughSpaceAlert];
}
+ (MWMAlert *)invalidUserNameOrPasswordAlert {
+ (MWMAlert *)invalidUserNameOrPasswordAlert
{
return [MWMDefaultAlert invalidUserNameOrPasswordAlert];
}
+ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock {
+ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock
{
return [MWMDefaultAlert downloaderNoConnectionAlertWithOkBlock:okBlock cancelBlock:cancelBlock];
}
+ (MWMAlert *)downloaderNotEnoughSpaceAlert {
+ (MWMAlert *)downloaderNotEnoughSpaceAlert
{
return [MWMDefaultAlert downloaderNotEnoughSpaceAlert];
}
+ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock {
+ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock
{
return [MWMDefaultAlert downloaderInternalErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock];
}
+ (MWMAlert *)placeDoesntExistAlertWithBlock:(MWMStringBlock)block {
+ (MWMAlert *)placeDoesntExistAlertWithBlock:(MWMStringBlock)block
{
return [MWMPlaceDoesntExistAlert alertWithBlock:block];
}
+ (MWMAlert *)resetChangesAlertWithBlock:(MWMVoidBlock)block {
+ (MWMAlert *)resetChangesAlertWithBlock:(MWMVoidBlock)block
{
return [MWMDefaultAlert resetChangesAlertWithBlock:block];
}
+ (MWMAlert *)deleteFeatureAlertWithBlock:(MWMVoidBlock)block {
+ (MWMAlert *)deleteFeatureAlertWithBlock:(MWMVoidBlock)block
{
return [MWMDefaultAlert deleteFeatureAlertWithBlock:block];
}
+ (MWMAlert *)personalInfoWarningAlertWithBlock:(MWMVoidBlock)block {
+ (MWMAlert *)personalInfoWarningAlertWithBlock:(MWMVoidBlock)block
{
return [MWMDefaultAlert personalInfoWarningAlertWithBlock:block];
}
+ (MWMAlert *)trackWarningAlertWithCancelBlock:(MWMVoidBlock)block {
+ (MWMAlert *)trackWarningAlertWithCancelBlock:(MWMVoidBlock)block
{
return [MWMDefaultAlert trackWarningAlertWithCancelBlock:block];
}
+ (MWMAlert *)infoAlert:(NSString *)title text:(NSString *)text {
+ (MWMAlert *)infoAlert:(NSString *)title text:(NSString *)text
{
return [MWMDefaultAlert infoAlert:title text:text];
}
+ (MWMAlert *)createBookmarkCategoryAlertWithMaxCharacterNum:(NSUInteger)max
minCharacterNum:(NSUInteger)min
callback:(MWMCheckStringBlock)callback {
callback:(MWMCheckStringBlock)callback
{
return [MWMBCCreateCategoryAlert alertWithMaxCharachersNum:max minCharactersNum:min callback:callback];
}
+ (MWMAlert *)spinnerAlertWithTitle:(NSString *)title cancel:(MWMVoidBlock)cancel {
+ (MWMAlert *)spinnerAlertWithTitle:(NSString *)title cancel:(MWMVoidBlock)cancel
{
return [MWMSpinnerAlert alertWithTitle:title cancel:cancel];
}
+ (MWMAlert *)bookmarkConversionErrorAlert {
+ (MWMAlert *)bookmarkConversionErrorAlert
{
return [MWMDefaultAlert bookmarkConversionErrorAlert];
}
+ (MWMAlert *)tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock {
+ (MWMAlert *)tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock
{
return [MWMDefaultAlert tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock];
}
+ (MWMAlert *)bugReportAlertWithTitle:(NSString *)title {
+ (MWMAlert *)bugReportAlertWithTitle:(NSString *)title
{
return [MWMDefaultAlert bugReportAlertWithTitle:title];
}
@@ -167,66 +188,76 @@
message:(NSString *)message
rightButtonTitle:(NSString *)rightButtonTitle
leftButtonTitle:(NSString *)leftButtonTitle
rightButtonAction:(MWMVoidBlock)action {
rightButtonAction:(MWMVoidBlock)action
{
return [MWMDefaultAlert defaultAlertWithTitle:title
message:message
rightButtonTitle:rightButtonTitle
leftButtonTitle:leftButtonTitle
rightButtonAction:action
log:nil];
log:nil];
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
// Should override this method if you want custom relayout after rotation.
}
- (void)close:(MWMVoidBlock)completion {
- (void)close:(MWMVoidBlock)completion
{
[self.alertController closeAlert:completion];
}
- (void)setNeedsCloseAlertAfterEnterBackground {
- (void)setNeedsCloseAlertAfterEnterBackground
{
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(applicationDidEnterBackground)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
}
- (void)dealloc {
- (void)dealloc
{
[NSNotificationCenter.defaultCenter removeObserver:self];
}
- (void)applicationDidEnterBackground {
- (void)applicationDidEnterBackground
{
// Should close alert when application entered background.
[self close:nil];
}
- (void)rotate:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
- (void)rotate:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if ([self respondsToSelector:@selector(willRotateToInterfaceOrientation:)])
[self willRotateToInterfaceOrientation:toInterfaceOrientation];
}
- (void)addControllerViewToWindow {
UIWindow *window = UIApplication.sharedApplication.delegate.window;
UIView *view = self.alertController.view;
- (void)addControllerViewToWindow
{
UIWindow * window = UIApplication.sharedApplication.delegate.window;
UIView * view = self.alertController.view;
[window addSubview:view];
view.frame = window.bounds;
}
- (void)layoutSubviews {
- (void)layoutSubviews
{
[super layoutSubviews];
self.frame = self.superview.bounds;
[super layoutSubviews];
}
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
{
[super traitCollectionDidChange:previousTraitCollection];
if (self.traitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle) {
if (self.traitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle)
[self updateViewStyle:self];
}
}
- (void)updateViewStyle:(UIView *)view {
- (void)updateViewStyle:(UIView *)view
{
if (!view)
return;
for (UIView *subview in view.subviews)
for (UIView * subview in view.subviews)
[self updateViewStyle:subview];
[view applyTheme];
}

View File

@@ -7,354 +7,387 @@ static CGFloat const kDividerTopConstant = -8.;
@interface MWMDefaultAlert ()
@property(weak, nonatomic) IBOutlet UILabel *messageLabel;
@property(weak, nonatomic) IBOutlet UIButton *rightButton;
@property(weak, nonatomic) IBOutlet UIButton *leftButton;
@property(weak, nonatomic) IBOutlet UILabel *titleLabel;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint *rightButtonWidth;
@property(weak, nonatomic) IBOutlet UILabel * messageLabel;
@property(weak, nonatomic) IBOutlet UIButton * rightButton;
@property(weak, nonatomic) IBOutlet UIButton * leftButton;
@property(weak, nonatomic) IBOutlet UILabel * titleLabel;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * rightButtonWidth;
@property(copy, nonatomic) MWMVoidBlock leftButtonAction;
@property(copy, nonatomic, readwrite) MWMVoidBlock rightButtonAction;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint *dividerTop;
@property(weak, nonatomic) IBOutlet UIView *vDivider;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * dividerTop;
@property(weak, nonatomic) IBOutlet UIView * vDivider;
@end
static NSString *const kDefaultAlertNibName = @"MWMDefaultAlert";
static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
@implementation MWMDefaultAlert
+ (instancetype)routeFileNotExistAlert {
+ (instancetype)routeFileNotExistAlert
{
return [self defaultAlertWithTitle:L(@"dialog_routing_download_files")
message:L(@"dialog_routing_download_and_update_all")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Route File Not Exist Alert"];
log:@"Route File Not Exist Alert"];
}
+ (instancetype)routeNotFoundAlert {
+ (instancetype)routeNotFoundAlert
{
return [self defaultAlertWithTitle:L(@"dialog_routing_unable_locate_route")
message:L(@"dialog_routing_change_start_or_end")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Route File Not Exist Alert"];
log:@"Route File Not Exist Alert"];
}
+ (instancetype)routeNotFoundNoPublicTransportAlert {
+ (instancetype)routeNotFoundNoPublicTransportAlert
{
return [self defaultAlertWithTitle:L(@"transit_not_found")
message:nil
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"transit_not_found"];
log:@"transit_not_found"];
}
+ (instancetype)routeNotFoundTooLongPedestrianAlert {
+ (instancetype)routeNotFoundTooLongPedestrianAlert
{
return [self defaultAlertWithTitle:L(@"dialog_pedestrian_route_is_long_header")
message:L(@"dialog_pedestrian_route_is_long_message")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Long Pedestrian Route Alert"];
log:@"Long Pedestrian Route Alert"];
}
+ (instancetype)locationServiceNotSupportedAlert {
+ (instancetype)locationServiceNotSupportedAlert
{
return [self defaultAlertWithTitle:L(@"current_location_unknown_error_title")
message:L(@"current_location_unknown_error_message")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Location Service Not Supported Alert"];
log:@"Location Service Not Supported Alert"];
}
+ (instancetype)noConnectionAlert {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"common_check_internet_connection_dialog")
message:nil
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"No Connection Alert"];
+ (instancetype)noConnectionAlert
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"common_check_internet_connection_dialog")
message:nil
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"No Connection Alert"];
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
+ (instancetype)deleteMapProhibitedAlert {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"downloader_delete_map")
message:L(@"downloader_delete_map_while_routing_dialog")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Delete Map Prohibited Alert"];
+ (instancetype)deleteMapProhibitedAlert
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"downloader_delete_map")
message:L(@"downloader_delete_map_while_routing_dialog")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Delete Map Prohibited Alert"];
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
+ (instancetype)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock {
+ (instancetype)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock
{
return [self defaultAlertWithTitle:L(@"please_note")
message:L(@"downloader_delete_map_dialog")
rightButtonTitle:L(@"delete")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:@"Editor unsaved changes on delete"];
log:@"Editor unsaved changes on delete"];
}
+ (instancetype)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"download_over_mobile_header")
message:L(@"download_over_mobile_message")
rightButtonTitle:L(@"use_cellular_data")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:@"No WiFi Alert"];
+ (instancetype)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"download_over_mobile_header")
message:L(@"download_over_mobile_message")
rightButtonTitle:L(@"use_cellular_data")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:@"No WiFi Alert"];
alert.leftButtonAction = cancelBlock;
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
+ (instancetype)endPointNotFoundAlert {
NSString *message = [NSString
stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_end_not_determined"), L(@"dialog_routing_select_closer_end")];
+ (instancetype)endPointNotFoundAlert
{
NSString * message = [NSString
stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_end_not_determined"), L(@"dialog_routing_select_closer_end")];
return [self defaultAlertWithTitle:L(@"dialog_routing_change_end")
message:message
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"End Point Not Found Alert"];
log:@"End Point Not Found Alert"];
}
+ (instancetype)startPointNotFoundAlert {
NSString *message = [NSString
stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_start_not_determined"), L(@"dialog_routing_select_closer_start")];
+ (instancetype)startPointNotFoundAlert
{
NSString * message = [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_start_not_determined"),
L(@"dialog_routing_select_closer_start")];
return [self defaultAlertWithTitle:L(@"dialog_routing_change_start")
message:message
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Start Point Not Found Alert"];
log:@"Start Point Not Found Alert"];
}
+ (instancetype)intermediatePointNotFoundAlert {
+ (instancetype)intermediatePointNotFoundAlert
{
return [self defaultAlertWithTitle:L(@"dialog_routing_change_intermediate")
message:L(@"dialog_routing_intermediate_not_determined")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Intermediate Point Not Found Alert"];
log:@"Intermediate Point Not Found Alert"];
}
+ (instancetype)internalRoutingErrorAlert {
NSString *message =
[NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_application_error"), L(@"dialog_routing_try_again")];
+ (instancetype)internalRoutingErrorAlert
{
NSString * message =
[NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_application_error"), L(@"dialog_routing_try_again")];
return [self defaultAlertWithTitle:L(@"dialog_routing_system_error")
message:message
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Internal Routing Error Alert"];
log:@"Internal Routing Error Alert"];
}
+ (instancetype)incorrectFeaturePositionAlert {
+ (instancetype)incorrectFeaturePositionAlert
{
return [self defaultAlertWithTitle:L(@"dialog_incorrect_feature_position")
message:L(@"message_invalid_feature_position")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Incorrect Feature Possition Alert"];
log:@"Incorrect Feature Possition Alert"];
}
+ (instancetype)notEnoughSpaceAlert {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"downloader_no_space_title")
message:L(@"migration_no_space_message")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Not Enough Space Alert"];
+ (instancetype)notEnoughSpaceAlert
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"downloader_no_space_title")
message:L(@"migration_no_space_message")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Not Enough Space Alert"];
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
+ (instancetype)invalidUserNameOrPasswordAlert {
+ (instancetype)invalidUserNameOrPasswordAlert
{
return [self defaultAlertWithTitle:L(@"invalid_username_or_password")
message:nil
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Invalid User Name or Password Alert"];
log:@"Invalid User Name or Password Alert"];
}
+ (instancetype)noCurrentPositionAlert {
NSString *message = [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_error_location_not_found"),
L(@"dialog_routing_location_turn_wifi")];
+ (instancetype)noCurrentPositionAlert
{
NSString * message = [NSString stringWithFormat:@"%@\n\n%@", L(@"dialog_routing_error_location_not_found"),
L(@"dialog_routing_location_turn_wifi")];
return [self defaultAlertWithTitle:L(@"dialog_routing_check_gps")
message:message
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"No Current Position Alert"];
log:@"No Current Position Alert"];
}
+ (instancetype)disabledLocationAlert {
MWMVoidBlock action = ^{
GetFramework().SwitchMyPositionNextMode();
};
+ (instancetype)disabledLocationAlert
{
MWMVoidBlock action = ^{ GetFramework().SwitchMyPositionNextMode(); };
return [self defaultAlertWithTitle:L(@"dialog_routing_location_turn_on")
message:L(@"dialog_routing_location_unknown_turn_on")
rightButtonTitle:L(@"turn_on")
leftButtonTitle:L(@"later")
rightButtonAction:action
log:@"Disabled Location Alert"];
log:@"Disabled Location Alert"];
}
+ (instancetype)pointsInDifferentMWMAlert {
+ (instancetype)pointsInDifferentMWMAlert
{
return [self defaultAlertWithTitle:L(@"routing_failed_cross_mwm_building")
message:nil
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Points In Different MWM Alert"];
log:@"Points In Different MWM Alert"];
}
+ (instancetype)point2PointAlertWithOkBlock:(MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild {
if (needToRebuild) {
+ (instancetype)point2PointAlertWithOkBlock:(MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild
{
if (needToRebuild)
{
return [self defaultAlertWithTitle:L(@"p2p_only_from_current")
message:L(@"p2p_reroute_from_current")
rightButtonTitle:L(@"ok")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:@"Default Alert"];
} else {
log:@"Default Alert"];
}
else
{
return [self defaultAlertWithTitle:L(@"p2p_only_from_current")
message:nil
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Default Alert"];
log:@"Default Alert"];
}
}
+ (instancetype)downloaderNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"downloader_status_failed")
message:L(@"common_check_internet_connection_dialog")
rightButtonTitle:L(@"downloader_retry")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:@"Downloader No Connection Alert"];
+ (instancetype)downloaderNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"downloader_status_failed")
message:L(@"common_check_internet_connection_dialog")
rightButtonTitle:L(@"downloader_retry")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:@"Downloader No Connection Alert"];
alert.leftButtonAction = cancelBlock;
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
+ (instancetype)downloaderNotEnoughSpaceAlert {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"downloader_no_space_title")
message:L(@"downloader_no_space_message")
rightButtonTitle:L(@"close")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Downloader Not Enough Space Alert"];
+ (instancetype)downloaderNotEnoughSpaceAlert
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"downloader_no_space_title")
message:L(@"downloader_no_space_message")
rightButtonTitle:L(@"close")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Downloader Not Enough Space Alert"];
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
+ (instancetype)downloaderInternalErrorAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"migration_download_error_dialog")
message:nil
rightButtonTitle:L(@"downloader_retry")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:@"Downloader Internal Error Alert"];
+ (instancetype)downloaderInternalErrorAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"migration_download_error_dialog")
message:nil
rightButtonTitle:L(@"downloader_retry")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:@"Downloader Internal Error Alert"];
alert.leftButtonAction = cancelBlock;
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
+ (instancetype)resetChangesAlertWithBlock:(MWMVoidBlock)block {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"editor_reset_edits_message")
message:nil
rightButtonTitle:L(@"editor_reset_edits_button")
leftButtonTitle:L(@"cancel")
rightButtonAction:block
log:@"Reset changes alert"];
+ (instancetype)resetChangesAlertWithBlock:(MWMVoidBlock)block
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"editor_reset_edits_message")
message:nil
rightButtonTitle:L(@"editor_reset_edits_button")
leftButtonTitle:L(@"cancel")
rightButtonAction:block
log:@"Reset changes alert"];
return alert;
}
+ (instancetype)deleteFeatureAlertWithBlock:(MWMVoidBlock)block {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"editor_remove_place_message")
message:nil
rightButtonTitle:L(@"editor_remove_place_button")
leftButtonTitle:L(@"cancel")
rightButtonAction:block
log:@"Delete feature alert"];
+ (instancetype)deleteFeatureAlertWithBlock:(MWMVoidBlock)block
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"editor_remove_place_message")
message:nil
rightButtonTitle:L(@"editor_remove_place_button")
leftButtonTitle:L(@"cancel")
rightButtonAction:block
log:@"Delete feature alert"];
return alert;
}
+ (instancetype)personalInfoWarningAlertWithBlock:(MWMVoidBlock)block {
NSString *message = [NSString
stringWithFormat:@"%@\n%@", L(@"editor_share_to_all_dialog_message_1"), L(@"editor_share_to_all_dialog_message_2")];
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"editor_share_to_all_dialog_title")
message:message
rightButtonTitle:L(@"editor_report_problem_send_button")
leftButtonTitle:L(@"cancel")
rightButtonAction:block
log:@"Personal info warning alert"];
+ (instancetype)personalInfoWarningAlertWithBlock:(MWMVoidBlock)block
{
NSString * message = [NSString stringWithFormat:@"%@\n%@", L(@"editor_share_to_all_dialog_message_1"),
L(@"editor_share_to_all_dialog_message_2")];
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"editor_share_to_all_dialog_title")
message:message
rightButtonTitle:L(@"editor_report_problem_send_button")
leftButtonTitle:L(@"cancel")
rightButtonAction:block
log:@"Personal info warning alert"];
return alert;
}
+ (instancetype)trackWarningAlertWithCancelBlock:(MWMVoidBlock)block {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"recent_track_background_dialog_title")
message:L(@"recent_track_background_dialog_message")
rightButtonTitle:L(@"off_recent_track_background_button")
leftButtonTitle:L(@"continue_button")
rightButtonAction:block
log:@"Track warning alert"];
+ (instancetype)trackWarningAlertWithCancelBlock:(MWMVoidBlock)block
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"recent_track_background_dialog_title")
message:L(@"recent_track_background_dialog_message")
rightButtonTitle:L(@"off_recent_track_background_button")
leftButtonTitle:L(@"continue_button")
rightButtonAction:block
log:@"Track warning alert"];
return alert;
}
+ (instancetype)infoAlert:(NSString *)title text:(NSString *)text {
+ (instancetype)infoAlert:(NSString *)title text:(NSString *)text
{
return [self defaultAlertWithTitle:title
message:text
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:@"Info Alert"];
log:@"Info Alert"];
}
+ (instancetype)convertBookmarksWithCount:(NSUInteger)count okBlock:(MWMVoidBlock)okBlock {
+ (instancetype)convertBookmarksWithCount:(NSUInteger)count okBlock:(MWMVoidBlock)okBlock
{
return [self defaultAlertWithTitle:L(@"bookmarks_detect_title")
message:[NSString stringWithFormat:L(@"bookmarks_detect_message"), count]
rightButtonTitle:L(@"button_convert")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:nil];
log:nil];
}
+ (instancetype)bookmarkConversionErrorAlert {
+ (instancetype)bookmarkConversionErrorAlert
{
return [self defaultAlertWithTitle:L(@"bookmarks_convert_error_title")
message:L(@"bookmarks_convert_error_message")
rightButtonTitle:L(@"ok")
leftButtonTitle:nil
rightButtonAction:nil
log:nil];
log:nil];
}
+ (instancetype)tagsLoadingErrorAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"title_error_downloading_bookmarks")
message:L(@"tags_loading_error_subtitle")
rightButtonTitle:L(@"downloader_retry")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:nil];
+ (instancetype)tagsLoadingErrorAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"title_error_downloading_bookmarks")
message:L(@"tags_loading_error_subtitle")
rightButtonTitle:L(@"downloader_retry")
leftButtonTitle:L(@"cancel")
rightButtonAction:okBlock
log:nil];
alert.leftButtonAction = cancelBlock;
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
+ (instancetype)bugReportAlertWithTitle:(NSString *)title {
MWMDefaultAlert *alert = [self defaultAlertWithTitle:title
message:L(@"bugreport_alert_message")
rightButtonTitle:L(@"report_a_bug")
leftButtonTitle:L(@"cancel")
rightButtonAction:^{ [MailComposer sendBugReportWithTitle:title]; }
log:nil];
+ (instancetype)bugReportAlertWithTitle:(NSString *)title
{
MWMDefaultAlert * alert = [self defaultAlertWithTitle:title
message:L(@"bugreport_alert_message")
rightButtonTitle:L(@"report_a_bug")
leftButtonTitle:L(@"cancel")
rightButtonAction:^{ [MailComposer sendBugReportWithTitle:title]; }
log:nil];
[alert setNeedsCloseAlertAfterEnterBackground];
return alert;
}
@@ -364,14 +397,15 @@ static NSString *const kDefaultAlertNibName = @"MWMDefaultAlert";
rightButtonTitle:(NSString *)rightButtonTitle
leftButtonTitle:(NSString *)leftButtonTitle
rightButtonAction:(MWMVoidBlock)action
log:(NSString *)log {
if (log) {
log:(NSString *)log
{
if (log)
LOG(LINFO, ([log UTF8String]));
}
MWMDefaultAlert *alert = [NSBundle.mainBundle loadNibNamed:kDefaultAlertNibName owner:self options:nil].firstObject;
MWMDefaultAlert * alert = [NSBundle.mainBundle loadNibNamed:kDefaultAlertNibName owner:self options:nil].firstObject;
alert.titleLabel.text = title;
alert.messageLabel.text = message;
if (!message) {
if (!message)
{
alert.dividerTop.constant = kDividerTopConstant;
[alert layoutIfNeeded];
}
@@ -380,10 +414,13 @@ static NSString *const kDefaultAlertNibName = @"MWMDefaultAlert";
[alert.rightButton setTitle:rightButtonTitle forState:UIControlStateDisabled];
alert.rightButtonAction = action;
if (leftButtonTitle) {
if (leftButtonTitle)
{
[alert.leftButton setTitle:leftButtonTitle forState:UIControlStateNormal];
[alert.leftButton setTitle:leftButtonTitle forState:UIControlStateDisabled];
} else {
}
else
{
alert.vDivider.hidden = YES;
alert.leftButton.hidden = YES;
alert.rightButtonWidth.constant = [alert.subviews.firstObject width];
@@ -393,11 +430,13 @@ static NSString *const kDefaultAlertNibName = @"MWMDefaultAlert";
#pragma mark - Actions
- (IBAction)rightButtonTap {
- (IBAction)rightButtonTap
{
[self close:self.rightButtonAction];
}
- (IBAction)leftButtonTap {
- (IBAction)leftButtonTap
{
[self close:self.leftButtonAction];
}

View File

@@ -17,34 +17,37 @@ CGFloat const kCellHeight = 32.;
CGFloat const kHeaderHeight = 44.;
CGFloat const kMinimumOffset = 20.;
CGFloat const kAnimationDuration = .05;
} // namespace
} // namespace
@interface MWMDownloadTransitMapAlert () <UITableViewDataSource, UITableViewDelegate, MWMStorageObserver, MWMCircularProgressProtocol>
@interface MWMDownloadTransitMapAlert () <UITableViewDataSource,
UITableViewDelegate,
MWMStorageObserver,
MWMCircularProgressProtocol>
@property(copy, nonatomic) MWMVoidBlock cancelBlock;
@property(copy, nonatomic) MWMDownloadBlock downloadBlock;
@property(copy, nonatomic) MWMVoidBlock downloadCompleteBlock;
@property (nonatomic) MWMCircularProgress * progress;
@property(nonatomic) MWMCircularProgress * progress;
@property (weak, nonatomic) IBOutlet UIView * containerView;
@property (weak, nonatomic) IBOutlet UILabel * titleLabel;
@property (weak, nonatomic) IBOutlet UILabel * messageLabel;
@property (weak, nonatomic) IBOutlet UITableView * dialogsTableView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * tableViewHeight;
@property (nonatomic) MWMDownloaderDialogHeader * listHeader;
@property (nonatomic) BOOL listExpanded;
@property(weak, nonatomic) IBOutlet UIView * containerView;
@property(weak, nonatomic) IBOutlet UILabel * titleLabel;
@property(weak, nonatomic) IBOutlet UILabel * messageLabel;
@property(weak, nonatomic) IBOutlet UITableView * dialogsTableView;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * tableViewHeight;
@property(nonatomic) MWMDownloaderDialogHeader * listHeader;
@property(nonatomic) BOOL listExpanded;
@property (weak, nonatomic) IBOutlet UIView * progressWrapper;
@property (weak, nonatomic) IBOutlet UIView * hDivider;
@property (weak, nonatomic) IBOutlet UIView * vDivider;
@property (weak, nonatomic) IBOutlet UIButton * leftButton;
@property (weak, nonatomic) IBOutlet UIButton * rightButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * dialogsBottomOffset;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * progressWrapperBottomOffset;
@property(weak, nonatomic) IBOutlet UIView * progressWrapper;
@property(weak, nonatomic) IBOutlet UIView * hDivider;
@property(weak, nonatomic) IBOutlet UIView * vDivider;
@property(weak, nonatomic) IBOutlet UIButton * leftButton;
@property(weak, nonatomic) IBOutlet UIButton * rightButton;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * dialogsBottomOffset;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * progressWrapperBottomOffset;
@property (copy, nonatomic) NSArray<NSString *> * countriesNames;
@property (copy, nonatomic) NSString * countriesSize;
@property(copy, nonatomic) NSArray<NSString *> * countriesNames;
@property(copy, nonatomic) NSString * countriesSize;
@end
@@ -62,23 +65,21 @@ CGFloat const kAnimationDuration = .05;
MWMDownloadTransitMapAlert * alert = [self alertWithCountries:countries];
switch (code)
{
case routing::RouterResultCode::InconsistentMWMandRoute:
case routing::RouterResultCode::RouteNotFound:
case routing::RouterResultCode::RouteFileNotExist:
alert.titleLabel.text = L(@"dialog_routing_download_files");
alert.messageLabel.text = L(@"dialog_routing_download_and_update_all");
break;
case routing::RouterResultCode::FileTooOld:
alert.titleLabel.text = L(@"dialog_routing_download_files");
alert.messageLabel.text = L(@"dialog_routing_download_and_update_maps");
break;
case routing::RouterResultCode::NeedMoreMaps:
alert.titleLabel.text = L(@"dialog_routing_download_and_build_cross_route");
alert.messageLabel.text = L(@"dialog_routing_download_cross_route");
break;
default:
NSAssert(false, @"Incorrect code!");
break;
case routing::RouterResultCode::InconsistentMWMandRoute:
case routing::RouterResultCode::RouteNotFound:
case routing::RouterResultCode::RouteFileNotExist:
alert.titleLabel.text = L(@"dialog_routing_download_files");
alert.messageLabel.text = L(@"dialog_routing_download_and_update_all");
break;
case routing::RouterResultCode::FileTooOld:
alert.titleLabel.text = L(@"dialog_routing_download_files");
alert.messageLabel.text = L(@"dialog_routing_download_and_update_maps");
break;
case routing::RouterResultCode::NeedMoreMaps:
alert.titleLabel.text = L(@"dialog_routing_download_and_build_cross_route");
alert.messageLabel.text = L(@"dialog_routing_download_cross_route");
break;
default: NSAssert(false, @"Incorrect code!"); break;
}
alert.cancelBlock = cancelBlock;
alert.downloadBlock = downloadBlock;
@@ -90,8 +91,7 @@ CGFloat const kAnimationDuration = .05;
{
NSAssert(!countries.empty(), @"countries can not be empty.");
MWMDownloadTransitMapAlert * alert =
[NSBundle.mainBundle loadNibNamed:kDownloadTransitMapAlertNibName owner:nil options:nil]
.firstObject;
[NSBundle.mainBundle loadNibNamed:kDownloadTransitMapAlertNibName owner:nil options:nil].firstObject;
alert->m_countries = storage::CountriesVec(countries.begin(), countries.end());
[alert configure];
@@ -113,10 +113,9 @@ CGFloat const kAnimationDuration = .05;
- (void)updateCountriesList
{
auto const & s = GetFramework().GetStorage();
m_countries.erase(
remove_if(m_countries.begin(), m_countries.end(),
[&s](storage::CountryId const & countryId) { return s.HasLatestVersion(countryId); }),
m_countries.end());
m_countries.erase(remove_if(m_countries.begin(), m_countries.end(),
[&s](storage::CountryId const & countryId) { return s.HasLatestVersion(countryId); }),
m_countries.end());
NSMutableArray<NSString *> * titles = [@[] mutableCopy];
MwmSize totalSize = 0;
for (auto const & countryId : m_countries)
@@ -170,16 +169,13 @@ CGFloat const kAnimationDuration = .05;
}
}
- (void)processCountry:(NSString *)countryId
downloadedBytes:(uint64_t)downloadedBytes
totalBytes:(uint64_t)totalBytes
- (void)processCountry:(NSString *)countryId downloadedBytes:(uint64_t)downloadedBytes totalBytes:(uint64_t)totalBytes
{
if (!self.rightButton.hidden ||
find(m_countries.begin(), m_countries.end(), countryId.UTF8String) == m_countries.end())
return;
auto const overallProgress = GetFramework().GetStorage().GetOverallProgress(m_countries);
CGFloat const progressValue =
static_cast<CGFloat>(overallProgress.m_bytesDownloaded) / overallProgress.m_bytesTotal;
CGFloat const progressValue = static_cast<CGFloat>(overallProgress.m_bytesDownloaded) / overallProgress.m_bytesTotal;
self.progress.progress = progressValue;
self.titleLabel.text = [NSString stringWithFormat:@"%@%@%%", L(@"downloading"), @(floor(progressValue * 100))];
}
@@ -210,10 +206,7 @@ CGFloat const kAnimationDuration = .05;
self.rightButton.hidden = YES;
self.dialogsBottomOffset.priority = UILayoutPriorityDefaultHigh;
self.progressWrapperBottomOffset.priority = UILayoutPriorityDefaultHigh;
[UIView animateWithDuration:kAnimationDuration
animations:^{
[self layoutSubviews];
}];
[UIView animateWithDuration:kAnimationDuration animations:^{ [self layoutSubviews]; }];
});
}
@@ -226,12 +219,9 @@ CGFloat const kAnimationDuration = .05;
{
_listExpanded = listExpanded;
[self layoutIfNeeded];
auto const updateCells = ^(BOOL show)
{
auto const updateCells = ^(BOOL show) {
for (MWMDownloaderDialogCell * cell in self.dialogsTableView.visibleCells)
{
cell.titleLabel.alpha = show ? 1. : 0.;
}
[self.dialogsTableView refresh];
};
if (listExpanded)
@@ -240,11 +230,11 @@ CGFloat const kAnimationDuration = .05;
CGFloat const height = [self bounded:actualHeight withHeight:self.superview.height];
self.tableViewHeight.constant = height;
self.dialogsTableView.scrollEnabled = actualHeight > self.tableViewHeight.constant;
[UIView animateWithDuration:kAnimationDuration animations:^{ [self layoutSubviews]; }
completion:^(BOOL finished)
{
[UIView animateWithDuration:kDefaultAnimationDuration animations:^{ updateCells(YES); }];
}];
[UIView animateWithDuration:kAnimationDuration
animations:^{ [self layoutSubviews]; }
completion:^(BOOL finished) {
[UIView animateWithDuration:kDefaultAnimationDuration animations:^{ updateCells(YES); }];
}];
}
else
{
@@ -279,7 +269,9 @@ CGFloat const kAnimationDuration = .05;
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
CGFloat const height = UIInterfaceOrientationIsLandscape(orientation) ? MIN(self.superview.width, self.superview.height) : MAX(self.superview.width, self.superview.height);
CGFloat const height = UIInterfaceOrientationIsLandscape(orientation)
? MIN(self.superview.width, self.superview.height)
: MAX(self.superview.width, self.superview.height);
[self invalidateTableConstraintWithHeight:height];
}
@@ -321,8 +313,8 @@ CGFloat const kAnimationDuration = .05;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Class cls = [MWMDownloaderDialogCell class];
auto cell = static_cast<MWMDownloaderDialogCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
auto cell = static_cast<MWMDownloaderDialogCell *>([tableView dequeueReusableCellWithCellClass:cls
indexPath:indexPath]);
cell.titleLabel.text = self.countriesNames[indexPath.row];
return cell;
}

View File

@@ -5,12 +5,12 @@ static NSString * const kDownloaderDialogHeaderNibName = @"MWMDownloaderDialogHe
@interface MWMDownloaderDialogHeader ()
@property (weak, nonatomic) IBOutlet UILabel * title;
@property (weak, nonatomic) IBOutlet UILabel * size;
@property (weak, nonatomic) IBOutlet UIView * dividerView;
@property (weak, nonatomic) MWMDownloadTransitMapAlert * ownerAlert;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * sizeTrailing;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * titleLeading;
@property(weak, nonatomic) IBOutlet UILabel * title;
@property(weak, nonatomic) IBOutlet UILabel * size;
@property(weak, nonatomic) IBOutlet UIView * dividerView;
@property(weak, nonatomic) MWMDownloadTransitMapAlert * ownerAlert;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * sizeTrailing;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * titleLeading;
@end
@@ -19,8 +19,7 @@ static NSString * const kDownloaderDialogHeaderNibName = @"MWMDownloaderDialogHe
+ (instancetype)headerForOwnerAlert:(MWMDownloadTransitMapAlert *)alert
{
MWMDownloaderDialogHeader * header =
[NSBundle.mainBundle loadNibNamed:kDownloaderDialogHeaderNibName owner:nil options:nil]
.firstObject;
[NSBundle.mainBundle loadNibNamed:kDownloaderDialogHeaderNibName owner:nil options:nil].firstObject;
header.ownerAlert = alert;
return header;
}
@@ -30,10 +29,11 @@ static NSString * const kDownloaderDialogHeaderNibName = @"MWMDownloaderDialogHe
BOOL const currentState = sender.selected;
sender.selected = !currentState;
self.dividerView.hidden = currentState;
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
self.expandImage.transform = sender.selected ? CGAffineTransformMakeRotation(M_PI) : CGAffineTransformIdentity;
}];
[UIView animateWithDuration:kDefaultAnimationDuration
animations:^{
self.expandImage.transform =
sender.selected ? CGAffineTransformMakeRotation(M_PI) : CGAffineTransformIdentity;
}];
[self.ownerAlert showDownloadDetail:sender];
}