mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[ios] Adding offline explanation
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
@@ -37,11 +37,14 @@ BOOL canAutoDownload(storage::CountryId const &countryId) {
|
||||
using namespace storage;
|
||||
|
||||
@interface MWMMapDownloadDialog () <MWMStorageObserver, MWMCircularProgressProtocol>
|
||||
@property(strong, nonatomic) IBOutlet UILabel *explanationTitle;
|
||||
@property(strong, nonatomic) IBOutlet UILabel *explanationText;
|
||||
@property(strong, nonatomic) IBOutlet UILabel *parentNode;
|
||||
@property(strong, nonatomic) IBOutlet UILabel *node;
|
||||
@property(strong, nonatomic) IBOutlet UILabel *nodeSize;
|
||||
@property(strong, nonatomic) IBOutlet NSLayoutConstraint *nodeTopOffset;
|
||||
@property(strong, nonatomic) IBOutlet NSLayoutConstraint *nodeTop;
|
||||
@property(strong, nonatomic) IBOutlet UIButton *downloadButton;
|
||||
@property(strong, nonatomic) IBOutlet NSLayoutConstraint *explanationHeight;
|
||||
@property(strong, nonatomic) IBOutlet UIView *progressWrapper;
|
||||
|
||||
@property(weak, nonatomic) MapViewController *controller;
|
||||
@@ -51,6 +54,8 @@ using namespace storage;
|
||||
|
||||
@end
|
||||
|
||||
NSString * const kOfflineMapsExplained = @"OfflineMapsExplained";
|
||||
|
||||
@implementation MWMMapDownloadDialog {
|
||||
CountryId m_countryId;
|
||||
CountryId m_autoDownloadCountryId;
|
||||
@@ -75,8 +80,10 @@ using namespace storage;
|
||||
BOOL const noParrent = (nodeAttrs.m_parentInfo[0].m_id == s.GetRootId());
|
||||
BOOL const hideParent = (noParrent || isMultiParent);
|
||||
self.parentNode.hidden = hideParent;
|
||||
self.nodeTopOffset.priority = hideParent ? UILayoutPriorityDefaultHigh : UILayoutPriorityDefaultLow;
|
||||
if (!hideParent) {
|
||||
if (hideParent) {
|
||||
[NSLayoutConstraint activateConstraints:@[self.nodeTop]];
|
||||
} else {
|
||||
[NSLayoutConstraint deactivateConstraints:@[self.nodeTop]];
|
||||
self.parentNode.text = @(nodeAttrs.m_topmostParentInfo[0].m_localName.c_str());
|
||||
self.parentNode.textColor = [UIColor blackSecondaryText];
|
||||
}
|
||||
@@ -86,6 +93,13 @@ using namespace storage;
|
||||
self.nodeSize.textColor = [UIColor blackSecondaryText];
|
||||
self.nodeSize.text = formattedSize(nodeAttrs.m_mwmSize);
|
||||
self.nodeSize.font = [UIFont medium14].monospaced;
|
||||
if ([NSUserDefaults.standardUserDefaults integerForKey:kOfflineMapsExplained] > 1) {
|
||||
[NSLayoutConstraint activateConstraints:@[self.explanationHeight]];
|
||||
} else {
|
||||
[NSLayoutConstraint deactivateConstraints:@[self.explanationHeight]];
|
||||
}
|
||||
self.explanationTitle.text = L(@"offline_explanation_title");
|
||||
self.explanationText.text = L(@"offline_explanation_text");
|
||||
|
||||
switch (nodeAttrs.m_status) {
|
||||
case NodeStatus::NotDownloaded:
|
||||
@@ -93,6 +107,10 @@ using namespace storage;
|
||||
MapViewController *controller = self.controller;
|
||||
BOOL const isMapVisible = [controller.navigationController.topViewController isEqual:controller];
|
||||
if (isMapVisible && !self.isAutoDownloadCancelled && canAutoDownload(m_countryId)) {
|
||||
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
|
||||
NSInteger offlineMapsExplained = [userDefaults integerForKey:kOfflineMapsExplained] + 1;
|
||||
[userDefaults setInteger:offlineMapsExplained forKey:kOfflineMapsExplained];
|
||||
|
||||
m_autoDownloadCountryId = m_countryId;
|
||||
[[MWMStorage sharedStorage] downloadNode:@(m_countryId.c_str())
|
||||
onSuccess:^{
|
||||
@@ -254,6 +272,10 @@ using namespace storage;
|
||||
#pragma mark - Actions
|
||||
|
||||
- (IBAction)downloadAction {
|
||||
NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults;
|
||||
NSInteger offlineMapsExplained = [userDefaults integerForKey:kOfflineMapsExplained] + 1;
|
||||
[userDefaults setInteger:offlineMapsExplained forKey:kOfflineMapsExplained];
|
||||
|
||||
[[MWMStorage sharedStorage] downloadNode:@(m_countryId.c_str())
|
||||
onSuccess:^{ [self showInQueue]; }];
|
||||
}
|
||||
|
||||
@@ -1,19 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24127" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24063"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="I6H-BQ-1TG" customClass="MWMMapDownloadDialog">
|
||||
<rect key="frame" x="0.0" y="0.0" width="200" height="199"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="200" height="361"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RvB-y5-5iX">
|
||||
<rect key="frame" x="0.0" y="0.0" width="200" height="81.5"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="750" verticalCompressionResistancePriority="753" text="Title" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3ki-f1-eeZ">
|
||||
<rect key="frame" x="16" y="19" width="168" height="20.5"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="750" verticalCompressionResistancePriority="753" text="Text" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ls5-nm-zjo">
|
||||
<rect key="frame" x="16" y="43.5" width="168" height="16"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="13"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LCO-7E-srL" userLabel="Divider">
|
||||
<rect key="frame" x="0.0" y="80.5" width="200" height="1"/>
|
||||
<color key="backgroundColor" systemColor="opaqueSeparatorColor"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="wqE-10-TUx"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="3ki-f1-eeZ" secondAttribute="trailing" constant="16" id="6nX-Re-jqZ"/>
|
||||
<constraint firstItem="LCO-7E-srL" firstAttribute="leading" secondItem="RvB-y5-5iX" secondAttribute="leading" id="HBn-fD-OpE"/>
|
||||
<constraint firstItem="ls5-nm-zjo" firstAttribute="top" secondItem="3ki-f1-eeZ" secondAttribute="bottom" constant="4" id="KzG-oR-PAR"/>
|
||||
<constraint firstAttribute="trailing" secondItem="ls5-nm-zjo" secondAttribute="trailing" constant="16" id="MJj-zB-w2b"/>
|
||||
<constraint firstAttribute="bottom" secondItem="LCO-7E-srL" secondAttribute="bottom" id="Tfu-HV-8xZ"/>
|
||||
<constraint firstAttribute="trailing" secondItem="LCO-7E-srL" secondAttribute="trailing" id="VH1-4J-Lb4"/>
|
||||
<constraint firstAttribute="height" id="drU-cO-jmt"/>
|
||||
<constraint firstItem="LCO-7E-srL" firstAttribute="top" secondItem="ls5-nm-zjo" secondAttribute="bottom" constant="21" id="huT-bw-r1m"/>
|
||||
<constraint firstItem="3ki-f1-eeZ" firstAttribute="top" secondItem="RvB-y5-5iX" secondAttribute="top" constant="19" id="l1b-RC-c30"/>
|
||||
<constraint firstItem="ls5-nm-zjo" firstAttribute="leading" secondItem="RvB-y5-5iX" secondAttribute="leading" constant="16" id="uwk-LS-Oyj"/>
|
||||
<constraint firstItem="3ki-f1-eeZ" firstAttribute="leading" secondItem="RvB-y5-5iX" secondAttribute="leading" constant="16" id="v49-pB-FIP"/>
|
||||
</constraints>
|
||||
<variation key="default">
|
||||
<mask key="constraints">
|
||||
<exclude reference="drU-cO-jmt"/>
|
||||
</mask>
|
||||
</variation>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="751" text="Россия" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GQf-xO-gh1">
|
||||
<rect key="frame" x="14" y="20" width="172" height="29"/>
|
||||
<rect key="frame" x="14" y="100.5" width="172" height="109.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.54000000000000004" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -22,7 +66,7 @@
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="260" verticalCompressionResistancePriority="751" text="Доминиканская республика" textAlignment="center" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vMH-GY-Vm2">
|
||||
<rect key="frame" x="14" y="51" width="172" height="47"/>
|
||||
<rect key="frame" x="14" y="212" width="172" height="48"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="20"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -31,13 +75,13 @@
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="260" text="16 МБ" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vU4-G9-kcd">
|
||||
<rect key="frame" x="14" y="106" width="172" height="17"/>
|
||||
<rect key="frame" x="14" y="268" width="172" height="17"/>
|
||||
<fontDescription key="fontDescription" type="system" weight="medium" 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>
|
||||
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iyV-Rb-bea">
|
||||
<rect key="frame" x="20" y="135" width="160" height="44"/>
|
||||
<rect key="frame" x="20" y="297" width="160" height="44"/>
|
||||
<color key="backgroundColor" red="0.1176470588" green="0.58823529409999997" blue="0.94117647059999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="44" id="i64-mO-Txs"/>
|
||||
@@ -56,7 +100,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="usc-Cm-gmg" userLabel="ProgressViewWrapper">
|
||||
<rect key="frame" x="84" y="141" width="32" height="32"/>
|
||||
<rect key="frame" x="84" y="303" width="32" height="32"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="32" id="LiD-Zk-ocz"/>
|
||||
@@ -66,17 +110,21 @@
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="GQf-xO-gh1" firstAttribute="top" secondItem="I6H-BQ-1TG" secondAttribute="top" priority="500" constant="20" id="1zT-cE-XI3"/>
|
||||
<constraint firstItem="GQf-xO-gh1" firstAttribute="leading" secondItem="iyV-Rb-bea" secondAttribute="leading" constant="-6" id="4vl-GS-oaZ"/>
|
||||
<constraint firstItem="usc-Cm-gmg" firstAttribute="centerX" secondItem="iyV-Rb-bea" secondAttribute="centerX" id="7DI-KV-B8S"/>
|
||||
<constraint firstItem="vU4-G9-kcd" firstAttribute="leading" secondItem="iyV-Rb-bea" secondAttribute="leading" constant="-6" id="8nk-Fu-pae"/>
|
||||
<constraint firstAttribute="trailing" secondItem="RvB-y5-5iX" secondAttribute="trailing" id="9rv-Kg-SEX"/>
|
||||
<constraint firstAttribute="trailing" secondItem="iyV-Rb-bea" secondAttribute="trailing" constant="20" id="C8t-0i-lpV"/>
|
||||
<constraint firstItem="vMH-GY-Vm2" firstAttribute="leading" secondItem="iyV-Rb-bea" secondAttribute="leading" constant="-6" id="E4i-Dd-AQA"/>
|
||||
<constraint firstAttribute="bottom" secondItem="iyV-Rb-bea" secondAttribute="bottom" priority="500" constant="20" id="HSh-rd-XIZ"/>
|
||||
<constraint firstItem="vMH-GY-Vm2" firstAttribute="top" secondItem="GQf-xO-gh1" secondAttribute="bottom" priority="500" constant="2" id="Kje-IL-qJy"/>
|
||||
<constraint firstItem="vU4-G9-kcd" firstAttribute="top" secondItem="vMH-GY-Vm2" secondAttribute="bottom" constant="8" id="S4i-o8-W4I"/>
|
||||
<constraint firstItem="iyV-Rb-bea" firstAttribute="top" secondItem="vU4-G9-kcd" secondAttribute="bottom" constant="12" id="VN6-NK-qgb"/>
|
||||
<constraint firstItem="vMH-GY-Vm2" firstAttribute="top" secondItem="RvB-y5-5iX" secondAttribute="bottom" priority="800" constant="19" id="XpP-Zw-jAa"/>
|
||||
<constraint firstItem="iyV-Rb-bea" firstAttribute="leading" secondItem="I6H-BQ-1TG" secondAttribute="leading" constant="20" id="atf-Me-rzF"/>
|
||||
<constraint firstItem="RvB-y5-5iX" firstAttribute="leading" secondItem="I6H-BQ-1TG" secondAttribute="leading" id="c55-Kg-7X1"/>
|
||||
<constraint firstItem="GQf-xO-gh1" firstAttribute="top" secondItem="RvB-y5-5iX" secondAttribute="bottom" constant="19" id="dJk-R4-Uwg"/>
|
||||
<constraint firstItem="RvB-y5-5iX" firstAttribute="top" secondItem="I6H-BQ-1TG" secondAttribute="top" id="duL-BL-ibL"/>
|
||||
<constraint firstAttribute="trailing" secondItem="iyV-Rb-bea" secondAttribute="trailing" priority="500" constant="20" id="hgA-l8-VzT"/>
|
||||
<constraint firstItem="vU4-G9-kcd" firstAttribute="trailing" secondItem="iyV-Rb-bea" secondAttribute="trailing" constant="6" id="jZP-5b-Nbs"/>
|
||||
<constraint firstItem="usc-Cm-gmg" firstAttribute="centerY" secondItem="iyV-Rb-bea" secondAttribute="centerY" id="pxa-11-yUj"/>
|
||||
@@ -89,6 +137,7 @@
|
||||
</userDefinedRuntimeAttributes>
|
||||
<variation key="default">
|
||||
<mask key="constraints">
|
||||
<exclude reference="XpP-Zw-jAa"/>
|
||||
<exclude reference="hgA-l8-VzT"/>
|
||||
<exclude reference="C8t-0i-lpV"/>
|
||||
</mask>
|
||||
@@ -106,12 +155,21 @@
|
||||
</variation>
|
||||
<connections>
|
||||
<outlet property="downloadButton" destination="iyV-Rb-bea" id="6fy-CY-zos"/>
|
||||
<outlet property="explanationHeight" destination="drU-cO-jmt" id="AAd-rw-kWs"/>
|
||||
<outlet property="explanationText" destination="ls5-nm-zjo" id="XFr-4s-UEW"/>
|
||||
<outlet property="explanationTitle" destination="3ki-f1-eeZ" id="Y4O-1s-mCP"/>
|
||||
<outlet property="node" destination="vMH-GY-Vm2" id="LJq-UU-a3U"/>
|
||||
<outlet property="nodeSize" destination="vU4-G9-kcd" id="DMJ-NW-mxf"/>
|
||||
<outlet property="nodeTop" destination="XpP-Zw-jAa" id="zCV-UY-ru9"/>
|
||||
<outlet property="parentNode" destination="GQf-xO-gh1" id="gWT-r0-LTv"/>
|
||||
<outlet property="progressWrapper" destination="usc-Cm-gmg" id="NTd-bU-rDE"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="417.78169014084506" y="529.6875"/>
|
||||
<point key="canvasLocation" x="417.39130434782612" y="539.39732142857144"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<systemColor name="opaqueSeparatorColor">
|
||||
<color red="0.77647058820000003" green="0.77647058820000003" blue="0.7843137255" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</systemColor>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
/* Settings/Downloader - info for country which started downloading */
|
||||
"downloading" = "Downloading…";
|
||||
|
||||
/* Title of offline maps explanation */
|
||||
"offline_explanation_title" = "Offline Maps";
|
||||
|
||||
/* Text of offline maps explanation */
|
||||
"offline_explanation_text" = "A map needs to be downloaded to view and navigate the area.\nDownload maps for areas you want to travel.";
|
||||
|
||||
/* Choose measurement on first launch alert - choose metric system button */
|
||||
"kilometres" = "Kilometres";
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
/* Settings/Downloader - info for country which started downloading */
|
||||
"downloading" = "Downloading…";
|
||||
|
||||
/* Title of offline maps explanation */
|
||||
"offline_explanation_title" = "Offline Maps";
|
||||
|
||||
/* Text of offline maps explanation */
|
||||
"offline_explanation_text" = "A map needs to be downloaded to view and navigate the area.\nDownload maps for areas you want to travel.";
|
||||
|
||||
/* Choose measurement on first launch alert - choose metric system button */
|
||||
"kilometres" = "Kilometers";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user