summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2017-08-08 19:21:58 -0400
committerFabian Guerra <fabian.guerra@mapbox.com>2017-08-08 19:21:58 -0400
commita4c5b4f4b579d321bf3efdeb1ab9fd74075993a8 (patch)
tree6d7d7e8b3c675608bdf3e7ded71a199cb2e97141
parent01d801c8c73b77c75a28f4fa8148780d58fe464d (diff)
downloadqtlocation-mapboxgl-upstream/fabian-dynamic-type-7030.tar.gz
[ios, macos] Adapt Mapbox Streets–sourced layers for Dynamic Type.upstream/fabian-dynamic-type-7030
-rw-r--r--platform/darwin/src/MGLStyle.mm26
-rw-r--r--platform/darwin/src/MGLStyle_Private.h3
-rw-r--r--platform/ios/src/MGLMapView.mm7
3 files changed, 36 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index 1e0a2e02b7..8c72c19e42 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -743,6 +743,32 @@ static NSURL *MGLStyleURL_emerald;
self.localizedLayersByIdentifier = [NSMutableDictionary dictionary];
}
+ [self setPreferredContentSize:nil];
+}
+
+- (void)setPreferredContentSize:(UIContentSizeCategory)preferredContentSize
+{
+ for (MGLSymbolStyleLayer *layer in self.layers) {
+ if (![layer isKindOfClass:[MGLSymbolStyleLayer class]]) {
+ continue;
+ }
+
+ MGLVectorSource *source = (MGLVectorSource *)[self sourceWithIdentifier:layer.sourceIdentifier];
+ if (![source isKindOfClass:[MGLVectorSource class]] || !source.mapboxStreets) {
+ continue;
+ }
+
+ if ([layer.textFontSize isKindOfClass:[MGLConstantStyleValue class]]) {
+ NSNumber *textFontSize = [(MGLConstantStyleValue<NSNumber *> *)layer.textFontSize rawValue];
+ textFontSize = [NSNumber numberWithFloat:(textFontSize.floatValue * [self sizeForContentSizeCategory:preferredContentSize])];
+ layer.textFontSize = [MGLStyleValue<NSNumber *> valueWithRawValue:textFontSize];
+ }
+ }
+}
+
+- (CGFloat)sizeForContentSizeCategory:(UIContentSizeCategory)preferredContentSize
+{
+ return 1.3;
}
@end
diff --git a/platform/darwin/src/MGLStyle_Private.h b/platform/darwin/src/MGLStyle_Private.h
index 23ce8fbee0..6b96540272 100644
--- a/platform/darwin/src/MGLStyle_Private.h
+++ b/platform/darwin/src/MGLStyle_Private.h
@@ -1,4 +1,5 @@
#import "MGLStyle.h"
+#import <UIKit/UIContentSizeCategory.h>
#import "MGLStyleLayer.h"
#import "MGLFillStyleLayer.h"
@@ -21,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setStyleClasses:(NS_ARRAY_OF(NSString *) *)appliedClasses transitionDuration:(NSTimeInterval)transitionDuration;
+- (void)setPreferredContentSize:(UIContentSizeCategory)preferredContentSize;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 715c32186d..5013e5096c 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -563,6 +563,7 @@ public:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wakeGL:) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(preferredContentSizeChanged:) name:UIContentSizeCategoryDidChangeNotification object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
// set initial position
@@ -2456,6 +2457,12 @@ public:
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.accessibilityValue);
}
+- (void)preferredContentSizeChanged:(NSNotification *)notification {
+ UIContentSizeCategory preferredContentSize = [notification.userInfo objectForKey:UIContentSizeCategoryNewValueKey];
+ [self.style setPreferredContentSize:preferredContentSize];
+
+}
+
#pragma mark - Geography -
+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingCenterCoordinate