diff options
-rw-r--r-- | platform/ios/app/MBXDownloadsTableViewController.m | 41 | ||||
-rw-r--r-- | platform/ios/app/MBXViewController.mm | 3 | ||||
-rw-r--r-- | platform/ios/app/Storyboard.storyboard | 4 |
3 files changed, 47 insertions, 1 deletions
diff --git a/platform/ios/app/MBXDownloadsTableViewController.m b/platform/ios/app/MBXDownloadsTableViewController.m index db79d77d3e..1748310be6 100644 --- a/platform/ios/app/MBXDownloadsTableViewController.m +++ b/platform/ios/app/MBXDownloadsTableViewController.m @@ -19,6 +19,15 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ @end +@implementation MGLTilePyramidOfflineRegion (MBXAdditions) + +- (void)applyToMapView:(MGLMapView *)mapView { + mapView.styleURL = self.styleURL; + [mapView setVisibleCoordinateBounds:self.bounds]; +} + +@end + @interface MBXDownloadsTableViewController () <MGLOfflineTaskDelegate> @property (nonatomic, strong) NS_MUTABLE_ARRAY_OF(MGLOfflineTask *) *offlineTasks; @@ -118,11 +127,15 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ NSString *statusString; switch (task.state) { case MGLOfflineTaskStateInactive: - case MGLOfflineTaskStateComplete: statusString = [NSString stringWithFormat:@"%@ of %@ resources (%@)", completedString, expectedString, byteCountString]; break; + case MGLOfflineTaskStateComplete: + statusString = [NSString stringWithFormat:@"%@ resources (%@)", + completedString, byteCountString]; + break; + case MGLOfflineTaskStateActive: if (progress.countOfResourcesExpected) { completedString = [NSNumberFormatter localizedStringFromNumber:@(progress.countOfResourcesCompleted + 1) @@ -152,6 +165,32 @@ static NSString * const MBXDownloadsTableViewActiveCellReuseIdentifier = @"Activ } } +#pragma mark - Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + + MGLOfflineTask *task = self.offlineTasks[indexPath.row]; + switch (task.state) { + case MGLOfflineTaskStateComplete: + if ([task.region respondsToSelector:@selector(applyToMapView:)]) { + [task.region performSelector:@selector(applyToMapView:) withObject:self.mapView]; + } + [self performSegueWithIdentifier:@"ReturnToMap" sender:self]; + break; + + case MGLOfflineTaskStateInactive: + [task resume]; + [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; + break; + + case MGLOfflineTaskStateActive: + [task suspend]; + [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; + break; + } +} + #pragma mark - Offline task delegate - (void)offlineTask:(MGLOfflineTask *)task progressDidChange:(MGLOfflineTaskProgress)progress { diff --git a/platform/ios/app/MBXViewController.mm b/platform/ios/app/MBXViewController.mm index ba35feed62..e1155f1e17 100644 --- a/platform/ios/app/MBXViewController.mm +++ b/platform/ios/app/MBXViewController.mm @@ -505,6 +505,9 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = { return filePath; } +- (IBAction)unwindToMapViewController:(__unused UIStoryboardSegue *)sender { +} + #pragma mark - Destruction - (void)dealloc diff --git a/platform/ios/app/Storyboard.storyboard b/platform/ios/app/Storyboard.storyboard index 7e1eded47e..01dface475 100644 --- a/platform/ios/app/Storyboard.storyboard +++ b/platform/ios/app/Storyboard.storyboard @@ -148,8 +148,12 @@ </connections> </barButtonItem> </navigationItem> + <connections> + <segue destination="x2D-ga-sM5" kind="unwind" identifier="ReturnToMap" unwindAction="unwindToMapViewController:" id="6MZ-Ed-tu2"/> + </connections> </tableViewController> <placeholder placeholderIdentifier="IBFirstResponder" id="Dga-Vh-IxZ" userLabel="First Responder" sceneMemberID="firstResponder"/> + <exit id="x2D-ga-sM5" userLabel="Exit" sceneMemberID="exit"/> </objects> <point key="canvasLocation" x="2075" y="350"/> </scene> |