diff --git a/platform/ios/app/MBXDownloadsTableViewController.m b/platform/ios/app/MBXDownloadsTableViewController.m index db79d77d3..1748310be 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 () @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 ba35feed6..e1155f1e1 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 7e1eded47..01dface47 100644 --- a/platform/ios/app/Storyboard.storyboard +++ b/platform/ios/app/Storyboard.storyboard @@ -148,8 +148,12 @@ + + + +