diff options
author | Julian Rex <julian.rex@mapbox.com> | 2019-05-02 14:08:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-02 14:08:48 -0400 |
commit | f7915fdc51f4924df2e2630b64908938ffa49830 (patch) | |
tree | 2364053e375a5091392096d3dd9e25086b66e847 /platform/ios/vendor | |
parent | c611d085b3dd478466f05eab24c442d53fef84ec (diff) | |
download | qtlocation-mapboxgl-f7915fdc51f4924df2e2630b64908938ffa49830.tar.gz |
[ios] Static analysis fix tweaks - part 2 (#14572)
Diffstat (limited to 'platform/ios/vendor')
-rwxr-xr-x | platform/ios/vendor/SMCalloutView/SMCalloutView.m | 84 |
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 { |