summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2019-08-14 13:26:37 -0700
committerjmkiley <jordan.kiley@mapbox.com>2019-08-14 13:26:37 -0700
commit313bcc4c2e20bc8882ebcc19ee07619446d5789f (patch)
treeaf046b0e7e44bc8724b1e4bea2ebcfd2375f68bf
parentcd129612c1d5472a7054ba4a3dd3a99ef29fe182 (diff)
downloadqtlocation-mapboxgl-313bcc4c2e20bc8882ebcc19ee07619446d5789f.tar.gz
[ios] temporary debug code, NSCache -> NSMutableDictionary
-rw-r--r--platform/ios/app/MBXViewController.m36
-rw-r--r--platform/ios/src/MGLScaleBar.mm10
2 files changed, 44 insertions, 2 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 2fb95e1b17..4f6d7987a6 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -215,6 +215,7 @@ CLLocationCoordinate2D randomWorldCoordinate() {
@property (nonatomic) NSMutableArray<UIWindow *> *helperWindows;
@property (nonatomic) NSMutableArray<UIView *> *contentInsetsOverlays;
+@property (nonatomic) NSTimer *hideScaleBarTimer;
@end
@interface MGLMapView (MBXViewController)
@@ -302,6 +303,41 @@ CLLocationCoordinate2D randomWorldCoordinate() {
}
}
}];
+
+ [self handleZoomOnScale];
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+ [self hideScaleWithAnimation:NO];
+}
+- (void)handleZoomOnScale {
+ if (!self.mapView.showsScale) { return; }
+
+ self.mapView.scaleBar.alpha = 1;
+
+ if (self.hideScaleBarTimer) {
+ [self.hideScaleBarTimer invalidate];
+ }
+
+ __weak typeof(self) weakSelf = self;
+ self.hideScaleBarTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 repeats:NO block:^(NSTimer * _Nonnull timer) {
+ if (![timer isValid]) {
+ [weakSelf hideScaleWithAnimation:YES];
+ }
+ }];
+}
+
+- (void)hideScaleWithAnimation:(BOOL)animated {
+ [self.hideScaleBarTimer invalidate];
+ self.hideScaleBarTimer = nil;
+
+ if (!animated) { return; }
+ __weak typeof(self) weakSelf = self;
+ [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
+ self.mapView.scaleBar.alpha = 0;
+ } completion:^(BOOL finished) {
+ weakSelf.mapView.showsScale = NO;
+ }];
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
diff --git a/platform/ios/src/MGLScaleBar.mm b/platform/ios/src/MGLScaleBar.mm
index 9590a99438..690fbe5e5b 100644
--- a/platform/ios/src/MGLScaleBar.mm
+++ b/platform/ios/src/MGLScaleBar.mm
@@ -84,7 +84,7 @@ static const MGLRow MGLImperialTable[] ={
@property (nonatomic) UIColor *secondaryColor;
@property (nonatomic) CALayer *borderLayer;
@property (nonatomic, assign) CGFloat borderWidth;
-@property (nonatomic) NSCache* labelImageCache;
+@property (nonatomic) NSMutableDictionary* labelImageCache;
@property (nonatomic) MGLScaleBarLabel* prototypeLabel;
@property (nonatomic) CGFloat lastLabelWidth;
@@ -159,7 +159,7 @@ static const CGFloat MGLFeetPerMeter = 3.28084;
_formatter = [[MGLDistanceFormatter alloc] init];
// Image labels are now images
- _labelImageCache = [[NSCache alloc] init];
+ _labelImageCache = [[NSMutableDictionary alloc] init];
_prototypeLabel = [[MGLScaleBarLabel alloc] init];
_prototypeLabel.font = [UIFont systemFontOfSize:8 weight:UIFontWeightMedium];
_prototypeLabel.clipsToBounds = NO;
@@ -180,8 +180,14 @@ static const CGFloat MGLFeetPerMeter = 3.28084;
// Zero is a special case (no formatting)
[self addZeroLabel];
+
+ [NSNotificationCenter defaultCenter] addObserver:<#(nonnull id)#> selector:<#(nonnull SEL)#> name:<#(nullable NSNotificationName)#> object:NSCurrentLocaleDidChangeNotification
+// NSNotificationCenter addObserver:self forKeyPath:@selector(resetLabelImageCache) options:<#(NSKeyValueObservingOptions)#> context:<#(nullable void *)#>
}
+- (void)resetLabelImageCache {
+
+}
#pragma mark - Dimensions
- (CGSize)intrinsicContentSize {