[ios] Renamed downloads to offline packs in iosapp

This commit is contained in:
Minh Nguyễn
2016-03-10 16:55:04 -08:00
committed by Minh Nguyễn
parent ff9c3a57b0
commit 641c31507d
4 changed files with 30 additions and 30 deletions

View File

@@ -2,7 +2,7 @@
@class MGLMapView;
@interface MBXDownloadsTableViewController : UITableViewController
@interface MBXOfflinePacksTableViewController : UITableViewController
@property (nonatomic, weak) MGLMapView *mapView;

View File

@@ -1,11 +1,11 @@
#import "MBXDownloadsTableViewController.h"
#import "MBXOfflinePacksTableViewController.h"
#import <Mapbox/Mapbox.h>
static NSString * const MBXOfflinePackContextNameKey = @"Name";
static NSString * const MBXDownloadsTableViewInactiveCellReuseIdentifier = @"Inactive";
static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Active";
static NSString * const MBXOfflinePacksTableViewInactiveCellReuseIdentifier = @"Inactive";
static NSString * const MBXOfflinePacksTableViewActiveCellReuseIdentifier = @"Active";
@implementation MGLOfflinePack (MBXAdditions)
@@ -28,22 +28,22 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ
@end
@interface MBXDownloadsTableViewController () <MGLOfflinePackDelegate>
@interface MBXOfflinePacksTableViewController () <MGLOfflinePackDelegate>
@property (nonatomic, strong) NS_MUTABLE_ARRAY_OF(MGLOfflinePack *) *offlinePacks;
@end
@implementation MBXDownloadsTableViewController {
@implementation MBXOfflinePacksTableViewController {
NSUInteger _untitledRegionCount;
}
- (void)viewDidLoad {
[super viewDidLoad];
__weak MBXDownloadsTableViewController *weakSelf = self;
__weak MBXOfflinePacksTableViewController *weakSelf = self;
[[MGLOfflineStorage sharedOfflineStorage] getPacksWithCompletionHandler:^(NS_ARRAY_OF(MGLOfflinePack *) *packs, NSError *error) {
MBXDownloadsTableViewController *strongSelf = weakSelf;
MBXOfflinePacksTableViewController *strongSelf = weakSelf;
strongSelf.offlinePacks = packs.mutableCopy;
[strongSelf.tableView reloadData];
@@ -53,7 +53,7 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ
}
if (error) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Can’t Find Downloads" message:@"Mapbox GL was unable to find the existing downloads." preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Can’t Find Offline Packs" message:@"Mapbox GL was unable to find the existing offline packs." preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:^{
[strongSelf dismissViewControllerAnimated:YES completion:nil];
@@ -63,7 +63,7 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ
}
- (IBAction)addCurrentRegion:(id)sender {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Add Download" message:@"Choose a name for the download:" preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Add Offline Pack" message:@"Choose a name for the pack:" preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:nil];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
@@ -81,12 +81,12 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ
MBXOfflinePackContextNameKey: name,
}];
__weak MBXDownloadsTableViewController *weakSelf = self;
__weak MBXOfflinePacksTableViewController *weakSelf = self;
[[MGLOfflineStorage sharedOfflineStorage] addPackForRegion:region withContext:context completionHandler:^(MGLOfflinePack *pack, NSError *error) {
MBXDownloadsTableViewController *strongSelf = weakSelf;
MBXOfflinePacksTableViewController *strongSelf = weakSelf;
if (error) {
NSString *message = [NSString stringWithFormat:@"Mapbox GL was unable to add the download “%@”.", name];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Can’t Add Download" message:message preferredStyle:UIAlertControllerStyleAlert];
NSString *message = [NSString stringWithFormat:@"Mapbox GL was unable to add the offline pack “%@”.", name];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Can’t Add Offline Pack" message:message preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];
} else {
@@ -114,7 +114,7 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MGLOfflinePack *pack = self.offlinePacks[indexPath.row];
NSString *reuseIdentifier = pack.state == MGLOfflinePackStateActive ? MBXDownloadsTableViewActiveCellReuseIdentifier : MBXDownloadsTableViewInactiveCellReuseIdentifier;
NSString *reuseIdentifier = pack.state == MGLOfflinePackStateActive ? MBXOfflinePacksTableViewActiveCellReuseIdentifier : MBXOfflinePacksTableViewInactiveCellReuseIdentifier;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier forIndexPath:indexPath];
cell.textLabel.text = pack.name;
MGLOfflinePackProgress progress = pack.progress;
@@ -164,9 +164,9 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
MGLOfflinePack *pack = self.offlinePacks[indexPath.row];
__weak MBXDownloadsTableViewController *weakSelf = self;
__weak MBXOfflinePacksTableViewController *weakSelf = self;
[[MGLOfflineStorage sharedOfflineStorage] removePack:pack withCompletionHandler:^(NSError *error) {
MBXDownloadsTableViewController *strongSelf = weakSelf;
MBXOfflinePacksTableViewController *strongSelf = weakSelf;
[strongSelf.offlinePacks removeObjectAtIndex:indexPath.row];
[strongSelf.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}];

View File

@@ -1,6 +1,6 @@
#import "MBXViewController.h"
#import "MBXCustomCalloutView.h"
#import "MBXDownloadsTableViewController.h"
#import "MBXOfflinePacksTableViewController.h"
#import <Mapbox/Mapbox.h>
#import "../../../include/mbgl/util/default_styles.hpp"
@@ -102,8 +102,8 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(__unused id)sender {
if ([segue.identifier isEqualToString:@"ShowDownloads"]) {
MBXDownloadsTableViewController *controller = [segue destinationViewController];
if ([segue.identifier isEqualToString:@"ShowOfflinePacks"]) {
MBXOfflinePacksTableViewController *controller = [segue destinationViewController];
controller.mapView = self.mapView;
}
}

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10109" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="PSe-Ot-7Ff">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10115" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="PSe-Ot-7Ff">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10083"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10084"/>
<capability name="Navigation items with more than one left or right bar item" minToolsVersion="7.0"/>
</dependencies>
<scenes>
@@ -60,7 +60,7 @@
</barButtonItem>
<barButtonItem systemItem="organize" id="5IK-vz-jKQ">
<connections>
<segue destination="7q0-lI-zqb" kind="show" identifier="ShowDownloads" id="xjx-0t-0LD"/>
<segue destination="7q0-lI-zqb" kind="show" identifier="ShowOfflinePacks" id="xjx-0t-0LD"/>
</connections>
</barButtonItem>
</rightBarButtonItems>
@@ -78,10 +78,10 @@
</objects>
<point key="canvasLocation" x="1366" y="350"/>
</scene>
<!--Downloads-->
<!--Offline Packs-->
<scene sceneID="xIg-PA-7r3">
<objects>
<tableViewController id="7q0-lI-zqb" customClass="MBXDownloadsTableViewController" sceneMemberID="viewController">
<tableViewController id="7q0-lI-zqb" customClass="MBXOfflinePacksTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="eeN-6b-zqe">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -94,8 +94,8 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="My Inactive Download" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="JtH-Ce-MI5">
<rect key="frame" x="15" y="6" width="159" height="19.5"/>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="My Inactive Offline Pack" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="JtH-Ce-MI5">
<rect key="frame" x="15" y="6" width="174.5" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
@@ -118,8 +118,8 @@
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="My Active Download" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="9ZK-gS-wJ4">
<rect key="frame" x="15" y="6" width="147.5" height="19.5"/>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="My Active Offline Pack" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="9ZK-gS-wJ4">
<rect key="frame" x="15" y="6" width="163" height="19.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
@@ -141,7 +141,7 @@
<outlet property="delegate" destination="7q0-lI-zqb" id="D5X-oy-DSc"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Downloads" id="UcK-PK-eQA">
<navigationItem key="navigationItem" title="Offline Packs" id="UcK-PK-eQA">
<barButtonItem key="rightBarButtonItem" systemItem="add" id="gCV-hl-Mzc">
<connections>
<action selector="addCurrentRegion:" destination="7q0-lI-zqb" id="G2O-3V-aEA"/>