From a2de6e2a33b2ac3db0c75b11aff506cebcb0a64a Mon Sep 17 00:00:00 2001 From: Alexander Boriskov Date: Tue, 4 Aug 2020 20:21:51 +0300 Subject: [PATCH] [iOS] Codestyle --- .../AlertController/MWMAlertViewController.h | 14 +- .../AlertController/MWMAlertViewController.mm | 244 +++++----- .../Classes/CustomAlert/BaseAlert/MWMAlert.h | 8 +- .../Classes/CustomAlert/BaseAlert/MWMAlert.mm | 204 ++++---- .../DefaultAlert/MWMDefaultAlert.h | 6 +- .../DefaultAlert/MWMDefaultAlert.mm | 370 +++++++-------- iphone/Maps/Core/Search/MWMSearch.mm | 4 +- .../UI/Search/DatePickerViewController.swift | 10 +- .../MWMSearchHotelsFilterViewController.mm | 434 ++++++++---------- .../Search/GuestsPickerViewController.swift | 4 +- .../Maps/UI/Search/MWMSearchManager+Filter.mm | 58 +-- iphone/Maps/UI/Search/MWMSearchManager.mm | 3 +- 12 files changed, 603 insertions(+), 756 deletions(-) diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h index 431677e190..e2145bd498 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.h @@ -1,17 +1,16 @@ #import "MWMAlert.h" -#import "MWMViewController.h" #import "MWMMobileInternetAlert.h" +#import "MWMViewController.h" @interface MWMAlertViewController : MWMViewController + (nonnull MWMAlertViewController *)activeAlertController; -@property(weak, nonatomic, readonly) UIViewController * _Null_unspecified ownerViewController; +@property(weak, nonatomic, readonly) UIViewController *_Null_unspecified ownerViewController; - (nonnull instancetype)initWithViewController:(nonnull UIViewController *)viewController; - (void)presentRateAlert; -- (void)presentPoint2PointAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock - needToRebuild:(BOOL)needToRebuild; +- (void)presentPoint2PointAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild; - (void)presentRoutingDisclaimerAlertWithOkBlock:(nonnull nonnull MWMVoidBlock)block; - (void)presentDisabledLocationAlert; - (void)presentLocationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock; @@ -65,14 +64,13 @@ leftButtonTitle:(nullable NSString *)leftButtonTitle rightButtonAction:(nullable MWMVoidBlock)action; - - (void)closeAlert:(nullable MWMVoidBlock)completion; - (nonnull instancetype)init __attribute__((unavailable("call -initWithViewController: instead!"))); -+ (nonnull instancetype) new __attribute__((unavailable("call -initWithViewController: instead!"))); ++ (nonnull instancetype)new __attribute__((unavailable("call -initWithViewController: instead!"))); - (nonnull instancetype)initWithCoder:(nonnull NSCoder *)aDecoder - __attribute__((unavailable("call -initWithViewController: instead!"))); + __attribute__((unavailable("call -initWithViewController: instead!"))); - (nonnull instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil - __attribute__((unavailable("call -initWithViewController: instead!"))); + __attribute__((unavailable("call -initWithViewController: instead!"))); @end diff --git a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm index a7c6217c8b..06a34a5b1d 100644 --- a/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm +++ b/iphone/Maps/Classes/CustomAlert/AlertController/MWMAlertViewController.mm @@ -8,27 +8,24 @@ #import "MapsAppDelegate.h" #import "SwiftBridge.h" -static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController"; +static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController"; -@interface MWMAlertViewController () +@interface MWMAlertViewController () -@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 = - static_cast *>(tvc); + UIViewController *mwmController = static_cast *>(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; @@ -36,64 +33,67 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController } - (void)viewWillTransitionToSize:(CGSize)size - withTransitionCoordinator:(id)coordinator -{ + withTransitionCoordinator:(id)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; auto const orient = size.width > size.height ? UIInterfaceOrientationLandscapeLeft : UIInterfaceOrientationPortrait; - [coordinator animateAlongsideTransition:^(id context) { - for (MWMAlert * alert in self.view.subviews) - [alert rotate:orient duration:context.transitionDuration]; - } completion:^(id context) {}]; + [coordinator + animateAlongsideTransition:^(id context) { + for (MWMAlert *alert in self.view.subviews) + [alert rotate:orient duration:context.transitionDuration]; + } + completion:^(id context){ + }]; } #pragma mark - Actions -- (void)presentRateAlert { [self displayAlert:[MWMAlert rateAlert]]; } -- (void)presentLocationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock -{ - if (![MapViewController sharedController].welcomePageController) - [self displayAlert:[MWMAlert locationAlertWithCancelBlock: cancelBlock]]; +- (void)presentRateAlert { + [self displayAlert:[MWMAlert rateAlert]]; } -- (void)presentPoint2PointAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock - needToRebuild:(BOOL)needToRebuild -{ +- (void)presentLocationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock { + if (![MapViewController sharedController].welcomePageController) + [self displayAlert:[MWMAlert locationAlertWithCancelBlock:cancelBlock]]; +} +- (void)presentPoint2PointAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild { [self displayAlert:[MWMAlert point2PointAlertWithOkBlock:okBlock needToRebuild:needToRebuild]]; } -- (void)presentLocationServiceNotSupportedAlert -{ +- (void)presentLocationServiceNotSupportedAlert { [self displayAlert:[MWMAlert locationServiceNotSupportedAlert]]; } -- (void)presentLocationNotFoundAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock -{ +- (void)presentLocationNotFoundAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock { [self displayAlert:[MWMLocationNotFoundAlert alertWithOkBlock:okBlock]]; } -- (void)presentNoConnectionAlert { [self displayAlert:[MWMAlert noConnectionAlert]]; } +- (void)presentNoConnectionAlert { + [self displayAlert:[MWMAlert noConnectionAlert]]; +} - (void)presentSearchQuickFilterNoConnectionAlert { [self displayAlert:[MWMAlert searchQuickFilterNoConnectionAlert]]; } -- (void)presentDeleteMapProhibitedAlert { [self displayAlert:[MWMAlert deleteMapProhibitedAlert]]; } -- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock -{ +- (void)presentDeleteMapProhibitedAlert { + [self displayAlert:[MWMAlert deleteMapProhibitedAlert]]; +} +- (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)presentInternalErrorAlert { [self displayAlert:[MWMAlert internalErrorAlert]]; } -- (void)presentNotEnoughSpaceAlert { [self displayAlert:[MWMAlert notEnoughSpaceAlert]]; } -- (void)presentInvalidUserNameOrPasswordAlert -{ +- (void)presentInternalErrorAlert { + [self displayAlert:[MWMAlert internalErrorAlert]]; +} +- (void)presentNotEnoughSpaceAlert { + [self displayAlert:[MWMAlert notEnoughSpaceAlert]]; +} +- (void)presentInvalidUserNameOrPasswordAlert { [self displayAlert:[MWMAlert invalidUserNameOrPasswordAlert]]; } @@ -101,8 +101,7 @@ 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 @@ -110,78 +109,64 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController downloadCompleteBlock:downloadCompleteBlock]]; } -- (void)presentRoutingDisclaimerAlertWithOkBlock:(MWMVoidBlock)block -{ +- (void)presentRoutingDisclaimerAlertWithOkBlock:(MWMVoidBlock)block { [self displayAlert:[MWMAlert routingDisclaimerAlertWithOkBlock:block]]; } -- (void)presentDisabledLocationAlert { [self displayAlert:[MWMAlert disabledLocationAlert]]; } -- (void)presentAlert:(routing::RouterResultCode)type -{ +- (void)presentDisabledLocationAlert { + [self displayAlert:[MWMAlert disabledLocationAlert]]; +} +- (void)presentAlert:(routing::RouterResultCode)type { [self displayAlert:[MWMAlert alert:type]]; } -- (void)presentDisableAutoDownloadAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock -{ +- (void)presentDisableAutoDownloadAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock { [self displayAlert:[MWMAlert disableAutoDownloadAlertWithOkBlock:okBlock]]; } - (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock - cancelBlock:(nonnull MWMVoidBlock)cancelBlock -{ - [self displayAlert:[MWMAlert downloaderNoConnectionAlertWithOkBlock:okBlock - cancelBlock: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 -{ - [self displayAlert:[MWMAlert downloaderInternalErrorAlertWithOkBlock:okBlock - cancelBlock:cancelBlock]]; + cancelBlock:(nonnull MWMVoidBlock)cancelBlock { + [self displayAlert:[MWMAlert downloaderInternalErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]]; } -- (void)presentDownloaderNeedUpdateAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock -{ +- (void)presentDownloaderNeedUpdateAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock { [self displayAlert:[MWMAlert downloaderNeedUpdateAlertWithOkBlock:okBlock]]; } -- (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)presentSearchNoResultsAlert -{ +- (void)presentSearchNoResultsAlert { Class alertClass = [MWMSearchNoResultsAlert class]; - NSArray<__kindof MWMAlert *> * subviews = self.view.subviews; - MWMSearchNoResultsAlert * alert = nil; - for (MWMAlert * view in subviews) - { + NSArray<__kindof MWMAlert *> *subviews = self.view.subviews; + MWMSearchNoResultsAlert *alert = nil; + for (MWMAlert *view in subviews) { if (![view isKindOfClass:alertClass]) continue; alert = static_cast(view); @@ -189,79 +174,72 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController [self.view bringSubviewToFront:alert]; break; } - if (!alert) - { + if (!alert) { alert = [MWMSearchNoResultsAlert alert]; [self displayAlert:alert]; } [alert update]; } -- (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)presentEditorViralAlert { [self displayAlert:[MWMAlert editorViralAlert]]; } -- (void)presentOsmAuthAlert { [self displayAlert:[MWMAlert osmAuthAlert]]; } +- (void)presentEditorViralAlert { + [self displayAlert:[MWMAlert editorViralAlert]]; +} +- (void)presentOsmAuthAlert { + [self displayAlert:[MWMAlert osmAuthAlert]]; +} - (void)presentCreateBookmarkCategoryAlertWithMaxCharacterNum:(NSUInteger)max minCharacterNum:(NSUInteger)min - callback:(nonnull MWMCheckStringBlock)callback -{ - auto alert = static_cast([MWMAlert - createBookmarkCategoryAlertWithMaxCharacterNum:max - minCharacterNum:min - callback:callback]); + callback:(nonnull MWMCheckStringBlock)callback { + auto alert = + static_cast([MWMAlert createBookmarkCategoryAlertWithMaxCharacterNum:max + minCharacterNum:min + callback:callback]); [self displayAlert:alert]; dispatch_async(dispatch_get_main_queue(), ^{ [alert.textField becomeFirstResponder]; }); } -- (void)presentConvertBookmarksAlertWithCount:(NSUInteger)count block:(nonnull MWMVoidBlock)block -{ +- (void)presentConvertBookmarksAlertWithCount:(NSUInteger)count block:(nonnull MWMVoidBlock)block { auto alert = [MWMAlert convertBookmarksAlertWithCount:count block:block]; [self displayAlert:alert]; } -- (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)presentRestoreBookmarkAlertWithMessage:(nonnull NSString *)message rightButtonAction:(nonnull MWMVoidBlock)rightButton - leftButtonAction:(nonnull MWMVoidBlock)leftButton -{ + leftButtonAction:(nonnull MWMVoidBlock)leftButton { [self displayAlert:[MWMAlert restoreBookmarkAlertWithMessage:message rightButtonAction:rightButton leftButtonAction:leftButton]]; } - (void)presentTagsLoadingErrorAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock - cancelBlock:(nonnull MWMVoidBlock)cancelBlock -{ - [self displayAlert:[MWMAlert tagsLoadingErrorAlertWithOkBlock:okBlock - cancelBlock:cancelBlock]]; + cancelBlock:(nonnull MWMVoidBlock)cancelBlock { + [self displayAlert:[MWMAlert tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]]; } - (void)presentDefaultAlertWithTitle:(nonnull NSString *)title 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 @@ -269,8 +247,7 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController rightButtonAction:action]]; } -- (void)displayAlert:(MWMAlert *)alert -{ +- (void)displayAlert:(MWMAlert *)alert { UIViewController *ownerVC = self.ownerViewController; BOOL isOwnerLoaded = ownerVC.isViewLoaded; if (!isOwnerLoaded) { @@ -279,10 +256,8 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController // 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; } @@ -291,8 +266,7 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController 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; } @@ -314,31 +288,29 @@ 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.; + 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]; } - completion:^(BOOL finished) { - [closeAlert removeFromSuperview]; - if (!showAlert) - { - [self.view removeFromSuperview]; - [self removeFromParentViewController]; - } - if (completion) - completion(); - }]; + if (completion) + completion(); + }]; } @end diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h index 3098ef937d..e8e900f887 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.h @@ -1,7 +1,7 @@ @class MWMAlertViewController; @interface MWMAlert : UIView -@property(weak, nonatomic) MWMAlertViewController * alertController; +@property(weak, nonatomic) MWMAlertViewController *alertController; + (MWMAlert *)rateAlert; + (MWMAlert *)locationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock; @@ -19,11 +19,9 @@ + (MWMAlert *)invalidUserNameOrPasswordAlert; + (MWMAlert *)point2PointAlertWithOkBlock:(MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild; + (MWMAlert *)disableAutoDownloadAlertWithOkBlock:(MWMVoidBlock)okBlock; -+ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock - cancelBlock:(MWMVoidBlock)cancelBlock; ++ (MWMAlert *)downloaderNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock; + (MWMAlert *)downloaderNotEnoughSpaceAlert; -+ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(MWMVoidBlock)okBlock - cancelBlock:(MWMVoidBlock)cancelBlock; ++ (MWMAlert *)downloaderInternalErrorAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock; + (MWMAlert *)downloaderNeedUpdateAlertWithOkBlock:(MWMVoidBlock)okBlock; + (MWMAlert *)placeDoesntExistAlertWithBlock:(MWMStringBlock)block; + (MWMAlert *)resetChangesAlertWithBlock:(MWMVoidBlock)block; diff --git a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm index cedadc630a..cae0270922 100644 --- a/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/BaseAlert/MWMAlert.mm @@ -13,28 +13,31 @@ @implementation MWMAlert -+ (MWMAlert *)rateAlert { return [MWMRateAlert alert]; } ++ (MWMAlert *)rateAlert { + return [MWMRateAlert alert]; +} + (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 { return [MWMDefaultAlert disabledLocationAlert]; } -+ (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock -{ ++ (MWMAlert *)disabledLocationAlert { + return [MWMDefaultAlert disabledLocationAlert]; +} ++ (MWMAlert *)noWiFiAlertWithOkBlock:(MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock { return [MWMDefaultAlert noWiFiAlertWithOkBlock:okBlock andCancelBlock:cancelBlock]; } -+ (MWMAlert *)noConnectionAlert { return [MWMDefaultAlert noConnectionAlert]; } ++ (MWMAlert *)noConnectionAlert { + return [MWMDefaultAlert noConnectionAlert]; +} + (MWMAlert *)searchQuickFilterNoConnectionAlert { return [MWMDefaultAlert searchQuickFilterNoConnectionAlertWithOkBlock:^{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] @@ -42,14 +45,14 @@ completionHandler:NULL]; }]; } -+ (MWMAlert *)deleteMapProhibitedAlert { return [MWMDefaultAlert deleteMapProhibitedAlert]; } -+ (MWMAlert *)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock -{ ++ (MWMAlert *)deleteMapProhibitedAlert { + return [MWMDefaultAlert deleteMapProhibitedAlert]; +} ++ (MWMAlert *)unsavedEditsAlertWithOkBlock:(MWMVoidBlock)okBlock { return [MWMDefaultAlert unsavedEditsAlertWithOkBlock:okBlock]; } -+ (MWMAlert *)locationServiceNotSupportedAlert -{ ++ (MWMAlert *)locationServiceNotSupportedAlert { return [MWMDefaultAlert locationServiceNotSupportedAlert]; } @@ -57,8 +60,7 @@ code:(routing::RouterResultCode)code cancelBlock:(MWMVoidBlock)cancelBlock downloadBlock:(MWMDownloadBlock)downloadBlock - downloadCompleteBlock:(MWMVoidBlock)downloadCompleteBlock -{ + downloadCompleteBlock:(MWMVoidBlock)downloadCompleteBlock { return [MWMDownloadTransitMapAlert downloaderAlertWithMaps:countries code:code cancelBlock:cancelBlock @@ -66,136 +68,130 @@ 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 *)internalErrorAlert { return [MWMDefaultAlert internalErrorAlert]; } -+ (MWMAlert *)notEnoughSpaceAlert { return [MWMDefaultAlert notEnoughSpaceAlert]; } -+ (MWMAlert *)invalidUserNameOrPasswordAlert -{ ++ (MWMAlert *)internalErrorAlert { + return [MWMDefaultAlert internalErrorAlert]; +} ++ (MWMAlert *)notEnoughSpaceAlert { + return [MWMDefaultAlert notEnoughSpaceAlert]; +} ++ (MWMAlert *)invalidUserNameOrPasswordAlert { return [MWMDefaultAlert invalidUserNameOrPasswordAlert]; } -+ (MWMAlert *)disableAutoDownloadAlertWithOkBlock:(MWMVoidBlock)okBlock -{ ++ (MWMAlert *)disableAutoDownloadAlertWithOkBlock:(MWMVoidBlock)okBlock { return [MWMDefaultAlert disableAutoDownloadAlertWithOkBlock:okBlock]; } -+ (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 *)downloaderNeedUpdateAlertWithOkBlock:(MWMVoidBlock)okBlock -{ ++ (MWMAlert *)downloaderNeedUpdateAlertWithOkBlock:(MWMVoidBlock)okBlock { return [MWMDefaultAlert downloaderNeedUpdateAlertWithOkBlock:okBlock]; } -+ (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 *)editorViralAlert { return [MWMEditorViralAlert alert]; } -+ (MWMAlert *)osmAuthAlert { return [MWMOsmAuthAlert alert]; } -+ (MWMAlert *)personalInfoWarningAlertWithBlock:(MWMVoidBlock)block -{ ++ (MWMAlert *)editorViralAlert { + return [MWMEditorViralAlert alert]; +} ++ (MWMAlert *)osmAuthAlert { + return [MWMOsmAuthAlert alert]; +} ++ (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 -{ - return [MWMBCCreateCategoryAlert alertWithMaxCharachersNum:max - minCharactersNum:min - callback:callback]; + callback:(MWMCheckStringBlock)callback { + return [MWMBCCreateCategoryAlert alertWithMaxCharachersNum:max minCharactersNum:min callback:callback]; } -+ (MWMAlert *)convertBookmarksAlertWithCount:(NSUInteger)count block:(MWMVoidBlock)block -{ ++ (MWMAlert *)convertBookmarksAlertWithCount:(NSUInteger)count block:(MWMVoidBlock)block { return [MWMDefaultAlert convertBookmarksWithCount:count okBlock:block]; } -+ (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 *)restoreBookmarkAlertWithMessage:(NSString *)message rightButtonAction:(MWMVoidBlock)rightButton - leftButtonAction:(MWMVoidBlock)leftButton -{ + leftButtonAction:(MWMVoidBlock)leftButton { return [MWMDefaultAlert restoreBookmarkAlertWithMessage:message rightButtonAction:rightButton leftButtonAction:leftButton]; } -+ (MWMAlert *)tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock -{ ++ (MWMAlert *)tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock { return [MWMDefaultAlert tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]; } @@ -203,8 +199,7 @@ message:(NSString *)message rightButtonTitle:(NSString *)rightButtonTitle leftButtonTitle:(NSString *)leftButtonTitle - rightButtonAction:(MWMVoidBlock)action -{ + rightButtonAction:(MWMVoidBlock)action { return [MWMDefaultAlert defaultAlertWithTitle:title message:message rightButtonTitle:rightButtonTitle @@ -213,46 +208,44 @@ statisticsEvent:nil]; } -- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation -{ +- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { // Should override this method if you want custom relayout after rotation. } -- (void)close:(MWMVoidBlock)completion { [self.alertController closeAlert:completion]; } -- (void)setNeedsCloseAlertAfterEnterBackground -{ +- (void)close:(MWMVoidBlock)completion { + [self.alertController closeAlert:completion]; +} +- (void)setNeedsCloseAlertAfterEnterBackground { [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; } -- (void)dealloc { [NSNotificationCenter.defaultCenter removeObserver:self]; } -- (void)applicationDidEnterBackground -{ +- (void)dealloc { + [NSNotificationCenter.defaultCenter removeObserver:self]; +} +- (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)setAlertController:(MWMAlertViewController *)alertController -{ +- (void)setAlertController:(MWMAlertViewController *)alertController { _alertController = alertController; - UIView * view = alertController.view; - UIViewController * ownerViewController = alertController.ownerViewController; + UIView *view = alertController.view; + UIViewController *ownerViewController = alertController.ownerViewController; view.frame = ownerViewController.view.bounds; [ownerViewController.view addSubview:view]; [self addControllerViewToWindow]; @@ -262,8 +255,7 @@ self.frame = view.bounds; } -- (void)layoutSubviews -{ +- (void)layoutSubviews { [super layoutSubviews]; self.frame = self.superview.bounds; [super layoutSubviews]; diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h index 71fdc49c36..7892f84b04 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.h @@ -25,11 +25,9 @@ + (instancetype)locationServiceNotSupportedAlert; + (instancetype)point2PointAlertWithOkBlock:(MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild; + (instancetype)disableAutoDownloadAlertWithOkBlock:(MWMVoidBlock)okBlock; -+ (instancetype)downloaderNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock - cancelBlock:(MWMVoidBlock)cancelBlock; ++ (instancetype)downloaderNoConnectionAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock; + (instancetype)downloaderNotEnoughSpaceAlert; -+ (instancetype)downloaderInternalErrorAlertWithOkBlock:(MWMVoidBlock)okBlock - cancelBlock:(MWMVoidBlock)cancelBlock; ++ (instancetype)downloaderInternalErrorAlertWithOkBlock:(MWMVoidBlock)okBlock cancelBlock:(MWMVoidBlock)cancelBlock; + (instancetype)downloaderNeedUpdateAlertWithOkBlock:(MWMVoidBlock)okBlock; + (instancetype)resetChangesAlertWithBlock:(MWMVoidBlock)block; + (instancetype)deleteFeatureAlertWithBlock:(MWMVoidBlock)block; diff --git a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm index f6290cc9ce..a7e1061f86 100644 --- a/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm +++ b/iphone/Maps/Classes/CustomAlert/DefaultAlert/MWMDefaultAlert.mm @@ -7,26 +7,25 @@ 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; -@property(copy, nonatomic) NSString * statisticsEvent; +@property(copy, nonatomic) NSString *statisticsEvent; @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") @@ -35,8 +34,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -45,8 +43,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"Route File Not Exist Alert"]; } -+ (instancetype)routeNotFoundNoPublicTransportAlert -{ ++ (instancetype)routeNotFoundNoPublicTransportAlert { return [self defaultAlertWithTitle:L(@"transit_not_found") message:nil rightButtonTitle:L(@"ok") @@ -55,8 +52,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -65,8 +61,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -75,15 +70,13 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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 - statisticsEvent:@"No Connection Alert"]; ++ (instancetype)noConnectionAlert { + MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"common_check_internet_connection_dialog") + message:nil + rightButtonTitle:L(@"ok") + leftButtonTitle:nil + rightButtonAction:nil + statisticsEvent:@"No Connection Alert"]; [alert setNeedsCloseAlertAfterEnterBackground]; return alert; } @@ -99,21 +92,18 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; 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 - statisticsEvent:@"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 + statisticsEvent:@"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") @@ -122,24 +112,21 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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 - statisticsEvent:@"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 + statisticsEvent:@"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") @@ -148,11 +135,9 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -161,8 +146,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -171,11 +155,9 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -184,8 +166,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -194,8 +175,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"Incorrect Feature Possition Alert"]; } -+ (instancetype)internalErrorAlert -{ ++ (instancetype)internalErrorAlert { return [self defaultAlertWithTitle:L(@"dialog_routing_system_error") message:L(@"error_system_message") rightButtonTitle:L(@"ok") @@ -204,20 +184,18 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"Internal Error 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 - statisticsEvent:@"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 + statisticsEvent:@"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") @@ -226,11 +204,9 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -239,21 +215,19 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"No Current Position Alert"]; } -+ (instancetype)disabledLocationAlert -{ ++ (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 - statisticsEvent:@"Disabled Location Alert"]; + message:L(@"dialog_routing_location_unknown_turn_on") + rightButtonTitle:L(@"turn_on") + leftButtonTitle:L(@"later") + rightButtonAction:action + statisticsEvent:@"Disabled Location Alert"]; } -+ (instancetype)pointsInDifferentMWMAlert -{ ++ (instancetype)pointsInDifferentMWMAlert { return [self defaultAlertWithTitle:L(@"routing_failed_cross_mwm_building") message:nil rightButtonTitle:L(@"ok") @@ -262,19 +236,15 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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 statisticsEvent:@"Default Alert"]; - } - else - { + } else { return [self defaultAlertWithTitle:L(@"p2p_only_from_current") message:nil rightButtonTitle:L(@"ok") @@ -284,118 +254,106 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; } } -+ (instancetype)disableAutoDownloadAlertWithOkBlock:(MWMVoidBlock)okBlock -{ - MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"disable_auto_download") - message:nil - rightButtonTitle:L(@"_disable") - leftButtonTitle:L(@"cancel") - rightButtonAction:okBlock - statisticsEvent:@"Disable Auto Download Alert"]; ++ (instancetype)disableAutoDownloadAlertWithOkBlock:(MWMVoidBlock)okBlock { + MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"disable_auto_download") + message:nil + rightButtonTitle:L(@"_disable") + leftButtonTitle:L(@"cancel") + rightButtonAction:okBlock + statisticsEvent:@"Disable Auto Download Alert"]; [alert setNeedsCloseAlertAfterEnterBackground]; return 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 - statisticsEvent:@"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 + statisticsEvent:@"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 - statisticsEvent:@"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 + statisticsEvent:@"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 - statisticsEvent:@"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 + statisticsEvent:@"Downloader Internal Error Alert"]; alert.leftButtonAction = cancelBlock; [alert setNeedsCloseAlertAfterEnterBackground]; return alert; } -+ (instancetype)downloaderNeedUpdateAlertWithOkBlock:(MWMVoidBlock)okBlock -{ - MWMDefaultAlert * alert = [self defaultAlertWithTitle:L(@"downloader_need_update_title") - message:L(@"downloader_need_update_message") - rightButtonTitle:L(@"downloader_status_outdated") - leftButtonTitle:L(@"not_now") - rightButtonAction:okBlock - statisticsEvent:@"Downloader Need Update Alert"]; ++ (instancetype)downloaderNeedUpdateAlertWithOkBlock:(MWMVoidBlock)okBlock { + MWMDefaultAlert *alert = [self defaultAlertWithTitle:L(@"downloader_need_update_title") + message:L(@"downloader_need_update_message") + rightButtonTitle:L(@"downloader_status_outdated") + leftButtonTitle:L(@"not_now") + rightButtonAction:okBlock + statisticsEvent:@"Downloader Need Update Alert"]; [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 - statisticsEvent:@"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 + statisticsEvent:@"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 - statisticsEvent:@"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 + statisticsEvent:@"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 - statisticsEvent:@"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 + statisticsEvent:@"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_download") - rightButtonAction:block - statisticsEvent:@"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_download") + rightButtonAction:block + statisticsEvent:@"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") @@ -404,8 +362,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent:@"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") @@ -416,10 +373,8 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; + (instancetype)restoreBookmarkAlertWithMessage:(NSString *)message rightButtonAction:(MWMVoidBlock)rightButton - leftButtonAction:(MWMVoidBlock)leftButton -{ - MWMDefaultAlert * alert = - [NSBundle.mainBundle loadNibNamed:kDefaultAlertNibName owner:self options:nil].firstObject; + leftButtonAction:(MWMVoidBlock)leftButton { + MWMDefaultAlert *alert = [NSBundle.mainBundle loadNibNamed:kDefaultAlertNibName owner:self options:nil].firstObject; alert.titleLabel.text = L(@"bookmarks_restore_title"); alert.messageLabel.text = message; [alert.rightButton setTitle:L(@"restore") forState:UIControlStateNormal]; @@ -429,8 +384,7 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; return alert; } -+ (instancetype)bookmarkConversionErrorAlert -{ ++ (instancetype)bookmarkConversionErrorAlert { return [self defaultAlertWithTitle:L(@"bookmarks_convert_error_title") message:L(@"bookmarks_convert_error_message") rightButtonTitle:L(@"ok") @@ -439,15 +393,13 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; statisticsEvent: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 - statisticsEvent: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 + statisticsEvent:nil]; alert.leftButtonAction = cancelBlock; [alert setNeedsCloseAlertAfterEnterBackground]; return alert; @@ -458,31 +410,25 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; rightButtonTitle:(NSString *)rightButtonTitle leftButtonTitle:(NSString *)leftButtonTitle rightButtonAction:(MWMVoidBlock)action - statisticsEvent:(NSString *)statisticsEvent -{ + statisticsEvent:(NSString *)statisticsEvent { if (statisticsEvent) - [Statistics logEvent:statisticsEvent withParameters:@{kStatAction : kStatOpen}]; - MWMDefaultAlert * alert = - [NSBundle.mainBundle loadNibNamed:kDefaultAlertNibName owner:self options:nil].firstObject; + [Statistics logEvent:statisticsEvent withParameters:@{kStatAction: kStatOpen}]; + 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]; } - + [alert.rightButton setTitle:rightButtonTitle forState:UIControlStateNormal]; [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]; @@ -493,18 +439,16 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert"; #pragma mark - Actions -- (IBAction)rightButtonTap -{ +- (IBAction)rightButtonTap { if (self.statisticsEvent) - [Statistics logEvent:self.statisticsEvent withParameters:@{kStatAction : kStatApply}]; + [Statistics logEvent:self.statisticsEvent withParameters:@{kStatAction: kStatApply}]; [self close:self.rightButtonAction]; } -- (IBAction)leftButtonTap -{ +- (IBAction)leftButtonTap { if (self.statisticsEvent) - [Statistics logEvent:self.statisticsEvent withParameters:@{kStatAction : kStatClose}]; + [Statistics logEvent:self.statisticsEvent withParameters:@{kStatAction: kStatClose}]; [self close:self.leftButtonAction]; } diff --git a/iphone/Maps/Core/Search/MWMSearch.mm b/iphone/Maps/Core/Search/MWMSearch.mm index 6e372fc4a7..d52b67330d 100644 --- a/iphone/Maps/Core/Search/MWMSearch.mm +++ b/iphone/Maps/Core/Search/MWMSearch.mm @@ -274,10 +274,10 @@ booking::filter::Tasks MakeBookingFilterTasks(booking::filter::Params &&availabi [MWMSearch manager].filter = params; [[MWMSearch manager] update]; - std::string priceCategory = strings::JoinAny(params.price, ',', [](auto const & item) { + std::string priceCategory = strings::JoinAny(params.price, ',', [](auto const &item) { return std::to_string(static_cast(item)); }); - std::string types = strings::JoinAny(params.types, ',', [](auto const & item) { + std::string types = strings::JoinAny(params.types, ',', [](auto const &item) { return std::to_string(static_cast(item)); }); diff --git a/iphone/Maps/UI/Search/DatePickerViewController.swift b/iphone/Maps/UI/Search/DatePickerViewController.swift index 52b8c86fb8..4cbcc79449 100644 --- a/iphone/Maps/UI/Search/DatePickerViewController.swift +++ b/iphone/Maps/UI/Search/DatePickerViewController.swift @@ -1,8 +1,8 @@ -import UIKit import DatePicker +import UIKit @objc protocol DatePickerViewControllerDelegate: AnyObject { - func datePicker(_ datePicker: DatePickerViewController, didSelectStartDate startDate:Date, endDate:Date) + func datePicker(_ datePicker: DatePickerViewController, didSelectStartDate startDate: Date, endDate: Date) func datePickerDidClick(_ datePicker: DatePickerViewController, didSelectStartDate startDate: Date?, endDate: Date?) func datePickerDidCancel(_ datePicker: DatePickerViewController) } @@ -34,12 +34,12 @@ import DatePicker override var transitioningDelegate: UIViewControllerTransitioningDelegate? { get { return transitioning } - set { } + set {} } override var modalPresentationStyle: UIModalPresentationStyle { get { return alternativeSizeClass(iPhone: .custom, iPad: .popover) } - set { } + set {} } @IBAction func onDone(_ sender: UIButton) { @@ -64,7 +64,7 @@ extension DatePickerViewController: DatePickerViewDelegate { } delegate?.datePickerDidClick(self, didSelectStartDate: view.startDate, endDate: view.endDate) } - + guard let startDate = view.startDate else { view.startDate = date startDateLabel.text = dateFormatter.string(from: date).capitalized diff --git a/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm b/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm index 948a33a23a..0d2a9bea9b 100644 --- a/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm +++ b/iphone/Maps/UI/Search/Filters/MWMSearchHotelsFilterViewController.mm @@ -6,30 +6,20 @@ #import "Statistics.h" #import "SwiftBridge.h" -namespace -{ -static NSString * const kHotelTypePattern = @"search_hotel_filter_%@"; +namespace { +static NSString *const kHotelTypePattern = @"search_hotel_filter_%@"; -std::array const - kTypes = {{ftypes::IsHotelChecker::Type::Hotel, ftypes::IsHotelChecker::Type::Apartment, - ftypes::IsHotelChecker::Type::CampSite, ftypes::IsHotelChecker::Type::Chalet, - ftypes::IsHotelChecker::Type::GuestHouse, ftypes::IsHotelChecker::Type::Hostel, - ftypes::IsHotelChecker::Type::Motel, ftypes::IsHotelChecker::Type::Resort}}; +std::array const kTypes = { + {ftypes::IsHotelChecker::Type::Hotel, ftypes::IsHotelChecker::Type::Apartment, ftypes::IsHotelChecker::Type::CampSite, + ftypes::IsHotelChecker::Type::Chalet, ftypes::IsHotelChecker::Type::GuestHouse, ftypes::IsHotelChecker::Type::Hostel, + ftypes::IsHotelChecker::Type::Motel, ftypes::IsHotelChecker::Type::Resort}}; -enum class Section -{ - Rating, - PriceCategory, - Type, - Count -}; +enum class Section { Rating, PriceCategory, Type, Count }; -NSAttributedString * makeString(NSString * primaryText, NSDictionary * primaryAttrs, - NSString * secondaryText, NSDictionary * secondaryAttrs) -{ +NSAttributedString *makeString(NSString *primaryText, NSDictionary *primaryAttrs, NSString *secondaryText, + NSDictionary *secondaryAttrs) { auto str = [[NSMutableAttributedString alloc] initWithString:primaryText attributes:primaryAttrs]; - if (secondaryText.length != 0) - { + if (secondaryText.length != 0) { auto secText = [NSString stringWithFormat:@"\n%@", secondaryText]; auto secStr = [[NSAttributedString alloc] initWithString:secText attributes:secondaryAttrs]; [str appendAttributedString:secStr]; @@ -37,101 +27,84 @@ NSAttributedString * makeString(NSString * primaryText, NSDictionary * primaryAt return str.copy; } -void configButton(UIButton * button, NSString * primaryText, NSString * secondaryText) -{ - UIFont * primaryFont = [UIFont regular14]; - UIFont * secondaryFont = [UIFont medium10]; +void configButton(UIButton *button, NSString *primaryText, NSString *secondaryText) { + UIFont *primaryFont = [UIFont regular14]; + UIFont *secondaryFont = [UIFont medium10]; - UIColor * white = [UIColor white]; + UIColor *white = [UIColor white]; - UIImage * linkBlueImage = [UIImage imageWithColor:[UIColor linkBlue]]; - UIImage * linkBlueHighlightedImage = [UIImage imageWithColor:[UIColor linkBlueHighlighted]]; + UIImage *linkBlueImage = [UIImage imageWithColor:[UIColor linkBlue]]; + UIImage *linkBlueHighlightedImage = [UIImage imageWithColor:[UIColor linkBlueHighlighted]]; [button setBackgroundImage:[UIImage imageWithColor:white] forState:UIControlStateNormal]; [button setBackgroundImage:linkBlueImage forState:UIControlStateSelected]; [button setBackgroundImage:linkBlueHighlightedImage forState:UIControlStateHighlighted]; - [button setBackgroundImage:linkBlueHighlightedImage - forState:UIControlStateSelected | UIControlStateHighlighted]; + [button setBackgroundImage:linkBlueHighlightedImage forState:UIControlStateSelected | UIControlStateHighlighted]; - NSDictionary * primarySelected = - @{NSFontAttributeName: primaryFont, NSForegroundColorAttributeName: white}; - NSDictionary * secondarySelected = - @{NSFontAttributeName: secondaryFont, NSForegroundColorAttributeName: white}; - NSAttributedString * titleSelected = - makeString(primaryText, primarySelected, secondaryText, secondarySelected); + NSDictionary *primarySelected = @{NSFontAttributeName: primaryFont, NSForegroundColorAttributeName: white}; + NSDictionary *secondarySelected = @{NSFontAttributeName: secondaryFont, NSForegroundColorAttributeName: white}; + NSAttributedString *titleSelected = makeString(primaryText, primarySelected, secondaryText, secondarySelected); [button setAttributedTitle:titleSelected forState:UIControlStateSelected]; [button setAttributedTitle:titleSelected forState:UIControlStateHighlighted]; - [button setAttributedTitle:titleSelected - forState:UIControlStateSelected | UIControlStateHighlighted]; + [button setAttributedTitle:titleSelected forState:UIControlStateSelected | UIControlStateHighlighted]; - NSDictionary * primaryNormal = @{ - NSFontAttributeName: primaryFont, - NSForegroundColorAttributeName: [UIColor blackPrimaryText] - }; - NSDictionary * secondaryNormal = @{ - NSFontAttributeName: secondaryFont, - NSForegroundColorAttributeName: [UIColor blackSecondaryText] - }; - NSAttributedString * titleNormal = - makeString(primaryText, primaryNormal, secondaryText, secondaryNormal); + NSDictionary *primaryNormal = + @{NSFontAttributeName: primaryFont, NSForegroundColorAttributeName: [UIColor blackPrimaryText]}; + NSDictionary *secondaryNormal = + @{NSFontAttributeName: secondaryFont, NSForegroundColorAttributeName: [UIColor blackSecondaryText]}; + NSAttributedString *titleNormal = makeString(primaryText, primaryNormal, secondaryText, secondaryNormal); [button setAttributedTitle:titleNormal forState:UIControlStateNormal]; button.titleLabel.textAlignment = NSTextAlignmentCenter; } } // namespace -@interface MWMSearchHotelsFilterViewController () -{ +@interface MWMSearchHotelsFilterViewController () { std::unordered_set m_selectedTypes; } -@property(nonatomic) MWMFilterRatingCell * rating; -@property(nonatomic) MWMFilterPriceCategoryCell * price; -@property(nonatomic) MWMFilterCollectionHolderCell * type; -@property(weak, nonatomic) IBOutlet UITableView * tableView; -@property(weak, nonatomic) IBOutlet UIButton * doneButton; +@property(nonatomic) MWMFilterRatingCell *rating; +@property(nonatomic) MWMFilterPriceCategoryCell *price; +@property(nonatomic) MWMFilterCollectionHolderCell *type; +@property(weak, nonatomic) IBOutlet UITableView *tableView; +@property(weak, nonatomic) IBOutlet UIButton *doneButton; @end @implementation MWMSearchHotelsFilterViewController -+ (MWMSearchHotelsFilterViewController *)controller -{ - NSString * identifier = [self className]; - return static_cast( - [self controllerWithIdentifier:identifier]); ++ (MWMSearchHotelsFilterViewController *)controller { + NSString *identifier = [self className]; + return static_cast([self controllerWithIdentifier:identifier]); } -- (void)applyParams:(MWMHotelParams *)params -{ +- (void)applyParams:(MWMHotelParams *)params { m_selectedTypes = params.types; [self.type.collectionView reloadData]; using namespace place_page::rating; auto ratingCell = self.rating; ratingCell.any.selected = NO; - switch (params.rating) - { - case FilterRating::Any: - ratingCell.any.selected = YES; - break; - case FilterRating::Good: - ratingCell.good.selected = YES; - break; - case FilterRating::VeryGood: - ratingCell.veryGood.selected = YES; - break; - case FilterRating::Excellent: - ratingCell.excellent.selected = YES; - break; + switch (params.rating) { + case FilterRating::Any: + ratingCell.any.selected = YES; + break; + case FilterRating::Good: + ratingCell.good.selected = YES; + break; + case FilterRating::VeryGood: + ratingCell.veryGood.selected = YES; + break; + case FilterRating::Excellent: + ratingCell.excellent.selected = YES; + break; } auto priceCell = self.price; for (auto const filter : params.price) { - switch (filter) - { + switch (filter) { case Price::Any: break; case Price::One: @@ -147,15 +120,13 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar } } -- (void)viewDidLoad -{ +- (void)viewDidLoad { [super viewDidLoad]; [self configNavigationBar:self.navigationController.navigationBar]; [self configNavigationItem:self.navigationItem]; } -- (void)viewWillAppear:(BOOL)animated -{ +- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [Statistics logEvent:kStatSearchFilterOpen withParameters:@{kStatCategory: kStatHotel, kStatNetwork: [Statistics connectionTypeString]}]; @@ -164,63 +135,56 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar [self setNeedsStatusBarAppearanceUpdate]; } -- (void)reset -{ +- (void)reset { self.rating = nil; self.price = nil; self.type = nil; [self.tableView reloadData]; } -- (void)refreshStatusBarAppearance -{ +- (void)refreshStatusBarAppearance { self.navigationController.navigationBar.barStyle = UIBarStyleBlack; } -- (void)refreshViewAppearance -{ +- (void)refreshViewAppearance { self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.contentInset = {-20, 0, 80, 0}; } -- (void)refreshDoneButtonAppearance -{ - UIButton * doneButton = self.doneButton; +- (void)refreshDoneButtonAppearance { + UIButton *doneButton = self.doneButton; doneButton.backgroundColor = [UIColor linkBlue]; doneButton.titleLabel.font = [UIFont bold16]; [doneButton setTitle:L(@"search") forState:UIControlStateNormal]; [doneButton setTitleColor:[UIColor white] forState:UIControlStateNormal]; } -- (void)refreshAppearance -{ +- (void)refreshAppearance { [self refreshStatusBarAppearance]; [self refreshViewAppearance]; [self refreshDoneButtonAppearance]; } -- (IBAction)applyAction -{ +- (IBAction)applyAction { [MWMEye bookingFilterUsed]; [self.delegate hotelsFilterViewController:self didSelectParams:[self getSelectedHotelParams]]; } -- (MWMHotelParams *)getSelectedHotelParams -{ - MWMHotelParams * params = [MWMHotelParams new]; +- (MWMHotelParams *)getSelectedHotelParams { + MWMHotelParams *params = [MWMHotelParams new]; params.types = m_selectedTypes; using namespace place_page::rating; - MWMFilterRatingCell * rating = self.rating; + MWMFilterRatingCell *rating = self.rating; if (rating.good.selected) params.rating = FilterRating::Good; else if (rating.veryGood.selected) params.rating = FilterRating::VeryGood; else if (rating.excellent.selected) params.rating = FilterRating::Excellent; - - MWMFilterPriceCategoryCell * price = self.price; - std::unordered_setpriceFilter; + + MWMFilterPriceCategoryCell *price = self.price; + std::unordered_set priceFilter; if (price.one.selected) priceFilter.insert(Price::One); if (price.two.selected) @@ -228,244 +192,234 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar if (price.three.selected) priceFilter.insert(Price::Three); params.price = priceFilter; - + return params; } -- (void)initialRatingConfig -{ - MWMFilterRatingCell * rating = self.rating; +- (void)initialRatingConfig { + MWMFilterRatingCell *rating = self.rating; configButton(rating.any, L(@"booking_filters_rating_any"), nil); configButton(rating.good, L(@"7.0+"), L(@"booking_filters_ragting_good")); configButton(rating.veryGood, L(@"8.0+"), L(@"booking_filters_rating_very_good")); configButton(rating.excellent, L(@"9.0+"), L(@"booking_filters_rating_excellent")); } -- (void)initialPriceCategoryConfig -{ - MWMFilterPriceCategoryCell * price = self.price; +- (void)initialPriceCategoryConfig { + MWMFilterPriceCategoryCell *price = self.price; configButton(price.one, L(@"$"), nil); configButton(price.two, L(@"$$"), nil); configButton(price.three, L(@"$$$"), nil); } -- (void)initialTypeConfig -{ +- (void)initialTypeConfig { [self.type configWithTableView:self.tableView]; } -- (void)resetRating -{ - MWMFilterRatingCell * rating = self.rating; +- (void)resetRating { + MWMFilterRatingCell *rating = self.rating; rating.any.selected = YES; rating.good.selected = NO; rating.veryGood.selected = NO; rating.excellent.selected = NO; } -- (void)resetPriceCategory -{ - MWMFilterPriceCategoryCell * price = self.price; +- (void)resetPriceCategory { + MWMFilterPriceCategoryCell *price = self.price; price.one.selected = NO; price.two.selected = NO; price.three.selected = NO; } -- (void)resetTypes -{ +- (void)resetTypes { m_selectedTypes.clear(); } #pragma mark - UITableViewDataSource -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return base::Underlying(Section::Count); } -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -{ +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - UITableViewCell * cell = nil; - switch (static_cast
(indexPath.section)) - { - case Section::Rating: - cell = [tableView dequeueReusableCellWithIdentifier:[MWMFilterRatingCell className] forIndexPath:indexPath]; - if (self.rating != cell) - { - self.rating = static_cast(cell); - [self resetRating]; - } - [self initialRatingConfig]; - break; - case Section::PriceCategory: - cell = [tableView dequeueReusableCellWithIdentifier:[MWMFilterPriceCategoryCell className] forIndexPath:indexPath]; - if (self.price != cell) - { - self.price = static_cast(cell); - [self resetPriceCategory]; - } - [self initialPriceCategoryConfig]; - break; - case Section::Type: - cell = [tableView dequeueReusableCellWithIdentifier:[MWMFilterCollectionHolderCell className] forIndexPath:indexPath]; - if (self.type != cell) - { - self.type = static_cast(cell); - [self resetTypes]; - } - [self initialTypeConfig]; - break; - case Section::Count: - NSAssert(false, @"Incorrect section!"); - break; +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = nil; + switch (static_cast
(indexPath.section)) { + case Section::Rating: + cell = [tableView dequeueReusableCellWithIdentifier:[MWMFilterRatingCell className] forIndexPath:indexPath]; + if (self.rating != cell) { + self.rating = static_cast(cell); + [self resetRating]; + } + [self initialRatingConfig]; + break; + case Section::PriceCategory: + cell = [tableView dequeueReusableCellWithIdentifier:[MWMFilterPriceCategoryCell className] + forIndexPath:indexPath]; + if (self.price != cell) { + self.price = static_cast(cell); + [self resetPriceCategory]; + } + [self initialPriceCategoryConfig]; + break; + case Section::Type: + cell = [tableView dequeueReusableCellWithIdentifier:[MWMFilterCollectionHolderCell className] + forIndexPath:indexPath]; + if (self.type != cell) { + self.type = static_cast(cell); + [self resetTypes]; + } + [self initialTypeConfig]; + break; + case Section::Count: + NSAssert(false, @"Incorrect section!"); + break; } return cell; } -- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section -{ - switch (static_cast
(section)) - { - case Section::Rating: return L(@"booking_filters_rating"); - case Section::PriceCategory: return L(@"booking_filters_price_category"); - case Section::Type: return L(@"search_hotel_filters_type"); - default: return nil; +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { + switch (static_cast
(section)) { + case Section::Rating: + return L(@"booking_filters_rating"); + case Section::PriceCategory: + return L(@"booking_filters_price_category"); + case Section::Type: + return L(@"search_hotel_filters_type"); + default: + return nil; } } #pragma mark - UICollectionViewDelegate & UICollectionViewDataSource -- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath -{ - MWMFilterTypeCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:[MWMFilterTypeCell className] - forIndexPath:indexPath]; +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView + cellForItemAtIndexPath:(NSIndexPath *)indexPath { + MWMFilterTypeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[MWMFilterTypeCell className] + forIndexPath:indexPath]; auto const type = kTypes[indexPath.row]; auto str = [NSString stringWithFormat:kHotelTypePattern, @(ftypes::IsHotelChecker::GetHotelTypeTag(type))]; cell.tagName.text = L(str); - - //we need to do this because of bug - ios 12 doesnt apply layout to cells until scrolling - if (@available(iOS 12.0, *)) - { + + // we need to do this because of bug - ios 12 doesnt apply layout to cells until scrolling + if (@available(iOS 12.0, *)) { [cell layoutIfNeeded]; } - + auto const selected = m_selectedTypes.find(type) != m_selectedTypes.end(); cell.selected = selected; - if (selected) - { - [collectionView selectItemAtIndexPath:indexPath - animated:NO - scrollPosition:UICollectionViewScrollPositionNone]; + if (selected) { + [collectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionNone]; } return cell; } -- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section -{ +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return kTypes.size(); } -- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath -{ +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { auto const type = kTypes[indexPath.row]; auto typeString = @""; - switch (type) - { - case ftypes::IsHotelChecker::Type::Hotel: typeString = kStatHotel; break; - case ftypes::IsHotelChecker::Type::Apartment: typeString = kStatApartment; break; - case ftypes::IsHotelChecker::Type::CampSite: typeString = kStatCampSite; break; - case ftypes::IsHotelChecker::Type::Chalet: typeString = kStatChalet; break; - case ftypes::IsHotelChecker::Type::GuestHouse: typeString = kStatGuestHouse; break; - case ftypes::IsHotelChecker::Type::Hostel: typeString = kStatHostel; break; - case ftypes::IsHotelChecker::Type::Motel: typeString = kStatMotel; break; - case ftypes::IsHotelChecker::Type::Resort: typeString = kStatResort; break; - case ftypes::IsHotelChecker::Type::Count: break; + switch (type) { + case ftypes::IsHotelChecker::Type::Hotel: + typeString = kStatHotel; + break; + case ftypes::IsHotelChecker::Type::Apartment: + typeString = kStatApartment; + break; + case ftypes::IsHotelChecker::Type::CampSite: + typeString = kStatCampSite; + break; + case ftypes::IsHotelChecker::Type::Chalet: + typeString = kStatChalet; + break; + case ftypes::IsHotelChecker::Type::GuestHouse: + typeString = kStatGuestHouse; + break; + case ftypes::IsHotelChecker::Type::Hostel: + typeString = kStatHostel; + break; + case ftypes::IsHotelChecker::Type::Motel: + typeString = kStatMotel; + break; + case ftypes::IsHotelChecker::Type::Resort: + typeString = kStatResort; + break; + case ftypes::IsHotelChecker::Type::Count: + break; } - [Statistics logEvent:kStatSearchFilterClick withParameters:@{kStatCategory: kStatHotel, - kStatType: typeString}]; + [Statistics logEvent:kStatSearchFilterClick withParameters:@{kStatCategory: kStatHotel, kStatType: typeString}]; m_selectedTypes.emplace(type); } -- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath -{ +- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath { auto const type = kTypes[indexPath.row]; m_selectedTypes.erase(type); } #pragma mark - Navigation bar -- (IBAction)closeAction -{ +- (IBAction)closeAction { [Statistics logEvent:kStatSearchFilterCancel withParameters:@{kStatCategory: kStatHotel}]; [self.delegate hotelsFilterViewControllerDidCancel:self]; } -- (IBAction)resetAction -{ +- (IBAction)resetAction { [Statistics logEvent:kStatSearchFilterReset withParameters:@{kStatCategory: kStatHotel}]; [self reset]; } -- (void)configNavigationBar:(UINavigationBar *)navBar -{ - if (IPAD) - { - UIColor * white = [UIColor white]; +- (void)configNavigationBar:(UINavigationBar *)navBar { + if (IPAD) { + UIColor *white = [UIColor white]; navBar.tintColor = white; navBar.barTintColor = white; navBar.translucent = NO; } navBar.titleTextAttributes = @{ - NSForegroundColorAttributeName: IPAD ? [UIColor blackPrimaryText] : [UIColor whiteColor], - NSFontAttributeName: [UIFont bold17] - }; + NSForegroundColorAttributeName: IPAD ? [UIColor blackPrimaryText] : [UIColor whiteColor], + NSFontAttributeName: [UIFont bold17] + }; } -- (void)configNavigationItem:(UINavigationItem *)navItem -{ - UIFont * textFont = [UIFont regular17]; - - UIColor * normalStateColor = IPAD ? [UIColor linkBlue] : [UIColor whiteColor]; - UIColor * highlightedStateColor = IPAD ? [UIColor linkBlueHighlighted] : [UIColor whiteColor]; - UIColor * disabledStateColor = [UIColor lightGrayColor]; - +- (void)configNavigationItem:(UINavigationItem *)navItem { + UIFont *textFont = [UIFont regular17]; + + UIColor *normalStateColor = IPAD ? [UIColor linkBlue] : [UIColor whiteColor]; + UIColor *highlightedStateColor = IPAD ? [UIColor linkBlueHighlighted] : [UIColor whiteColor]; + UIColor *disabledStateColor = [UIColor lightGrayColor]; + navItem.title = L(@"booking_filters"); navItem.rightBarButtonItem.title = L(@"booking_filters_reset"); + [navItem.rightBarButtonItem + setTitleTextAttributes:@{NSForegroundColorAttributeName: normalStateColor, NSFontAttributeName: textFont} + forState:UIControlStateNormal]; [navItem.rightBarButtonItem setTitleTextAttributes:@{ - NSForegroundColorAttributeName: normalStateColor, - NSFontAttributeName: textFont - } - forState:UIControlStateNormal]; - [navItem.rightBarButtonItem setTitleTextAttributes:@{ - NSForegroundColorAttributeName: highlightedStateColor, - } + NSForegroundColorAttributeName: highlightedStateColor, + } forState:UIControlStateHighlighted]; [navItem.rightBarButtonItem setTitleTextAttributes:@{ - NSForegroundColorAttributeName: disabledStateColor, - } + NSForegroundColorAttributeName: disabledStateColor, + } forState:UIControlStateDisabled]; - + + [navItem.leftBarButtonItem + setTitleTextAttributes:@{NSForegroundColorAttributeName: normalStateColor, NSFontAttributeName: textFont} + forState:UIControlStateNormal]; [navItem.leftBarButtonItem setTitleTextAttributes:@{ - NSForegroundColorAttributeName: normalStateColor, - NSFontAttributeName: textFont - } - forState:UIControlStateNormal]; - [navItem.leftBarButtonItem setTitleTextAttributes:@{ - NSForegroundColorAttributeName: highlightedStateColor, - } + NSForegroundColorAttributeName: highlightedStateColor, + } forState:UIControlStateHighlighted]; - + [navItem.leftBarButtonItem setTitleTextAttributes:@{ - NSForegroundColorAttributeName: disabledStateColor, - } + NSForegroundColorAttributeName: disabledStateColor, + } forState:UIControlStateDisabled]; } diff --git a/iphone/Maps/UI/Search/GuestsPickerViewController.swift b/iphone/Maps/UI/Search/GuestsPickerViewController.swift index c0800cb9b9..230dc56705 100644 --- a/iphone/Maps/UI/Search/GuestsPickerViewController.swift +++ b/iphone/Maps/UI/Search/GuestsPickerViewController.swift @@ -42,12 +42,12 @@ override var transitioningDelegate: UIViewControllerTransitioningDelegate? { get { return transitioning } - set { } + set {} } override var modalPresentationStyle: UIModalPresentationStyle { get { return alternativeSizeClass(iPhone: .custom, iPad: .popover) } - set { } + set {} } @IBAction func onDone(_ sender: UIButton) { diff --git a/iphone/Maps/UI/Search/MWMSearchManager+Filter.mm b/iphone/Maps/UI/Search/MWMSearchManager+Filter.mm index c03c1385cc..8afdb074f4 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager+Filter.mm +++ b/iphone/Maps/UI/Search/MWMSearchManager+Filter.mm @@ -1,12 +1,12 @@ +#import #import "MWMSearch.h" #import "MWMSearchManager+Filter.h" -#import #import "Statistics.h" @interface MWMSearchManager () -@property(weak, nonatomic, readonly) UIViewController * ownerController; -@property(weak, nonatomic) IBOutlet UIButton * actionBarView; +@property(weak, nonatomic, readonly) UIViewController *ownerController; +@property(weak, nonatomic) IBOutlet UIButton *actionBarView; @property(nonatomic, copy) MWMVoidBlock onFinishCallback; @@ -14,65 +14,57 @@ @implementation MWMSearchManager (Filter) -- (void)showHotelFilterWithParams:(MWMHotelParams *)params - onFinishCallback:(MWMVoidBlock)callback -{ - MWMSearchHotelsFilterViewController * filterVC = - (MWMSearchHotelsFilterViewController *)[MWMSearchHotelsFilterViewController controller]; +- (void)showHotelFilterWithParams:(MWMHotelParams *)params onFinishCallback:(MWMVoidBlock)callback { + MWMSearchHotelsFilterViewController *filterVC = + (MWMSearchHotelsFilterViewController *)[MWMSearchHotelsFilterViewController controller]; filterVC.delegate = self; - - UINavigationController * navController = - [[UINavigationController alloc] initWithRootViewController:filterVC]; - UIViewController * ownerController = self.ownerController; - - if (IPAD) - { + + UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:filterVC]; + UIViewController *ownerController = self.ownerController; + + if (IPAD) { navController.modalPresentationStyle = UIModalPresentationPopover; - UIPopoverPresentationController * popover = navController.popoverPresentationController; + UIPopoverPresentationController *popover = navController.popoverPresentationController; popover.sourceView = self.actionBarView; popover.sourceRect = self.actionBarView.bounds; popover.permittedArrowDirections = UIPopoverArrowDirectionLeft; } - + self.onFinishCallback = callback; - [ownerController presentViewController:navController animated:YES completion:^{ - if (params) - [filterVC applyParams:params]; - }]; + [ownerController presentViewController:navController + animated:YES + completion:^{ + if (params) + [filterVC applyParams:params]; + }]; } -- (IBAction)updateTap -{ +- (IBAction)updateTap { [self showHotelFilterWithParams:[MWMSearch getFilter] onFinishCallback:nil]; [Statistics logEvent:kStatSearchContextAreaClick withParameters:@{kStatValue: kStatFilter}]; } -- (IBAction)clearFilter -{ +- (IBAction)clearFilter { [MWMSearch clearFilter]; } -- (NSString *)onFinishCallback -{ +- (NSString *)onFinishCallback { return objc_getAssociatedObject(self, @selector(onFinishCallback)); } -- (void)setOnFinishCallback:(NSString *)onFinishCallback -{ +- (void)setOnFinishCallback:(NSString *)onFinishCallback { objc_setAssociatedObject(self, @selector(onFinishCallback), onFinishCallback, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } #pragma mark - MWMSearchHotelsFilterViewControllerDelegate - (void)hotelsFilterViewController:(MWMSearchHotelsFilterViewController *)viewController - didSelectParams:(MWMHotelParams *)params -{ + didSelectParams:(MWMHotelParams *)params { [MWMSearch updateHotelFilterWithParams:params]; [self.ownerController dismissViewControllerAnimated:YES completion:self.onFinishCallback]; } -- (void)hotelsFilterViewControllerDidCancel:(MWMSearchHotelsFilterViewController *)viewController -{ +- (void)hotelsFilterViewControllerDidCancel:(MWMSearchHotelsFilterViewController *)viewController { [self.ownerController dismissViewControllerAnimated:YES completion:nil]; } diff --git a/iphone/Maps/UI/Search/MWMSearchManager.mm b/iphone/Maps/UI/Search/MWMSearchManager.mm index f1ef8e6095..5649f2d8bf 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager.mm +++ b/iphone/Maps/UI/Search/MWMSearchManager.mm @@ -475,8 +475,7 @@ using Observers = NSHashTable; kStatSearchRooms: @(rooms), kStatSearchAdults: @(adults), kStatSearchChildren: @(children), - kStatSearchInfants: @(infants) - }]; + kStatSearchInfants: @(infants)}]; } - (void)guestsPickerDidCancel:(GuestsPickerViewController *)guestsPicker {