forked from organicmaps/organicmaps
[ios] Bookmark convertation.
This commit is contained in:
parent
e6d1f0c1c2
commit
5ebc0be5c1
20 changed files with 343 additions and 8 deletions
|
@ -40,6 +40,19 @@ final class BMCViewController: MWMViewController {
|
|||
viewModel = BMCDefaultViewModel()
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
let count = viewModel.filesCountForConversion
|
||||
if count > 0 {
|
||||
MWMAlertViewController.activeAlert().presentConvertBookmarksAlert(withCount: count)
|
||||
{ [weak viewModel] in
|
||||
MWMAlertViewController.activeAlert().presentSpinnerAlert(withTitle: L("converting"),
|
||||
cancel: nil)
|
||||
viewModel?.convertAllKML()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func updateCategoryName(category: BMCCategory?) {
|
||||
let isNewCategory = (category == nil)
|
||||
alertController.presentCreateBookmarkCategoryAlert(withMaxCharacterNum: viewModel.maxCategoryNameLength,
|
||||
|
@ -151,6 +164,14 @@ extension BMCViewController: BMCView {
|
|||
func delete(at indexPath: IndexPath) {
|
||||
tableView.deleteRows(at: [indexPath], with: .automatic)
|
||||
}
|
||||
|
||||
func conversionFinished(success: Bool) {
|
||||
MWMAlertViewController.activeAlert().closeAlert {
|
||||
if !success {
|
||||
MWMAlertViewController.activeAlert().presentBookmarkConversionErrorAlert()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension BMCViewController: UITableViewDataSource {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
final class BMCDefaultViewModel: NSObject {
|
||||
typealias BM = MWMBookmarksManager
|
||||
|
||||
var view: BMCView!
|
||||
|
||||
private enum Const
|
||||
{
|
||||
static let minCategoryNameLength: UInt = 0
|
||||
|
@ -20,11 +23,15 @@ final class BMCDefaultViewModel: NSObject {
|
|||
var minCategoryNameLength: UInt = Const.minCategoryNameLength
|
||||
var maxCategoryNameLength: UInt = Const.maxCategoryNameLength
|
||||
|
||||
typealias BM = MWMBookmarksManager
|
||||
var filesCountForConversion: UInt {
|
||||
get {
|
||||
return BM.filesCountForConversion()
|
||||
}
|
||||
}
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
MWMBookmarksManager.add(self)
|
||||
BM.add(self)
|
||||
loadData()
|
||||
}
|
||||
|
||||
|
@ -66,7 +73,7 @@ final class BMCDefaultViewModel: NSObject {
|
|||
sections.append(.permissions)
|
||||
setPermissions()
|
||||
|
||||
if MWMBookmarksManager.areBookmarksLoaded() {
|
||||
if BM.areBookmarksLoaded() {
|
||||
sections.append(.categories)
|
||||
setCategories()
|
||||
|
||||
|
@ -195,6 +202,10 @@ extension BMCDefaultViewModel: BMCViewModel {
|
|||
}
|
||||
pendingPermission(isPending: false)
|
||||
}
|
||||
|
||||
func convertAllKML() {
|
||||
BM.convertAll()
|
||||
}
|
||||
}
|
||||
|
||||
extension BMCDefaultViewModel: MWMBookmarksObserver {
|
||||
|
@ -217,4 +228,10 @@ extension BMCDefaultViewModel: MWMBookmarksObserver {
|
|||
onPreparedToShareCategory?(.error(title: L("dialog_routing_system_error"), text: L("bookmarks_error_message_share_general")))
|
||||
}
|
||||
}
|
||||
|
||||
func onConversionFinish(_ success: Bool) {
|
||||
setCategories()
|
||||
view.update(sections: [.categories])
|
||||
view.conversionFinished(success: success)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ protocol BMCView: AnyObject {
|
|||
func update(sections: [BMCSection])
|
||||
func delete(at indexPath: IndexPath)
|
||||
func insert(at indexPath: IndexPath)
|
||||
func conversionFinished(success: Bool)
|
||||
}
|
||||
|
||||
enum BMCShareCategoryStatus {
|
||||
|
@ -38,4 +39,7 @@ protocol BMCViewModel: AnyObject {
|
|||
|
||||
func pendingPermission(isPending: Bool)
|
||||
func grant(permission: BMCPermission?)
|
||||
|
||||
var filesCountForConversion: UInt { get }
|
||||
func convertAllKML();
|
||||
}
|
||||
|
|
|
@ -49,6 +49,11 @@
|
|||
isNewCategory:(BOOL)isNewCategory
|
||||
callback:(nonnull MWMCheckStringBlock)callback;
|
||||
|
||||
- (void)presentConvertBookmarksAlertWithCount:(NSUInteger)count block:(nonnull MWMVoidBlock)block;
|
||||
|
||||
- (void)presentSpinnerAlertWithTitle:(nonnull NSString *)title cancel:(nullable MWMVoidBlock)cancel;
|
||||
- (void)presentBookmarkConversionErrorAlert;
|
||||
|
||||
- (void)closeAlert:(nullable MWMVoidBlock)completion;
|
||||
|
||||
- (nonnull instancetype)init __attribute__((unavailable("call -initWithViewController: instead!")));
|
||||
|
|
|
@ -232,6 +232,22 @@ static NSString * const kAlertControllerNibIdentifier = @"MWMAlertViewController
|
|||
});
|
||||
}
|
||||
|
||||
- (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
|
||||
{
|
||||
[self displayAlert:[MWMAlert spinnerAlertWithTitle:title cancel:cancel]];
|
||||
}
|
||||
|
||||
- (void)presentBookmarkConversionErrorAlert
|
||||
{
|
||||
[self displayAlert:[MWMAlert bookmarkConversionErrorAlert]];
|
||||
}
|
||||
|
||||
- (void)displayAlert:(MWMAlert *)alert
|
||||
{
|
||||
// TODO(igrechuhin): Remove this check on location manager refactoring.
|
||||
|
|
|
@ -39,6 +39,10 @@
|
|||
minCharacterNum:(NSUInteger)min
|
||||
isNewCategory:(BOOL)isNewCategory
|
||||
callback:(MWMCheckStringBlock)callback;
|
||||
+ (MWMAlert *)convertBookmarksAlertWithCount:(NSUInteger)count block:(MWMVoidBlock)block;
|
||||
+ (MWMAlert *)spinnerAlertWithTitle:(NSString *)title cancel:(MWMVoidBlock)cancel;
|
||||
+ (MWMAlert *)bookmarkConversionErrorAlert;
|
||||
|
||||
- (void)close:(MWMVoidBlock)completion;
|
||||
|
||||
- (void)setNeedsCloseAlertAfterEnterBackground;
|
||||
|
|
|
@ -170,6 +170,21 @@
|
|||
callback:callback];
|
||||
}
|
||||
|
||||
+ (MWMAlert *)convertBookmarksAlertWithCount:(NSUInteger)count block:(MWMVoidBlock)block
|
||||
{
|
||||
return [MWMDefaultAlert convertBookmarksWithCount:count okBlock:block];
|
||||
}
|
||||
|
||||
+ (MWMAlert *)spinnerAlertWithTitle:(NSString *)title cancel:(MWMVoidBlock)cancel
|
||||
{
|
||||
return [MWMSpinnerAlert alertWithTitle:title cancel:cancel];
|
||||
}
|
||||
|
||||
+ (MWMAlert *)bookmarkConversionErrorAlert
|
||||
{
|
||||
return [MWMDefaultAlert bookmarkConversionErrorAlert];
|
||||
}
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
|
||||
{
|
||||
// Should override this method if you want custom relayout after rotation.
|
||||
|
|
|
@ -37,5 +37,7 @@
|
|||
+ (instancetype)personalInfoWarningAlertWithBlock:(MWMVoidBlock)block;
|
||||
+ (instancetype)trackWarningAlertWithCancelBlock:(MWMVoidBlock)block;
|
||||
+ (instancetype)infoAlert:(NSString *)title text:(NSString *)text;
|
||||
+ (instancetype)convertBookmarksWithCount:(NSUInteger)count okBlock:(MWMVoidBlock)okBlock;
|
||||
+ (instancetype)bookmarkConversionErrorAlert;
|
||||
|
||||
@end
|
||||
|
|
|
@ -415,14 +415,35 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
|
|||
statisticsEvent:@"Info Alert"];
|
||||
}
|
||||
|
||||
+ (instancetype)convertBookmarksWithCount:(NSUInteger)count okBlock:(MWMVoidBlock)okBlock
|
||||
{
|
||||
return [self defaultAlertWithTitle:L(@"bookmarks_detect_title")
|
||||
message:[NSString stringWithFormat:L(@"bookmarks_detect_message"), count]
|
||||
rightButtonTitle:L(@"button_convert")
|
||||
leftButtonTitle:L(@"cancel")
|
||||
rightButtonAction:okBlock
|
||||
statisticsEvent:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)bookmarkConversionErrorAlert
|
||||
{
|
||||
return [self defaultAlertWithTitle:L(@"bookmarks_convert_error_title")
|
||||
message:L(@"bookmarks_convert_error_message")
|
||||
rightButtonTitle:L(@"ok")
|
||||
leftButtonTitle:nil
|
||||
rightButtonAction:nil
|
||||
statisticsEvent:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)defaultAlertWithTitle:(nonnull NSString *)title
|
||||
message:(nullable NSString *)message
|
||||
rightButtonTitle:(nonnull NSString *)rightButtonTitle
|
||||
leftButtonTitle:(nullable NSString *)leftButtonTitle
|
||||
rightButtonAction:(nullable MWMVoidBlock)action
|
||||
statisticsEvent:(nonnull NSString *)statisticsEvent
|
||||
statisticsEvent:(nullable NSString *)statisticsEvent
|
||||
{
|
||||
[Statistics logEvent:statisticsEvent withParameters:@{kStatAction : kStatOpen}];
|
||||
if (statisticsEvent)
|
||||
[Statistics logEvent:statisticsEvent withParameters:@{kStatAction : kStatOpen}];
|
||||
MWMDefaultAlert * alert =
|
||||
[NSBundle.mainBundle loadNibNamed:kDefaultAlertNibName owner:self options:nil].firstObject;
|
||||
alert.titleLabel.text = title;
|
||||
|
@ -456,13 +477,17 @@ static NSString * const kDefaultAlertNibName = @"MWMDefaultAlert";
|
|||
|
||||
- (IBAction)rightButtonTap
|
||||
{
|
||||
[Statistics logEvent:self.statisticsEvent withParameters:@{kStatAction : kStatApply}];
|
||||
if (self.statisticsEvent)
|
||||
[Statistics logEvent:self.statisticsEvent withParameters:@{kStatAction : kStatApply}];
|
||||
|
||||
[self close:self.rightButtonAction];
|
||||
}
|
||||
|
||||
- (IBAction)leftButtonTap
|
||||
{
|
||||
[Statistics logEvent:self.statisticsEvent withParameters:@{kStatAction : kStatClose}];
|
||||
if (self.statisticsEvent)
|
||||
[Statistics logEvent:self.statisticsEvent withParameters:@{kStatAction : kStatClose}];
|
||||
|
||||
[self close:self.leftButtonAction];
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
rightButtonTitle:(nonnull NSString *)rightButtonTitle
|
||||
leftButtonTitle:(nullable NSString *)leftButtonTitle
|
||||
rightButtonAction:(nullable MWMVoidBlock)action
|
||||
statisticsEvent:(nonnull NSString *)statisticsEvent;
|
||||
statisticsEvent:(nullable NSString *)statisticsEvent;
|
||||
|
||||
@property(copy, nonatomic, readonly, nullable) MWMVoidBlock rightButtonAction;
|
||||
|
||||
|
|
135
iphone/Maps/Classes/CustomAlert/SpinnerAlert/MWMSpinnerAlert.xib
Normal file
135
iphone/Maps/Classes/CustomAlert/SpinnerAlert/MWMSpinnerAlert.xib
Normal file
|
@ -0,0 +1,135 @@
|
|||
<?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>
|
||||
<customFonts key="customFonts">
|
||||
<array key="HelveticaNeue.ttc">
|
||||
<string>HelveticaNeue</string>
|
||||
<string>HelveticaNeue-Medium</string>
|
||||
</array>
|
||||
</customFonts>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="zbk-bu-cTT" customClass="MWMSpinnerAlert" propertyAccessControl="none">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fZW-Y8-F8A" userLabel="ContainerView">
|
||||
<rect key="frame" x="48" y="264" width="280" height="139"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6Ik-Gs-Yc7" userLabel="button1">
|
||||
<rect key="frame" x="0.0" y="95" width="280" height="44"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="ejP-Qr-J5O"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="17"/>
|
||||
<state key="normal" title="cancel">
|
||||
<color key="titleColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</state>
|
||||
<state key="highlighted" backgroundImage="dialog_btn_press"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="cancel"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="linkBlue"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="bold17"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="tap" destination="zbk-bu-cTT" eventType="touchUpInside" id="a2c-ED-0jy"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lX1-uE-UHN" userLabel="hDivider1">
|
||||
<rect key="frame" x="0.0" y="94" width="280" height="1"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.12" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="f9v-KZ-u2L"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="blackDividers"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kq1-MC-Bth">
|
||||
<rect key="frame" x="124" y="16" width="32" height="32"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="32" id="BsB-R0-OVr"/>
|
||||
<constraint firstAttribute="width" constant="32" id="ElH-YQ-cGZ"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JHp-iN-vQc" userLabel="Title">
|
||||
<rect key="frame" x="20" y="56" width="240" height="22"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="20" id="57O-O2-CsM"/>
|
||||
<constraint firstAttribute="width" constant="240" id="M8o-cf-xqy"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" name="HelveticaNeue-Medium" family="Helvetica Neue" pointSize="18"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="colorName" value="blackPrimaryText"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="medium18"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.88" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="6Ik-Gs-Yc7" firstAttribute="top" secondItem="lX1-uE-UHN" secondAttribute="bottom" id="04f-3J-sOv"/>
|
||||
<constraint firstItem="kq1-MC-Bth" firstAttribute="centerX" secondItem="fZW-Y8-F8A" secondAttribute="centerX" id="1bI-tg-lK9"/>
|
||||
<constraint firstAttribute="width" constant="280" id="7A5-aI-a0x"/>
|
||||
<constraint firstAttribute="centerX" secondItem="lX1-uE-UHN" secondAttribute="centerX" id="DKt-je-czo"/>
|
||||
<constraint firstItem="kq1-MC-Bth" firstAttribute="top" secondItem="fZW-Y8-F8A" secondAttribute="top" constant="16" id="Ft7-Dd-lYK"/>
|
||||
<constraint firstAttribute="width" secondItem="lX1-uE-UHN" secondAttribute="width" id="Qpr-nH-Na5"/>
|
||||
<constraint firstAttribute="bottom" secondItem="6Ik-Gs-Yc7" secondAttribute="bottom" id="Tqv-1O-YVs"/>
|
||||
<constraint firstItem="lX1-uE-UHN" firstAttribute="top" secondItem="JHp-iN-vQc" secondAttribute="bottom" constant="16" id="b0T-2G-xsF"/>
|
||||
<constraint firstItem="6Ik-Gs-Yc7" firstAttribute="trailing" secondItem="lX1-uE-UHN" secondAttribute="trailing" id="tYJ-fJ-ov9"/>
|
||||
<constraint firstItem="6Ik-Gs-Yc7" firstAttribute="leading" secondItem="lX1-uE-UHN" secondAttribute="leading" id="vDN-x9-Sw8"/>
|
||||
<constraint firstAttribute="centerX" secondItem="JHp-iN-vQc" secondAttribute="centerX" id="wwC-8B-KBV"/>
|
||||
<constraint firstItem="JHp-iN-vQc" firstAttribute="top" secondItem="kq1-MC-Bth" secondAttribute="bottom" constant="8" id="yW9-DY-uxC"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="size" keyPath="layer.shadowOffset">
|
||||
<size key="value" width="0.0" height="3"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
<userDefinedRuntimeAttribute type="color" keyPath="layer.shadowUIColor">
|
||||
<color key="value" red="0.0" green="0.0" blue="0.0" alpha="0.22" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.shadowRadius">
|
||||
<integer key="value" value="6"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<integer key="value" value="12"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.shadowOpacity">
|
||||
<integer key="value" value="1"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="alertBackground"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="centerX" secondItem="fZW-Y8-F8A" secondAttribute="centerX" id="Ll6-go-lGy"/>
|
||||
<constraint firstAttribute="centerY" secondItem="fZW-Y8-F8A" secondAttribute="centerY" id="Sz5-hL-nLu"/>
|
||||
</constraints>
|
||||
<viewLayoutGuide key="safeArea" id="fPw-k5-Wbc"/>
|
||||
<connections>
|
||||
<outlet property="cancelButton" destination="6Ik-Gs-Yc7" id="PcZ-Qo-ycv"/>
|
||||
<outlet property="cancelHeight" destination="ejP-Qr-J5O" id="sxx-S8-gDN"/>
|
||||
<outlet property="divider" destination="lX1-uE-UHN" id="BGf-W6-2UF"/>
|
||||
<outlet property="progressView" destination="kq1-MC-Bth" id="FK3-oI-lWX"/>
|
||||
<outlet property="title" destination="JHp-iN-vQc" id="6lQ-ps-HJD"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="304.5" y="171.5"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="dialog_btn_press" width="280" height="44"/>
|
||||
</resources>
|
||||
</document>
|
|
@ -0,0 +1,43 @@
|
|||
@objc (MWMSpinnerAlert)
|
||||
final class SpinnerAlert: MWMAlert {
|
||||
@IBOutlet private weak var progressView: UIView!
|
||||
@IBOutlet private weak var title: UILabel!
|
||||
@IBOutlet private weak var cancelHeight: NSLayoutConstraint!
|
||||
@IBOutlet private weak var cancelButton: UIButton!
|
||||
@IBOutlet private weak var divider: UIView!
|
||||
|
||||
private var cancel: MWMVoidBlock?
|
||||
|
||||
private lazy var progress: MWMCircularProgress = {
|
||||
var p = MWMCircularProgress.downloaderProgress(forParentView: progressView)
|
||||
return p
|
||||
}()
|
||||
|
||||
|
||||
@objc static func alert(title: String, cancel: MWMVoidBlock?) -> SpinnerAlert? {
|
||||
guard let alert = Bundle.main.loadNibNamed(className(), owner: nil, options: nil)?.first
|
||||
as? SpinnerAlert else {
|
||||
assertionFailure()
|
||||
return nil
|
||||
}
|
||||
|
||||
alert.title.text = title
|
||||
alert.progress.state = .spinner
|
||||
alert.progress.setCancelButtonHidden()
|
||||
|
||||
if let cancel = cancel {
|
||||
alert.cancel = cancel
|
||||
} else {
|
||||
alert.cancelHeight.constant = 0
|
||||
alert.cancelButton.isHidden = true
|
||||
alert.divider.isHidden = true
|
||||
alert.setNeedsLayout()
|
||||
}
|
||||
|
||||
return alert
|
||||
}
|
||||
|
||||
@IBAction private func tap() {
|
||||
close(cancel)
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@
|
|||
- (void)setSpinnerColoring:(MWMImageColoring)coloring;
|
||||
- (void)setSpinnerBackgroundColor:(nonnull UIColor *)backgroundColor;
|
||||
- (void)setInvertColor:(BOOL)invertColor;
|
||||
- (void)setCancelButtonHidden;
|
||||
|
||||
- (nonnull instancetype)init __attribute__((unavailable("init is not available")));
|
||||
- (nonnull instancetype)initWithParentView:(nonnull UIView *)parentView;
|
||||
|
|
|
@ -113,6 +113,11 @@
|
|||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)setCancelButtonHidden
|
||||
{
|
||||
self.rootView.buttonView.hidden = YES;
|
||||
}
|
||||
|
||||
- (IBAction)buttonTouchUpInside:(UIButton *)sender { [self.delegate progressButtonPressed:self]; }
|
||||
#pragma mark - Properties
|
||||
|
||||
|
|
|
@ -22,4 +22,6 @@
|
|||
|
||||
- (void)updatePath:(CGFloat)progress;
|
||||
|
||||
- (UIView *)buttonView;
|
||||
|
||||
@end
|
||||
|
|
|
@ -209,6 +209,11 @@ CGFloat angleWithProgress(CGFloat progress) { return 2.0 * M_PI * progress - M_P
|
|||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (UIView *)buttonView
|
||||
{
|
||||
return self.button;
|
||||
}
|
||||
|
||||
- (void)setState:(MWMCircularProgressState)state
|
||||
{
|
||||
if (state == MWMCircularProgressStateSpinner)
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
+ (BOOL)isCloudEnabled;
|
||||
+ (void)setCloudEnabled:(BOOL)enabled;
|
||||
|
||||
+ (NSUInteger)filesCountForConversion;
|
||||
+ (void)convertAll;
|
||||
|
||||
- (instancetype)init __attribute__((unavailable("call +manager instead")));
|
||||
- (instancetype)copy __attribute__((unavailable("call +manager instead")));
|
||||
- (instancetype)copyWithZone:(NSZone *)zone __attribute__((unavailable("call +manager instead")));
|
||||
|
|
|
@ -226,6 +226,20 @@ using TLoopBlock = void (^)(Observer observer);
|
|||
});
|
||||
}
|
||||
|
||||
+ (NSUInteger)filesCountForConversion
|
||||
{
|
||||
return GetFramework().GetBookmarkManager().GetKmlFilesCountForConversion();
|
||||
}
|
||||
|
||||
+ (void)convertAll
|
||||
{
|
||||
GetFramework().GetBookmarkManager().ConvertAllKmlFiles([](bool success) {
|
||||
[[MWMBookmarksManager manager] loopObservers:^(Observer observer) {
|
||||
[observer onConversionFinish:success];
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
+ (NSURL *)shareCategoryURL
|
||||
{
|
||||
MWMBookmarksManager * manager = [MWMBookmarksManager manager];
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
@protocol MWMBookmarksObserver<NSObject>
|
||||
|
||||
- (void)onConversionFinish:(BOOL)success;
|
||||
|
||||
@optional
|
||||
- (void)onBookmarksLoadFinished;
|
||||
- (void)onBookmarksFileLoadSuccess;
|
||||
|
|
|
@ -477,6 +477,8 @@
|
|||
F61757F11FC731F5000AD0D0 /* DiscoveryOnlineTemplateCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F61757EF1FC731F5000AD0D0 /* DiscoveryOnlineTemplateCell.xib */; };
|
||||
F623DA6C1C9C2731006A3436 /* opening_hours_how_to_edit.html in Resources */ = {isa = PBXBuildFile; fileRef = F623DA6A1C9C2731006A3436 /* opening_hours_how_to_edit.html */; };
|
||||
F623DA6F1C9C2E62006A3436 /* MWMAddPlaceNavigationBar.xib in Resources */ = {isa = PBXBuildFile; fileRef = F653CE171C71F62400A453F1 /* MWMAddPlaceNavigationBar.xib */; };
|
||||
F62607FD207B790300176C5A /* SpinnerAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = F62607FC207B790300176C5A /* SpinnerAlert.swift */; };
|
||||
F62607FF207B83C400176C5A /* MWMSpinnerAlert.xib in Resources */ = {isa = PBXBuildFile; fileRef = F62607FE207B83C400176C5A /* MWMSpinnerAlert.xib */; };
|
||||
F626D52F1C3E83F800C17D15 /* MWMTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = F626D52D1C3E6CAA00C17D15 /* MWMTableViewCell.mm */; };
|
||||
F6381BF61CD12045004CA943 /* LocaleTranslator.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6381BF41CD12045004CA943 /* LocaleTranslator.mm */; };
|
||||
F63AF5061EA6162400A1DB98 /* FilterTypeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F63AF5041EA6162400A1DB98 /* FilterTypeCell.swift */; };
|
||||
|
@ -1366,6 +1368,8 @@
|
|||
F61757EB1FC73027000AD0D0 /* DiscoveryOnlineTemplateCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveryOnlineTemplateCell.swift; sourceTree = "<group>"; };
|
||||
F61757EF1FC731F5000AD0D0 /* DiscoveryOnlineTemplateCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoveryOnlineTemplateCell.xib; sourceTree = "<group>"; };
|
||||
F623DA6A1C9C2731006A3436 /* opening_hours_how_to_edit.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = opening_hours_how_to_edit.html; path = ../../data/opening_hours_how_to_edit.html; sourceTree = "<group>"; };
|
||||
F62607FC207B790300176C5A /* SpinnerAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpinnerAlert.swift; sourceTree = "<group>"; };
|
||||
F62607FE207B83C400176C5A /* MWMSpinnerAlert.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MWMSpinnerAlert.xib; sourceTree = "<group>"; };
|
||||
F626D52C1C3E6CAA00C17D15 /* MWMTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMTableViewCell.h; sourceTree = "<group>"; };
|
||||
F626D52D1C3E6CAA00C17D15 /* MWMTableViewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMTableViewCell.mm; sourceTree = "<group>"; };
|
||||
F63774E61B59375E00BCF54D /* MWMRoutingDisclaimerAlert.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMRoutingDisclaimerAlert.xib; sourceTree = "<group>"; };
|
||||
|
@ -3053,6 +3057,15 @@
|
|||
path = RateAlert;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F62607FB207B78E300176C5A /* SpinnerAlert */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F62607FC207B790300176C5A /* SpinnerAlert.swift */,
|
||||
F62607FE207B83C400176C5A /* MWMSpinnerAlert.xib */,
|
||||
);
|
||||
path = SpinnerAlert;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F63774E51B59374F00BCF54D /* RoutingDisclaimerAlert */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -3076,6 +3089,7 @@
|
|||
F64F195F1AB8125C006EAF7E /* CustomAlert */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F62607FB207B78E300176C5A /* SpinnerAlert */,
|
||||
F6D67CDA2062B9810032FD38 /* CreateBookmarkCategory */,
|
||||
349B92691DF0516C007779DD /* Toast */,
|
||||
349A137E1DEC138C00C7DB60 /* MobileInternetAlert */,
|
||||
|
@ -4165,6 +4179,7 @@
|
|||
3406FA191C6E0D8F00E9FAD2 /* MWMMapDownloadDialog.xib in Resources */,
|
||||
F6E2FD531E097BA00083EBEC /* MWMMapDownloaderAdsTableViewCell.xib in Resources */,
|
||||
F6E2FD591E097BA00083EBEC /* MWMMapDownloaderButtonTableViewCell.xib in Resources */,
|
||||
F62607FF207B83C400176C5A /* MWMSpinnerAlert.xib in Resources */,
|
||||
F6EBB2731FD7E4FD00B69B6A /* DiscoveryNoResultsCell.xib in Resources */,
|
||||
F6E2FD621E097BA00083EBEC /* MWMMapDownloaderLargeCountryTableViewCell.xib in Resources */,
|
||||
F6664BFD1E6459CB00E703C2 /* PPFacilityCell.xib in Resources */,
|
||||
|
@ -4515,6 +4530,7 @@
|
|||
342CC5F21C2D7730005F3FE5 /* MWMAuthorizationLoginViewController.mm in Sources */,
|
||||
340475591E081A4600C92850 /* WebViewController.mm in Sources */,
|
||||
3404F4992028A20D0090E401 /* BMCCategoryCell.swift in Sources */,
|
||||
F62607FD207B790300176C5A /* SpinnerAlert.swift in Sources */,
|
||||
34F407411E9E1AFF00E57AC0 /* RBBanner.swift in Sources */,
|
||||
3444DFD21F17620C00E73099 /* MWMMapWidgetsHelper.mm in Sources */,
|
||||
348A8DFB1F66775A00D83026 /* RatingViewSettings.swift in Sources */,
|
||||
|
|
Loading…
Add table
Reference in a new issue