summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-05-02 00:20:40 -0400
committerJulian Rex <julian.rex@mapbox.com>2019-05-02 00:20:40 -0400
commit512ad1f8b40d1cd5f40f0dcaee362318e7a3c58c (patch)
tree07d3011f7beeeb016cfc7d7fcf1dd2ce9299890b
parentb87b7471ce5d17bda6ea34a8db7b1950a4b3c929 (diff)
downloadqtlocation-mapboxgl-512ad1f8b40d1cd5f40f0dcaee362318e7a3c58c.tar.gz
[ios] Convert to exhaustive switch statement
-rwxr-xr-xplatform/ios/vendor/SMCalloutView/SMCalloutView.m84
1 files changed, 45 insertions, 39 deletions
diff --git a/platform/ios/vendor/SMCalloutView/SMCalloutView.m b/platform/ios/vendor/SMCalloutView/SMCalloutView.m
index 0520ba08a5..06626f9497 100755
--- a/platform/ios/vendor/SMCalloutView/SMCalloutView.m
+++ b/platform/ios/vendor/SMCalloutView/SMCalloutView.m
@@ -520,52 +520,58 @@ NSTimeInterval const kMGLSMCalloutViewRepositionDelayForUIScrollView = 1.0/3.0;
- (CAAnimation *)animationWithType:(MGLSMCalloutAnimation)type presenting:(BOOL)presenting {
CAAnimation *animation = nil;
- if (type == MGLSMCalloutAnimationBounce) {
-
- CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
- fade.duration = 0.23;
- fade.fromValue = presenting ? @0.0 : @1.0;
- fade.toValue = presenting ? @1.0 : @0.0;
- fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
-
- CABasicAnimation *bounce = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
- bounce.duration = 0.23;
- bounce.fromValue = presenting ? @0.7 : @1.0;
- bounce.toValue = presenting ? @1.0 : @0.7;
- bounce.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.59367:0.12066:0.18878:1.5814];
-
- CAAnimationGroup *group = [CAAnimationGroup animation];
- group.animations = @[fade, bounce];
- group.duration = 0.23;
-
- animation = group;
- }
- else if (type == MGLSMCalloutAnimationFade) {
- CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
- fade.duration = 1.0/3.0;
- fade.fromValue = presenting ? @0.0 : @1.0;
- fade.toValue = presenting ? @1.0 : @0.0;
- animation = fade;
- }
- else if (type == MGLSMCalloutAnimationStretch) {
- CABasicAnimation *stretch = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
- stretch.duration = 0.1;
- stretch.fromValue = presenting ? @0.0 : @1.0;
- stretch.toValue = presenting ? @1.0 : @0.0;
- animation = stretch;
+ switch (type)
+ {
+ case MGLSMCalloutAnimationBounce:
+ {
+ CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
+ fade.duration = 0.23;
+ fade.fromValue = presenting ? @0.0 : @1.0;
+ fade.toValue = presenting ? @1.0 : @0.0;
+ fade.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
+
+ CABasicAnimation *bounce = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
+ bounce.duration = 0.23;
+ bounce.fromValue = presenting ? @0.7 : @1.0;
+ bounce.toValue = presenting ? @1.0 : @0.7;
+ bounce.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.59367:0.12066:0.18878:1.5814];
+
+ CAAnimationGroup *group = [CAAnimationGroup animation];
+ group.animations = @[fade, bounce];
+ group.duration = 0.23;
+
+ animation = group;
+ break;
+ }
+
+ case MGLSMCalloutAnimationFade:
+ {
+ CABasicAnimation *fade = [CABasicAnimation animationWithKeyPath:@"opacity"];
+ fade.duration = 1.0/3.0;
+ fade.fromValue = presenting ? @0.0 : @1.0;
+ fade.toValue = presenting ? @1.0 : @0.0;
+ animation = fade;
+ break;
+ }
+
+ case MGLSMCalloutAnimationStretch:
+ {
+ CABasicAnimation *stretch = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
+ stretch.duration = 0.1;
+ stretch.fromValue = presenting ? @0.0 : @1.0;
+ stretch.toValue = presenting ? @1.0 : @0.0;
+ animation = stretch;
+ break;
+ }
}
-
- NSAssert(animation, @"There should be an animation");
-
+
// CAAnimation is KVC compliant, so we can store whether we're presenting for lookup in our delegate methods
[animation setValue:@(presenting) forKey:@"presenting"];
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
- // Cast as non-null to mute static analysis warning as documented at
- // https://clang-analyzer.llvm.org/faq.html#decide_nullability
- return (CAAnimation * _Nonnull)animation;
+ return animation;
}
- (void)layoutSubviews {