Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
|
|
@ -0,0 +1,18 @@
|
|||
#import "MWMAlert+CPP.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
|
||||
#include "routing/router.hpp"
|
||||
#include "routing/routing_callbacks.hpp"
|
||||
#include "storage/storage.hpp"
|
||||
#include "storage/storage_defines.hpp"
|
||||
|
||||
@interface MWMAlertViewController (CPP)
|
||||
|
||||
- (void)presentAlert:(routing::RouterResultCode)type;
|
||||
- (void)presentDownloaderAlertWithCountries:(storage::CountriesSet const &)countries
|
||||
code:(routing::RouterResultCode)code
|
||||
cancelBlock:(nonnull MWMVoidBlock)cancelBlock
|
||||
downloadBlock:(nonnull MWMDownloadBlock)downloadBlock
|
||||
downloadCompleteBlock:(nonnull MWMVoidBlock)downloadCompleteBlock;
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
#import "MWMAlert.h"
|
||||
#import "MWMMobileInternetAlert.h"
|
||||
#import "MWMViewController.h"
|
||||
|
||||
@interface MWMAlertViewController : MWMViewController
|
||||
|
||||
+ (nonnull MWMAlertViewController *)activeAlertController;
|
||||
|
||||
@property(weak, nonatomic, readonly) UIViewController *_Null_unspecified ownerViewController;
|
||||
|
||||
- (nonnull instancetype)initWithViewController:(nonnull UIViewController *)viewController;
|
||||
- (void)presentPoint2PointAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild;
|
||||
- (void)presentRoutingDisclaimerAlertWithOkBlock:(nonnull nonnull MWMVoidBlock)block;
|
||||
- (void)presentDisabledLocationAlert;
|
||||
- (void)presentLocationAlertWithCancelBlock:(MWMVoidBlock _Nonnull )cancelBlock;
|
||||
- (void)presentLocationServicesDisabledAlert;
|
||||
- (void)presentLocationServiceNotSupportedAlert;
|
||||
- (void)presentNoConnectionAlert;
|
||||
- (void)presentDeleteMapProhibitedAlert;
|
||||
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock;
|
||||
- (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock andCancelBlock:(nullable MWMVoidBlock)cancelBlock;
|
||||
- (void)presentIncorrectFeauturePositionAlert;
|
||||
- (void)presentNotEnoughSpaceAlert;
|
||||
- (void)presentInvalidUserNameOrPasswordAlert;
|
||||
- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
|
||||
cancelBlock:(nonnull MWMVoidBlock)cancelBlock;
|
||||
- (void)presentDownloaderNotEnoughSpaceAlert;
|
||||
- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
|
||||
cancelBlock:(nonnull MWMVoidBlock)cancelBlock;
|
||||
- (void)presentPlaceDoesntExistAlertWithBlock:(nonnull MWMStringBlock)block;
|
||||
- (void)presentResetChangesAlertWithBlock:(nonnull MWMVoidBlock)block;
|
||||
- (void)presentDeleteFeatureAlertWithBlock:(nonnull MWMVoidBlock)block;
|
||||
- (void)presentPersonalInfoWarningAlertWithBlock:(nonnull MWMVoidBlock)block;
|
||||
- (void)presentTrackWarningAlertWithCancelBlock:(nonnull MWMVoidBlock)block;
|
||||
- (void)presentMobileInternetAlertWithBlock:(nonnull MWMMobileInternetAlertCompletionBlock)block;
|
||||
- (void)presentInfoAlert:(nonnull NSString *)title text:(nonnull NSString *)text;
|
||||
- (void)presentInfoAlert:(nonnull NSString *)title;
|
||||
- (void)presentCreateBookmarkCategoryAlertWithMaxCharacterNum:(NSUInteger)max
|
||||
minCharacterNum:(NSUInteger)min
|
||||
callback:(nonnull MWMCheckStringBlock)callback;
|
||||
|
||||
- (void)presentBookmarkConversionErrorAlert;
|
||||
- (void)presentBugReportAlertWithTitle:(nonnull NSString *)title;
|
||||
|
||||
- (void)presentDefaultAlertWithTitle:(nonnull NSString *)title
|
||||
message:(nullable NSString *)message
|
||||
rightButtonTitle:(nonnull NSString *)rightButtonTitle
|
||||
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)initWithCoder:(nonnull NSCoder *)aDecoder
|
||||
__attribute__((unavailable("call -initWithViewController: instead!")));
|
||||
- (nonnull instancetype)initWithNibName:(nullable NSString *)nibNameOrNil
|
||||
bundle:(nullable NSBundle *)nibBundleOrNil
|
||||
__attribute__((unavailable("call -initWithViewController: instead!")));
|
||||
@end
|
||||
|
|
@ -0,0 +1,278 @@
|
|||
#import "MWMAlertViewController+CPP.h"
|
||||
#import "MWMController.h"
|
||||
#import "MWMDownloadTransitMapAlert.h"
|
||||
#import "MWMLocationAlert.h"
|
||||
#import "MapViewController.h"
|
||||
#import "MapsAppDelegate.h"
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
static NSString *const kAlertControllerNibIdentifier = @"MWMAlertViewController";
|
||||
|
||||
@interface MWMAlertViewController () <UIGestureRecognizerDelegate>
|
||||
|
||||
@property(weak, nonatomic, readwrite) UIViewController *ownerViewController;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMAlertViewController
|
||||
|
||||
+ (nonnull MWMAlertViewController *)activeAlertController {
|
||||
UIViewController *tvc = [MapViewController sharedController];
|
||||
ASSERT([tvc conformsToProtocol:@protocol(MWMController)], ());
|
||||
UIViewController<MWMController> *mwmController = static_cast<UIViewController<MWMController> *>(tvc);
|
||||
return mwmController.alertController;
|
||||
}
|
||||
|
||||
- (nonnull instancetype)initWithViewController:(nonnull UIViewController *)viewController {
|
||||
self = [super initWithNibName:kAlertControllerNibIdentifier bundle:nil];
|
||||
if (self)
|
||||
_ownerViewController = viewController;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size
|
||||
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){
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)presentLocationAlertWithCancelBlock:(MWMVoidBlock)cancelBlock {
|
||||
[self displayAlert:[MWMAlert locationAlertWithCancelBlock:cancelBlock]];
|
||||
}
|
||||
- (void)presentPoint2PointAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock needToRebuild:(BOOL)needToRebuild {
|
||||
[self displayAlert:[MWMAlert point2PointAlertWithOkBlock:okBlock needToRebuild:needToRebuild]];
|
||||
}
|
||||
|
||||
- (void)presentLocationServiceNotSupportedAlert {
|
||||
[self displayAlert:[MWMAlert locationServiceNotSupportedAlert]];
|
||||
}
|
||||
- (void)presentNoConnectionAlert {
|
||||
[self displayAlert:[MWMAlert noConnectionAlert]];
|
||||
}
|
||||
|
||||
- (void)presentDeleteMapProhibitedAlert {
|
||||
[self displayAlert:[MWMAlert deleteMapProhibitedAlert]];
|
||||
}
|
||||
- (void)presentUnsavedEditsAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock {
|
||||
[self displayAlert:[MWMAlert unsavedEditsAlertWithOkBlock:okBlock]];
|
||||
}
|
||||
|
||||
- (void)presentNoWiFiAlertWithOkBlock:(nullable MWMVoidBlock)okBlock andCancelBlock:(MWMVoidBlock)cancelBlock {
|
||||
[self displayAlert:[MWMAlert noWiFiAlertWithOkBlock:okBlock andCancelBlock:cancelBlock]];
|
||||
}
|
||||
|
||||
- (void)presentIncorrectFeauturePositionAlert {
|
||||
[self displayAlert:[MWMAlert incorrectFeaturePositionAlert]];
|
||||
}
|
||||
|
||||
- (void)presentNotEnoughSpaceAlert {
|
||||
[self displayAlert:[MWMAlert notEnoughSpaceAlert]];
|
||||
}
|
||||
- (void)presentInvalidUserNameOrPasswordAlert {
|
||||
[self displayAlert:[MWMAlert invalidUserNameOrPasswordAlert]];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderAlertWithCountries:(storage::CountriesSet const &)countries
|
||||
code:(routing::RouterResultCode)code
|
||||
cancelBlock:(MWMVoidBlock)cancelBlock
|
||||
downloadBlock:(MWMDownloadBlock)downloadBlock
|
||||
downloadCompleteBlock:(MWMVoidBlock)downloadCompleteBlock {
|
||||
[self displayAlert:[MWMAlert downloaderAlertWithAbsentCountries:countries
|
||||
code:code
|
||||
cancelBlock:cancelBlock
|
||||
downloadBlock:downloadBlock
|
||||
downloadCompleteBlock:downloadCompleteBlock]];
|
||||
}
|
||||
|
||||
- (void)presentRoutingDisclaimerAlertWithOkBlock:(MWMVoidBlock)block {
|
||||
[self displayAlert:[MWMAlert routingDisclaimerAlertWithOkBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentDisabledLocationAlert {
|
||||
[self displayAlert:[MWMAlert disabledLocationAlert]];
|
||||
}
|
||||
|
||||
- (void)presentLocationServicesDisabledAlert; {
|
||||
[self displayAlert:[MWMAlert locationServicesDisabledAlert]];
|
||||
}
|
||||
|
||||
- (void)presentAlert:(routing::RouterResultCode)type {
|
||||
[self displayAlert:[MWMAlert alert:type]];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderNoConnectionAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
|
||||
cancelBlock:(nonnull MWMVoidBlock)cancelBlock {
|
||||
[self displayAlert:[MWMAlert downloaderNoConnectionAlertWithOkBlock:okBlock cancelBlock:cancelBlock]];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderNotEnoughSpaceAlert {
|
||||
[self displayAlert:[MWMAlert downloaderNotEnoughSpaceAlert]];
|
||||
}
|
||||
|
||||
- (void)presentDownloaderInternalErrorAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
|
||||
cancelBlock:(nonnull MWMVoidBlock)cancelBlock {
|
||||
[self displayAlert:[MWMAlert downloaderInternalErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]];
|
||||
}
|
||||
|
||||
- (void)presentPlaceDoesntExistAlertWithBlock:(MWMStringBlock)block {
|
||||
[self displayAlert:[MWMAlert placeDoesntExistAlertWithBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentResetChangesAlertWithBlock:(MWMVoidBlock)block {
|
||||
[self displayAlert:[MWMAlert resetChangesAlertWithBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentDeleteFeatureAlertWithBlock:(MWMVoidBlock)block {
|
||||
[self displayAlert:[MWMAlert deleteFeatureAlertWithBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentPersonalInfoWarningAlertWithBlock:(nonnull MWMVoidBlock)block {
|
||||
[self displayAlert:[MWMAlert personalInfoWarningAlertWithBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentTrackWarningAlertWithCancelBlock:(nonnull MWMVoidBlock)block {
|
||||
[self displayAlert:[MWMAlert trackWarningAlertWithCancelBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentMobileInternetAlertWithBlock:(nonnull MWMMobileInternetAlertCompletionBlock)block {
|
||||
[self displayAlert:[MWMMobileInternetAlert alertWithBlock:block]];
|
||||
}
|
||||
|
||||
- (void)presentInfoAlert:(nonnull NSString *)title text:(nonnull NSString *)text {
|
||||
[self displayAlert:[MWMAlert infoAlert:title text:text]];
|
||||
}
|
||||
|
||||
- (void)presentInfoAlert:(nonnull NSString *)title {
|
||||
[self displayAlert:[MWMAlert infoAlert:title text:nil]];
|
||||
}
|
||||
|
||||
- (void)presentCreateBookmarkCategoryAlertWithMaxCharacterNum:(NSUInteger)max
|
||||
minCharacterNum:(NSUInteger)min
|
||||
callback:(nonnull MWMCheckStringBlock)callback {
|
||||
auto alert =
|
||||
static_cast<MWMBCCreateCategoryAlert *>([MWMAlert createBookmarkCategoryAlertWithMaxCharacterNum:max
|
||||
minCharacterNum:min
|
||||
callback:callback]);
|
||||
[self displayAlert:alert];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[alert.textField becomeFirstResponder];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)presentSpinnerAlertWithTitle:(nonnull NSString *)title cancel:(nullable MWMVoidBlock)cancel {
|
||||
[self displayAlert:[MWMAlert spinnerAlertWithTitle:title cancel:cancel]];
|
||||
}
|
||||
|
||||
- (void)presentBookmarkConversionErrorAlert {
|
||||
[self displayAlert:[MWMAlert bookmarkConversionErrorAlert]];
|
||||
}
|
||||
|
||||
- (void)presentTagsLoadingErrorAlertWithOkBlock:(nonnull MWMVoidBlock)okBlock
|
||||
cancelBlock:(nonnull MWMVoidBlock)cancelBlock {
|
||||
[self displayAlert:[MWMAlert tagsLoadingErrorAlertWithOkBlock:okBlock cancelBlock:cancelBlock]];
|
||||
}
|
||||
|
||||
- (void)presentBugReportAlertWithTitle:(nonnull NSString *)title {
|
||||
[self displayAlert:[MWMAlert bugReportAlertWithTitle:title]];
|
||||
}
|
||||
|
||||
- (void)presentDefaultAlertWithTitle:(nonnull NSString *)title
|
||||
message:(nullable NSString *)message
|
||||
rightButtonTitle:(nonnull NSString *)rightButtonTitle
|
||||
leftButtonTitle:(nullable NSString *)leftButtonTitle
|
||||
rightButtonAction:(nullable MWMVoidBlock)action {
|
||||
[self displayAlert:[MWMAlert defaultAlertWithTitle:title
|
||||
message:message
|
||||
rightButtonTitle:rightButtonTitle
|
||||
leftButtonTitle:leftButtonTitle
|
||||
rightButtonAction:action]];
|
||||
}
|
||||
|
||||
- (void)displayAlert:(MWMAlert *)alert {
|
||||
UIViewController *ownerVC = self.ownerViewController;
|
||||
if (ownerVC.navigationController != nil) {
|
||||
ownerVC = ownerVC.navigationController;
|
||||
}
|
||||
BOOL isOwnerLoaded = ownerVC.isViewLoaded;
|
||||
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 ([view isKindOfClass:[MWMLocationAlert class]])
|
||||
return;
|
||||
}
|
||||
}
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
delay:0
|
||||
options:UIViewAnimationOptionBeginFromCurrentState
|
||||
animations:^{
|
||||
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;
|
||||
alert.transform = CGAffineTransformMakeScale(scale, scale);
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration
|
||||
animations:^{
|
||||
self.view.alpha = 1.;
|
||||
alert.alpha = 1.;
|
||||
alert.transform = CGAffineTransformIdentity;
|
||||
}];
|
||||
[[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);
|
||||
[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];
|
||||
}
|
||||
if (completion)
|
||||
completion();
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MWMAlertViewController">
|
||||
<connections>
|
||||
<outlet property="view" destination="PTX-3C-07U" id="OUb-QU-9sV"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view multipleTouchEnabled="YES" contentMode="scaleToFill" id="PTX-3C-07U" customClass="SolidTouchView" propertyAccessControl="all">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.40000000000000002" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<gestureRecognizers/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<viewLayoutGuide key="safeArea" id="1tF-gt-bLj"/>
|
||||
<point key="canvasLocation" x="528" y="235"/>
|
||||
</view>
|
||||
</objects>
|
||||
</document>
|
||||
Loading…
Add table
Add a link
Reference in a new issue