[ios] Sharing main screen

This commit is contained in:
o.bolovintseva 2018-10-25 12:13:51 +03:00 committed by Aleksey Belousov
parent 63009be3ff
commit 503b8c6ac6
16 changed files with 409 additions and 71 deletions

View file

@ -73,25 +73,11 @@ final class BMCViewController: MWMViewController {
}
private func shareCategory(category: BMCCategory, anchor: UIView) {
let shareOnSuccess = { [viewModel] (url: URL) in
typealias AVC = MWMActivityViewController
let message = L("share_bookmarks_email_body")
let shareController = AVC.share(for: url, message: message) { [viewModel] _, _, _, _ in
viewModel?.finishShareCategory()
}
shareController!.present(inParentViewController: self, anchorView: anchor)
}
let showAlertOnError = { (title: String, text: String) in
MWMAlertViewController.activeAlert().presentInfoAlert(title, text: text)
}
let storyboard = UIStoryboard.instance(.sharing)
let shareController = storyboard.instantiateInitialViewController() as! BookmarksSharingViewController
viewModel.shareCategory(category: category) { (status: BMCShareCategoryStatus) in
switch status {
case let .success(url): shareOnSuccess(url)
case let .error(title, text): showAlertOnError(title, text)
}
}
MapViewController.topViewController().navigationController?.pushViewController(shareController,
animated: true)
}
private func openCategory(category: BMCCategory) {
@ -100,19 +86,6 @@ final class BMCViewController: MWMViewController {
animated: true)
}
private func signup(anchor: UIView, onComplete: @escaping (Bool) -> Void) {
if MWMAuthorizationViewModel.isAuthenticated() {
onComplete(true)
} else {
let authVC = AuthorizationViewController(popoverSourceView: anchor,
sourceComponent: .bookmarks,
permittedArrowDirections: .any,
successHandler: { _ in onComplete(true) },
errorHandler: { _ in onComplete(false) })
present(authVC, animated: true, completion: nil)
}
}
private func editCategory(category: BMCCategory, anchor: UIView) {
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
if let ppc = actionSheet.popoverPresentationController {

View file

@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Yad-RH-i8M">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Bookmarks Sharing View Controller-->
<scene sceneID="U9B-V6-MqR">
<objects>
<tableViewController id="Yad-RH-i8M" customClass="BookmarksSharingViewController" customModule="maps_me" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="1pz-95-Ts3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<sections>
<tableViewSection headerTitle="Public access" id="wSk-N4-gbo">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="56" id="YW0-jq-Isw" customClass="UploadActionCell" customModule="maps_me" customModuleProvider="target">
<rect key="frame" x="0.0" y="55.5" width="375" height="56"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="YW0-jq-Isw" id="ayR-ii-DjA">
<rect key="frame" x="0.0" y="0.0" width="375" height="55.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic24PxGlobe" translatesAutoresizingMaskIntoConstraints="NO" id="fmA-82-rPS">
<rect key="frame" x="16" y="16" width="24" height="24"/>
<color key="tintColor" red="0.11764705882352941" green="0.58823529411764708" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="5bK-ck-alK"/>
<constraint firstAttribute="width" constant="24" id="RId-hH-I1b"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="coloring" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Upload and publish" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uMP-YO-wbu">
<rect key="frame" x="56" y="18" width="140" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.11764705882352941" green="0.58823529411764708" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="fmA-82-rPS" firstAttribute="centerY" secondItem="ayR-ii-DjA" secondAttribute="centerY" id="Bfj-dF-WcJ"/>
<constraint firstItem="uMP-YO-wbu" firstAttribute="centerY" secondItem="fmA-82-rPS" secondAttribute="centerY" id="D4L-J4-gPv"/>
<constraint firstItem="fmA-82-rPS" firstAttribute="leading" secondItem="ayR-ii-DjA" secondAttribute="leadingMargin" id="Zzq-yt-7DW"/>
<constraint firstItem="uMP-YO-wbu" firstAttribute="leading" secondItem="fmA-82-rPS" secondAttribute="trailing" constant="16" id="qOc-7f-rpS"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="actionImage" destination="fmA-82-rPS" id="Z0K-e9-nZj"/>
<outlet property="actionTitle" destination="uMP-YO-wbu" id="pQd-ox-QLF"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="95" id="VdZ-fO-p63">
<rect key="frame" x="0.0" y="111.5" width="375" height="95"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="VdZ-fO-p63" id="Y9s-zu-iol">
<rect key="frame" x="0.0" y="0.0" width="375" height="94.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="This list will be uploaded in the public catalog at MAPS.ME as guide and will be easily shared with others" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="N3w-HY-3ac">
<rect key="frame" x="56" y="20" width="303" height="60.5"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="N3w-HY-3ac" secondAttribute="bottom" constant="14" id="1EW-1C-WIX"/>
<constraint firstItem="N3w-HY-3ac" firstAttribute="top" secondItem="Y9s-zu-iol" secondAttribute="top" constant="20" id="qEv-Gk-ane"/>
<constraint firstItem="N3w-HY-3ac" firstAttribute="leading" secondItem="Y9s-zu-iol" secondAttribute="leading" constant="56" id="upe-MD-o7N"/>
<constraint firstAttribute="trailing" secondItem="N3w-HY-3ac" secondAttribute="trailing" constant="16" id="zDt-Qf-8JF"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="70" id="3UL-dT-hKc">
<rect key="frame" x="0.0" y="206.5" width="375" height="70"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="3UL-dT-hKc" id="402-ot-2TF">
<rect key="frame" x="0.0" y="0.0" width="375" height="69.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="Please note: by proceeding, you accept the license agreement" translatesAutoresizingMaskIntoConstraints="NO" id="dsV-Vs-oCo" customClass="LinkTextView" customModule="maps_me" customModuleProvider="target">
<rect key="frame" x="56" y="20" width="303" height="35.5"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="textContainer.lineFragmentPadding">
<integer key="value" value="0"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="rect" keyPath="textContainerInset">
<rect key="value" x="0.0" y="0.0" width="0.0" height="0.0"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</textView>
</subviews>
<constraints>
<constraint firstItem="dsV-Vs-oCo" firstAttribute="leading" secondItem="402-ot-2TF" secondAttribute="leading" constant="56" id="BgN-PM-ejM"/>
<constraint firstAttribute="bottom" secondItem="dsV-Vs-oCo" secondAttribute="bottom" constant="14" id="bik-bt-cDR"/>
<constraint firstItem="dsV-Vs-oCo" firstAttribute="top" secondItem="402-ot-2TF" secondAttribute="top" constant="20" id="rZO-fI-h9b"/>
<constraint firstAttribute="trailing" secondItem="dsV-Vs-oCo" secondAttribute="trailing" constant="16" id="vcP-CZ-R8d"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="Limited access" id="GtE-jP-p4q">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="56" id="90b-ef-VUJ" customClass="UploadActionCell" customModule="maps_me" customModuleProvider="target">
<rect key="frame" x="0.0" y="332.5" width="375" height="56"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="90b-ef-VUJ" id="AlV-ie-H63">
<rect key="frame" x="0.0" y="0.0" width="375" height="55.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic24PxLink" translatesAutoresizingMaskIntoConstraints="NO" id="saz-sU-6Ej">
<rect key="frame" x="16" y="16" width="24" height="24"/>
<color key="tintColor" red="0.1176470588" green="0.58823529409999997" blue="0.94117647059999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="24" id="1xP-Cc-gIc"/>
<constraint firstAttribute="height" constant="24" id="gmf-FK-0kF"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="coloring" value="MWMBlue"/>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Upload and get a direct link" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eP0-FF-mrr">
<rect key="frame" x="56" y="18" width="199" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.1176470588" green="0.58823529409999997" blue="0.94117647059999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="saz-sU-6Ej" firstAttribute="leading" secondItem="AlV-ie-H63" secondAttribute="leadingMargin" id="6xx-om-FYX"/>
<constraint firstItem="eP0-FF-mrr" firstAttribute="leading" secondItem="saz-sU-6Ej" secondAttribute="trailing" constant="16" id="9wM-mP-nrJ"/>
<constraint firstItem="saz-sU-6Ej" firstAttribute="centerY" secondItem="AlV-ie-H63" secondAttribute="centerY" id="RO2-ZE-4ki"/>
<constraint firstItem="eP0-FF-mrr" firstAttribute="centerY" secondItem="saz-sU-6Ej" secondAttribute="centerY" id="gjd-eI-tRy"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="actionImage" destination="saz-sU-6Ej" id="98p-ou-d6i"/>
<outlet property="actionTitle" destination="eP0-FF-mrr" id="SCv-0e-YHj"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="50" id="4dc-7Z-s7O">
<rect key="frame" x="0.0" y="388.5" width="375" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="4dc-7Z-s7O" id="5YA-YS-3K5">
<rect key="frame" x="0.0" y="0.0" width="375" height="49.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Anyone this the link will see your list" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XQh-26-CNo">
<rect key="frame" x="56" y="20" width="303" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="XQh-26-CNo" firstAttribute="leading" secondItem="5YA-YS-3K5" secondAttribute="leading" constant="56" id="YAj-bm-cRZ"/>
<constraint firstAttribute="trailing" secondItem="XQh-26-CNo" secondAttribute="trailing" constant="16" id="a42-ex-JkL"/>
<constraint firstAttribute="bottom" secondItem="XQh-26-CNo" secondAttribute="bottom" constant="14" id="jUr-iV-omT"/>
<constraint firstItem="XQh-26-CNo" firstAttribute="top" secondItem="5YA-YS-3K5" secondAttribute="top" constant="20" id="yhk-td-FO2"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="Yad-RH-i8M" id="xFz-G4-umt"/>
<outlet property="delegate" destination="Yad-RH-i8M" id="aq1-gc-f3D"/>
</connections>
</tableView>
<connections>
<outlet property="getDirectLinkCell" destination="90b-ef-VUJ" id="L7h-0r-eSe"/>
<outlet property="getDirectLinkDescLabel" destination="XQh-26-CNo" id="0J9-NV-e70"/>
<outlet property="licenseAgreementTextView" destination="dsV-Vs-oCo" id="TtB-Uw-WGR"/>
<outlet property="uploadAndPublishCell" destination="YW0-jq-Isw" id="84h-vp-JdM"/>
<outlet property="uploadAndPublishDescLabel" destination="N3w-HY-3ac" id="swz-rU-GFi"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ylv-YU-ujs" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="37.600000000000001" y="26.53673163418291"/>
</scene>
</scenes>
<resources>
<image name="ic24PxGlobe" width="24" height="24"/>
<image name="ic24PxLink" width="24" height="24"/>
</resources>
</document>

View file

@ -0,0 +1,76 @@
import SafariServices
final class BookmarksSharingViewController: MWMTableViewController {
typealias ViewModel = MWMAuthorizationViewModel
@IBOutlet weak var uploadAndPublishCell: UploadActionCell!
@IBOutlet weak var getDirectLinkCell: UploadActionCell!
@IBOutlet weak var uploadAndPublishDescLabel: UILabel! {
didSet {
uploadAndPublishDescLabel.text = L("upload_and_publish_desc")
}
}
@IBOutlet private weak var licenseAgreementTextView: UITextView! {
didSet {
let htmlString = String(coreFormat: L("ugc_routes_user_agreement"), arguments: [ViewModel.termsOfUseLink()])
let attributes: [NSAttributedStringKey : Any] = [NSAttributedStringKey.font: UIFont.regular14(),
NSAttributedStringKey.foregroundColor: UIColor.blackSecondaryText()]
licenseAgreementTextView.attributedText = NSAttributedString.string(withHtml: htmlString,
defaultAttributes: attributes)
licenseAgreementTextView.delegate = self
}
}
@IBOutlet weak var getDirectLinkDescLabel: UILabel! {
didSet {
getDirectLinkDescLabel.text = L("get_direct_link_desc")
}
}
override func viewDidLoad() {
super.viewDidLoad()
title = L("sharing_options") //"Sharing options"
self.configureActionCells()
}
func configureActionCells() {
uploadAndPublishCell.config(title: L("upload_and_publish"), image: UIImage(named: "ic24PxGlobe")!)
getDirectLinkCell.config(title: L("upload_and_get_direct_link"), image: UIImage(named: "ic24PxLink")!)
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
override func tableView(_ tableView: UITableView,
titleForHeaderInSection section: Int) -> String? {
return section == 0 ? L("public_access") : L("limited_access")
}
override func tableView(_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let cell = tableView.cellForRow(at: indexPath)
if (cell == self.uploadAndPublishCell || cell == self.getDirectLinkCell) {
MWMFrameworkHelper.checkConnectionAndPerformAction { [unowned self] in
self.signup(anchor: self.view, onComplete: { success in
if (success) {
//impl uploading
}
})
}
}
}
}
extension BookmarksSharingViewController: UITextViewDelegate {
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool {
let safari = SFSafariViewController(url: URL)
self.present(safari, animated: true, completion: nil)
return false;
}
}

View file

@ -0,0 +1,14 @@
final class UploadActionCell: MWMTableViewCell {
@IBOutlet private weak var actionImage: UIImageView! {
didSet {
actionImage.tintColor = .linkBlue()
}
}
@IBOutlet private weak var actionTitle: UILabel!
func config(title: String, image: UIImage) {
actionImage.image = image
actionTitle.text = title
}
}

View file

@ -0,0 +1,14 @@
extension UIViewController {
func signup(anchor: UIView, onComplete: @escaping (Bool) -> Void) {
if MWMAuthorizationViewModel.isAuthenticated() {
onComplete(true)
} else {
let authVC = AuthorizationViewController(popoverSourceView: anchor,
sourceComponent: .bookmarks,
permittedArrowDirections: .any,
successHandler: { _ in onComplete(true) },
errorHandler: { _ in onComplete(false) })
present(authVC, animated: true, completion: nil)
}
}
}

View file

@ -8,6 +8,8 @@
+ (MWMDayTime)daytime;
+ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action;
+ (void)createFramework;
+ (BOOL)canUseNetwork;

View file

@ -1,6 +1,7 @@
#import "MWMFrameworkHelper.h"
#import "MWMLocationManager.h"
#import "MapViewController.h"
#import "MWMAlertViewController.h"
#include "Framework.h"
@ -66,6 +67,34 @@
}
}
+ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action
{
switch (Platform::ConnectionStatus())
{
case Platform::EConnectionType::CONNECTION_NONE:
[[MWMAlertViewController activeAlertController] presentNoConnectionAlert];
break;
case Platform::EConnectionType::CONNECTION_WIFI:
action();
break;
case Platform::EConnectionType::CONNECTION_WWAN:
{
if (!GetFramework().GetDownloadingPolicy().IsCellularDownloadEnabled())
{
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:[action] {
GetFramework().GetDownloadingPolicy().EnableCellularDownload(true);
action();
}];
}
else
{
action();
}
break;
}
}
}
+ (void)createFramework { UNUSED_VALUE(GetFramework()); }
+ (BOOL)canUseNetwork

View file

@ -1,6 +1,7 @@
#import "MWMStorage.h"
#import "MWMAlertViewController.h"
#import "MWMRouter.h"
#import "MWMFrameworkHelper.h"
#include "Framework.h"
@ -16,7 +17,7 @@ using namespace storage;
{
if (IsEnoughSpaceForDownload(countryId, GetFramework().GetStorage()))
{
[self checkConnectionAndPerformAction:[countryId, onSuccess] {
[MWMFrameworkHelper checkConnectionAndPerformAction:[countryId, onSuccess] {
GetFramework().GetStorage().DownloadNode(countryId);
if (onSuccess)
onSuccess();
@ -30,7 +31,7 @@ using namespace storage;
+ (void)retryDownloadNode:(TCountryId const &)countryId
{
[self checkConnectionAndPerformAction:[countryId] {
[MWMFrameworkHelper checkConnectionAndPerformAction:[countryId] {
GetFramework().GetStorage().RetryDownloadNode(countryId);
}];
}
@ -39,7 +40,7 @@ using namespace storage;
{
if (IsEnoughSpaceForUpdate(countryId, GetFramework().GetStorage()))
{
[self checkConnectionAndPerformAction:[countryId] {
[MWMFrameworkHelper checkConnectionAndPerformAction:[countryId] {
GetFramework().GetStorage().UpdateNode(countryId);
}];
}
@ -92,7 +93,7 @@ using namespace storage;
});
if (storage::IsEnoughSpaceForDownload(requiredSize))
{
[self checkConnectionAndPerformAction:[countryIds, onSuccess, &s] {
[MWMFrameworkHelper checkConnectionAndPerformAction:[countryIds, onSuccess, &s] {
for (auto const & countryId : countryIds)
s.DownloadNode(countryId);
if (onSuccess)
@ -105,32 +106,4 @@ using namespace storage;
}
}
+ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action
{
switch (Platform::ConnectionStatus())
{
case Platform::EConnectionType::CONNECTION_NONE:
[[MWMAlertViewController activeAlertController] presentNoConnectionAlert];
break;
case Platform::EConnectionType::CONNECTION_WIFI:
action();
break;
case Platform::EConnectionType::CONNECTION_WWAN:
{
if (!GetFramework().GetDownloadingPolicy().IsCellularDownloadEnabled())
{
[[MWMAlertViewController activeAlertController] presentNoWiFiAlertWithOkBlock:[action] {
GetFramework().GetDownloadingPolicy().EnableCellularDownload(true);
action();
}];
}
else
{
action();
}
break;
}
}
}
@end

View file

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View file

@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic24PxGlobe.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}

View file

@ -0,0 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic24PxLink.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"template-rendering-intent" : "template"
}
}

View file

@ -9,6 +9,10 @@
/* Begin PBXBuildFile section */
1DA7908820762CEB008BDD6B /* libopen_location_code.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DA7908920762CEB008BDD6B /* libopen_location_code.a */; };
1DFA2F6A20D3B57400FB2C66 /* UIColor+PartnerColor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1DFA2F6920D3B57400FB2C66 /* UIColor+PartnerColor.mm */; };
3358607E217632A2006D11F2 /* BookmarksSharingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3358607D217632A2006D11F2 /* BookmarksSharingViewController.swift */; };
33BCD61621777A7400CA30B4 /* BookmarksSharingFlow.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 33BCD61521777A7400CA30B4 /* BookmarksSharingFlow.storyboard */; };
33C558E3217F6CF100299E70 /* UploadActionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33C558E2217F6CF100299E70 /* UploadActionCell.swift */; };
33E905462180C40900868CAC /* UIViewController+Authorization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33E905452180C40900868CAC /* UIViewController+Authorization.swift */; };
3404163C1E7BDFE000E2B6D6 /* PhotosViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3404163A1E7BDFE000E2B6D6 /* PhotosViewController.swift */; };
340416441E7BED3900E2B6D6 /* PhotosTransitionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 340416421E7BED3900E2B6D6 /* PhotosTransitionAnimator.swift */; };
340416481E7BF28E00E2B6D6 /* UIView+Snapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 340416461E7BF28E00E2B6D6 /* UIView+Snapshot.swift */; };
@ -767,6 +771,10 @@
1DFA2F6E20D3CA9200FB2C66 /* UIColorRoutines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIColorRoutines.h; sourceTree = "<group>"; };
28A0AB4B0D9B1048005BE974 /* Maps_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Maps_Prefix.pch; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
29B97316FDCFA39411CA2CEA /* main.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = main.mm; sourceTree = "<group>"; };
3358607D217632A2006D11F2 /* BookmarksSharingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksSharingViewController.swift; sourceTree = "<group>"; };
33BCD61521777A7400CA30B4 /* BookmarksSharingFlow.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = BookmarksSharingFlow.storyboard; sourceTree = "<group>"; };
33C558E2217F6CF100299E70 /* UploadActionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadActionCell.swift; sourceTree = "<group>"; };
33E905452180C40900868CAC /* UIViewController+Authorization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Authorization.swift"; sourceTree = "<group>"; };
3404163A1E7BDFE000E2B6D6 /* PhotosViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotosViewController.swift; sourceTree = "<group>"; };
340416421E7BED3900E2B6D6 /* PhotosTransitionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotosTransitionAnimator.swift; sourceTree = "<group>"; };
340416461E7BF28E00E2B6D6 /* UIView+Snapshot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Snapshot.swift"; sourceTree = "<group>"; };
@ -2120,6 +2128,16 @@
name = Frameworks;
sourceTree = "<group>";
};
33C49D5C21774222000F8B6A /* Sharing */ = {
isa = PBXGroup;
children = (
3358607D217632A2006D11F2 /* BookmarksSharingViewController.swift */,
33BCD61521777A7400CA30B4 /* BookmarksSharingFlow.storyboard */,
33C558E2217F6CF100299E70 /* UploadActionCell.swift */,
);
path = Sharing;
sourceTree = "<group>";
};
340416391E7BDFB800E2B6D6 /* Photos */ = {
isa = PBXGroup;
children = (
@ -2340,6 +2358,7 @@
3404F4A02028A6C00090E401 /* Categories */ = {
isa = PBXGroup;
children = (
33C49D5C21774222000F8B6A /* Sharing */,
343D7B6D202AF4CA007D56A8 /* Actions */,
3404F48F202898CC0090E401 /* BMCModels.swift */,
343D7B6F202AF7AC007D56A8 /* BMCView */,
@ -2546,6 +2565,7 @@
349D1CE21E3F836900A878FD /* UIViewController+Hierarchy.swift */,
34F7422F1E0834F400AC1FD6 /* UIViewController+Navigation.h */,
34F742301E0834F400AC1FD6 /* UIViewController+Navigation.mm */,
33E905452180C40900868CAC /* UIViewController+Authorization.swift */,
347E03981FAC5F1D00426032 /* UIWindow+InputLanguage.swift */,
4767CDA320AAF66B00BD8166 /* NSAttributedString+HTML.swift */,
);
@ -4495,6 +4515,7 @@
4554B6EC1E55F0EF0084017F /* drules_proto_vehicle_clear.bin in Resources */,
F6E2FE761E097BA00083EBEC /* MWMOpeningHoursCell.xib in Resources */,
34AB66351FC5AA330078E451 /* RouteManagerCell.xib in Resources */,
33BCD61621777A7400CA30B4 /* BookmarksSharingFlow.storyboard in Resources */,
F6E2FE011E097BA00083EBEC /* MWMOpeningHoursClosedSpanTableViewCell.xib in Resources */,
F6E2FE071E097BA00083EBEC /* MWMOpeningHoursDaysSelectorTableViewCell.xib in Resources */,
F6A806531FDAE51600D4D26F /* DiscoveryViatorCollectionHolderCell.xib in Resources */,
@ -4845,6 +4866,7 @@
34AC8FDB1EFC07FE00E7F910 /* UILabel+NumberOfVisibleLines.swift in Sources */,
4767CD9F20AAD48A00BD8166 /* Checkmark.swift in Sources */,
F6E2FD981E097BA00083EBEC /* MWMBookmarkTitleCell.m in Sources */,
33E905462180C40900868CAC /* UIViewController+Authorization.swift in Sources */,
6741A9E81BF340DE002C974C /* MWMAPIBar.mm in Sources */,
349A13831DEC138C00C7DB60 /* MWMMobileInternetAlert.mm in Sources */,
349D1ADE1E2E325C004A2006 /* MWMBottomMenuViewController.mm in Sources */,
@ -4874,6 +4896,7 @@
6741A9F51BF340DE002C974C /* BookmarksVC.mm in Sources */,
B33D21B820E130D000BAD749 /* BookmarksTabViewController.swift in Sources */,
3404754A1E081A4600C92850 /* AppInfo.mm in Sources */,
3358607E217632A2006D11F2 /* BookmarksSharingViewController.swift in Sources */,
34AB662F1FC5AA330078E451 /* RouteManageriPhonePresentationController.swift in Sources */,
34AB66201FC5AA330078E451 /* RouteStartButton.swift in Sources */,
34F4072C1E9E1AFF00E57AC0 /* Banner.swift in Sources */,
@ -4999,6 +5022,7 @@
34B127EA1FBDD410008713D9 /* MWMRouterTransitStepInfo.mm in Sources */,
34926BE71EA4C2A700DCF14C /* SearchBanners.swift in Sources */,
34D3B02A1E389D05004100F9 /* MWMEditorAdditionalNameTableViewCell.mm in Sources */,
33C558E3217F6CF100299E70 /* UploadActionCell.swift in Sources */,
347E039A1FAC5F1D00426032 /* UIWindow+InputLanguage.swift in Sources */,
340475711E081A4600C92850 /* MWMSettings.mm in Sources */,
3404165C1E7C29AE00E2B6D6 /* PhotosInteractionAnimator.swift in Sources */,

View file

@ -3,19 +3,13 @@
#import "MWMMapDownloaderViewController.h"
#import "MWMMigrationView.h"
#import "MWMMigrationViewController.h"
#import "MWMStorage.h"
#import "MWMFrameworkHelper.h"
#import "Statistics.h"
#include "Framework.h"
using namespace storage;
@interface MWMStorage ()
+ (void)checkConnectionAndPerformAction:(MWMVoidBlock)action;
@end
@interface MWMMigrationViewController () <MWMCircularProgressProtocol>
@end
@ -101,7 +95,7 @@ using namespace storage;
[view setProgress:static_cast<CGFloat>(progress.first) / progress.second];
};
[MWMStorage checkConnectionAndPerformAction:^{
[MWMFrameworkHelper checkConnectionAndPerformAction:^{
self->m_countryId = f.PreMigrate(position, onStatusChanged, onProgressChanged);
if (self->m_countryId != kInvalidCountryId)
[self setState:MWMMigrationViewState::Processing];

View file

@ -9,6 +9,7 @@ enum Storyboard: Int {
case searchFilters
case settings
case welcome
case sharing
}
extension UIStoryboard {
@ -21,6 +22,7 @@ extension UIStoryboard {
case .searchFilters: name = "SearchFilters"
case .settings: name = "Settings"
case .welcome: name = "Welcome"
case .sharing: name = "BookmarksSharingFlow"
}
return UIStoryboard(name: name, bundle: nil)
}