summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-10-23 14:14:29 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-10-26 14:55:19 -0700
commitd48c640b5c29699e4ffb60a6268e97784164eebd (patch)
tree211181d883e6a90e3bf6078e74850689438650c4 /ios
parent5f081701dff785090827b8a4891aa27f2bae57c6 (diff)
downloadqtlocation-mapboxgl-d48c640b5c29699e4ffb60a6268e97784164eebd.tar.gz
More natural style names in iosapp
ref #2740
Diffstat (limited to 'ios')
-rw-r--r--ios/app/MBXViewController.mm41
1 files changed, 18 insertions, 23 deletions
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm
index c8ebede43c..6a04b7fa24 100644
--- a/ios/app/MBXViewController.mm
+++ b/ios/app/MBXViewController.mm
@@ -6,20 +6,24 @@
static UIColor *const kTintColor = [UIColor colorWithRed:0.120 green:0.550 blue:0.670 alpha:1.000];
-static NSArray *const kStyleNames = @[
- @"Streets",
- @"Emerald",
- @"Light",
- @"Dark",
- @"Satellite",
- @"Satellite-Hybrid",
-];
+static struct MBXStyle {
+ NSString *name;
+ NSString *displayName;
+} MBXAvailableStyles[] = {
+ {@"streets", @"Streets"},
+ {@"emerald", @"Emerald"},
+ {@"light", @"Light"},
+ {@"dark", @"Dark"},
+ {@"satellite", @"Satellite"},
+ {@"satellite-hybrid", @"Hybrid"},
+};
static NSUInteger const kStyleVersion = 8;
@interface MBXViewController () <UIActionSheetDelegate, MGLMapViewDelegate>
@property (nonatomic) MGLMapView *mapView;
+@property (nonatomic) NSUInteger styleIndex;
@end
@@ -70,10 +74,12 @@ static NSUInteger const kStyleVersion = 8;
style:UIBarButtonItemStylePlain
target:self
action:@selector(showSettings)];
+
+ self.styleIndex = 0;
UIButton *titleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[titleButton setFrame:CGRectMake(0, 0, 150, 40)];
- [titleButton setTitle:[kStyleNames firstObject] forState:UIControlStateNormal];
+ [titleButton setTitle:MBXAvailableStyles[self.styleIndex].displayName forState:UIControlStateNormal];
[titleButton setTitleColor:kTintColor forState:UIControlStateNormal];
[titleButton addTarget:self action:@selector(cycleStyles) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.titleView = titleButton;
@@ -317,25 +323,14 @@ static NSUInteger const kStyleVersion = 8;
{
UIButton *titleButton = (UIButton *)self.navigationItem.titleView;
- NSString *styleName = [titleButton titleForState:UIControlStateNormal];
-
- if ( ! styleName)
- {
- styleName = [kStyleNames firstObject];
- }
- else
- {
- NSUInteger index = [kStyleNames indexOfObject:styleName] + 1;
- if (index == [kStyleNames count]) index = 0;
- styleName = [kStyleNames objectAtIndex:index];
- }
+ self.styleIndex = (self.styleIndex + 1) % (sizeof(MBXAvailableStyles) / sizeof(MBXAvailableStyles[0]));
self.mapView.styleURL = [NSURL URLWithString:
[NSString stringWithFormat:@"asset://styles/%@-v%lu.json",
- [styleName lowercaseString],
+ MBXAvailableStyles[self.styleIndex].name,
(unsigned long)kStyleVersion]];
- [titleButton setTitle:styleName forState:UIControlStateNormal];
+ [titleButton setTitle:MBXAvailableStyles[self.styleIndex].displayName forState:UIControlStateNormal];
}
- (void)locateUser