14
14
15
15
#import " MDCActivityIndicator.h"
16
16
17
- #import < QuartzCore/QuartzCore.h>
18
17
#import < MDFInternationalization/MDFInternationalization.h>
19
18
#import < MotionAnimator/MotionAnimator.h>
19
+ #import < QuartzCore/QuartzCore.h>
20
20
21
21
#import " MaterialApplication.h"
22
22
#import " MaterialPalettes.h"
23
- #import " private/MDCActivityIndicatorMotionSpec.h"
24
23
#import " private/MDCActivityIndicator+Private.h"
24
+ #import " private/MDCActivityIndicatorMotionSpec.h"
25
25
#import " private/MaterialActivityIndicatorStrings.h"
26
26
#import " private/MaterialActivityIndicatorStrings_table.h"
27
27
@@ -248,7 +248,7 @@ - (void)startAnimating {
248
248
if (!self.window || _backgrounded) {
249
249
return ;
250
250
}
251
-
251
+
252
252
[self actuallyStartAnimating ];
253
253
}
254
254
@@ -289,7 +289,8 @@ - (void)startAnimatingWithTransition:(nonnull MDCActivityIndicatorTransition *)s
289
289
290
290
[self actuallyStartAnimating ];
291
291
292
- self.cycleColorsIndex = self.cycleColors .count > 0 ? cycleStartIndex % self.cycleColors .count : 0 ;
292
+ self.cycleColorsIndex =
293
+ self.cycleColors .count > 0 ? cycleStartIndex % self.cycleColors .count : 0 ;
293
294
[self applyPropertiesWithoutAnimation: ^{
294
295
[self updateStrokeColor ];
295
296
}];
@@ -523,10 +524,8 @@ - (void)setCycleColors:(NSArray<UIColor *> *)cycleColors {
523
524
- (void )addStopAnimation {
524
525
MDCActivityIndicatorTransition *stopTransition = self.stopTransition ;
525
526
526
- CGFloat innerRotation =
527
- [[_strokeLayer valueForKeyPath: MDMKeyPathRotation] floatValue ];
528
- CGFloat outerRotation =
529
- [[_outerRotationLayer valueForKeyPath: MDMKeyPathRotation] floatValue ];
527
+ CGFloat innerRotation = [[_strokeLayer valueForKeyPath: MDMKeyPathRotation] floatValue ];
528
+ CGFloat outerRotation = [[_outerRotationLayer valueForKeyPath: MDMKeyPathRotation] floatValue ];
530
529
CGFloat totalRotation =
531
530
(CGFloat )fmod (innerRotation + outerRotation, 2 * M_PI) / (CGFloat )(2 * M_PI);
532
531
@@ -603,27 +602,29 @@ - (void)addStrokeRotationCycle {
603
602
604
603
[_animator animateWithTiming: timing.outerRotation
605
604
toLayer: _outerRotationLayer
606
- withValues: @[@(kOuterRotationIncrement * _cycleCount),
607
- @(kOuterRotationIncrement * (_cycleCount + 1 ))]
605
+ withValues: @[
606
+ @(kOuterRotationIncrement * _cycleCount),
607
+ @(kOuterRotationIncrement * (_cycleCount + 1 ))
608
+ ]
608
609
keyPath: MDMKeyPathRotation];
609
610
610
611
CGFloat startRotation = _cycleCount * (CGFloat )M_PI;
611
612
CGFloat endRotation = startRotation + kCycleRotation * (CGFloat )M_PI;
612
613
[_animator animateWithTiming: timing.innerRotation
613
614
toLayer: _strokeLayer
614
- withValues: @[@(startRotation), @(endRotation)]
615
+ withValues: @[ @(startRotation), @(endRotation) ]
615
616
keyPath: MDMKeyPathRotation];
616
617
617
618
[_animator animateWithTiming: timing.strokeStart
618
619
toLayer: _strokeLayer
619
- withValues: @[@0 , @(kStrokeLength )]
620
+ withValues: @[ @0 , @(kStrokeLength ) ]
620
621
keyPath: MDMKeyPathStrokeStart];
621
622
622
623
// Ensure the stroke never completely disappears on start by animating from non-zero start and
623
624
// to a value slightly larger than the strokeStart's final value.
624
625
[_animator animateWithTiming: timing.strokeEnd
625
626
toLayer: _strokeLayer
626
- withValues: @[@(_minStrokeDifference), @(kStrokeLength + _minStrokeDifference)]
627
+ withValues: @[ @(_minStrokeDifference), @(kStrokeLength + _minStrokeDifference) ]
627
628
keyPath: MDMKeyPathStrokeEnd];
628
629
629
630
[CATransaction commit ];
@@ -668,8 +669,8 @@ - (void)addTransitionToIndeterminateCycle {
668
669
CGFloat pointCycleDuration = (CGFloat )MDCActivityIndicatorMotionSpec.pointCycleDuration ;
669
670
CGFloat pointCycleMinimumVariableDuration =
670
671
(CGFloat )MDCActivityIndicatorMotionSpec.pointCycleMinimumVariableDuration ;
671
- CGFloat normalizedDuration = 2 * (targetRotation + _currentProgress) / kSingleCycleRotation *
672
- pointCycleDuration;
672
+ CGFloat normalizedDuration =
673
+ 2 * (targetRotation + _currentProgress) / kSingleCycleRotation * pointCycleDuration;
673
674
CGFloat strokeEndTravelDistance = targetRotation - _currentProgress + _minStrokeDifference;
674
675
CGFloat totalDistance = targetRotation + strokeEndTravelDistance;
675
676
CGFloat strokeStartDuration =
@@ -698,14 +699,14 @@ - (void)addTransitionToIndeterminateCycle {
698
699
timing.strokeStart .delay = strokeEndDuration;
699
700
[_animator animateWithTiming: timing.strokeStart
700
701
toLayer: _strokeLayer
701
- withValues: @[@0 , @(targetRotation)]
702
+ withValues: @[ @0 , @(targetRotation) ]
702
703
keyPath: MDMKeyPathStrokeStart];
703
704
704
705
timing.strokeEnd .duration = strokeEndDuration;
705
706
timing.strokeEnd .delay = 0 ;
706
707
[_animator animateWithTiming: timing.strokeEnd
707
708
toLayer: _strokeLayer
708
- withValues: @[@(_currentProgress), @(targetRotation + _minStrokeDifference)]
709
+ withValues: @[ @(_currentProgress), @(targetRotation + _minStrokeDifference) ]
709
710
keyPath: MDMKeyPathStrokeEnd];
710
711
}
711
712
[CATransaction commit ];
@@ -746,7 +747,8 @@ - (void)addTransitionToDeterminateCycle {
746
747
[CATransaction setCompletionBlock: ^{
747
748
[self
748
749
strokeRotationCycleFinishedFromState: MDCActivityIndicatorStateTransitionToDeterminate];
749
- if ([self .delegate respondsToSelector: @selector (activityIndicatorModeTransitionDidFinish: )]) {
750
+ if ([self .delegate
751
+ respondsToSelector: @selector (activityIndicatorModeTransitionDidFinish: )]) {
750
752
[self .delegate activityIndicatorModeTransitionDidFinish: self ];
751
753
}
752
754
}];
@@ -763,14 +765,14 @@ - (void)addTransitionToDeterminateCycle {
763
765
CGFloat endRotation = startRotation + rotationDelta * 2 * (CGFloat )M_PI;
764
766
[_animator animateWithTiming: spec.innerRotation
765
767
toLayer: _strokeLayer
766
- withValues: @[@(startRotation), @(endRotation)]
768
+ withValues: @[ @(startRotation), @(endRotation) ]
767
769
keyPath: MDMKeyPathRotation];
768
770
769
771
_strokeLayer.strokeStart = 0 ;
770
772
771
773
[_animator animateWithTiming: spec.strokeEnd
772
774
toLayer: _strokeLayer
773
- withValues: @[@(_minStrokeDifference), @(_currentProgress)]
775
+ withValues: @[ @(_minStrokeDifference), @(_currentProgress) ]
774
776
keyPath: MDMKeyPathStrokeEnd];
775
777
}
776
778
[CATransaction commit ];
@@ -800,7 +802,7 @@ - (void)addProgressAnimation {
800
802
801
803
[_animator animateWithTiming: MDCActivityIndicatorMotionSpec.willChangeProgress.strokeEnd
802
804
toLayer: _strokeLayer
803
- withValues: @[@(_lastProgress), @(_currentProgress)]
805
+ withValues: @[ @(_lastProgress), @(_currentProgress) ]
804
806
keyPath: MDMKeyPathStrokeEnd];
805
807
}
806
808
@@ -912,8 +914,8 @@ - (void)removeAnimations {
912
914
[_strokeLayer removeAllAnimations ];
913
915
[_outerRotationLayer removeAllAnimations ];
914
916
915
- // Reset current and latest progress, to ensure addProgressAnimationIfRequired adds a progress animation
916
- // when returning from hidden.
917
+ // Reset current and latest progress, to ensure addProgressAnimationIfRequired adds a progress
918
+ // animation when returning from hidden.
917
919
_currentProgress = 0 ;
918
920
_lastProgress = 0 ;
919
921
@@ -931,11 +933,10 @@ + (CGFloat)defaultHeight {
931
933
static NSArray <UIColor *> *s_defaultCycleColors;
932
934
static dispatch_once_t onceToken;
933
935
dispatch_once (&onceToken, ^{
934
- s_defaultCycleColors =
935
- @[ MDCPalette.bluePalette.tint500,
936
- MDCPalette.redPalette.tint500,
937
- MDCPalette.yellowPalette.tint500,
938
- MDCPalette.greenPalette.tint500 ];
936
+ s_defaultCycleColors = @[
937
+ MDCPalette.bluePalette.tint500, MDCPalette.redPalette.tint500,
938
+ MDCPalette.yellowPalette.tint500, MDCPalette.greenPalette.tint500
939
+ ];
939
940
});
940
941
return s_defaultCycleColors;
941
942
}
@@ -967,7 +968,7 @@ + (NSString *)bundlePathWithName:(NSString *)bundleName {
967
968
// not be in the main .app bundle, but rather in a nested framework, so figure out where we live
968
969
// and use that as the search location.
969
970
NSBundle *bundle = [NSBundle bundleForClass: [MDCActivityIndicator class ]];
970
- NSString *resourcePath = [(nil == bundle ? [NSBundle mainBundle ] : bundle)resourcePath];
971
+ NSString *resourcePath = [(nil == bundle ? [NSBundle mainBundle ] : bundle) resourcePath ];
971
972
return [resourcePath stringByAppendingPathComponent: bundleName];
972
973
}
973
974
@@ -980,10 +981,8 @@ - (BOOL)isAccessibilityElement {
980
981
- (NSString *)defaultAccessibilityLabel {
981
982
MaterialActivityIndicatorStringId keyIndex = kStr_MaterialActivityIndicatorAccessibilityLabel ;
982
983
NSString *key = kMaterialActivityIndicatorStringTable [keyIndex];
983
- return NSLocalizedStringFromTableInBundle(key,
984
- kMaterialActivityIndicatorStringsTableName ,
985
- [[self class ] bundle ],
986
- @" Activity Indicator" );
984
+ return NSLocalizedStringFromTableInBundle(key, kMaterialActivityIndicatorStringsTableName ,
985
+ [[self class ] bundle ], @" Activity Indicator" );
987
986
}
988
987
989
988
- (NSString *)accessibilityValue {
@@ -992,29 +991,24 @@ - (NSString *)accessibilityValue {
992
991
MaterialActivityIndicatorStringId keyIndex =
993
992
kStr_MaterialActivityIndicatorInProgressAccessibilityValue ;
994
993
NSString *key = kMaterialActivityIndicatorStringTable [keyIndex];
995
- return NSLocalizedStringFromTableInBundle(key,
996
- kMaterialActivityIndicatorStringsTableName ,
997
- [[self class ] bundle ],
998
- @" In Progress" );
994
+ return NSLocalizedStringFromTableInBundle(key, kMaterialActivityIndicatorStringsTableName ,
995
+ [[self class ] bundle ], @" In Progress" );
999
996
} else {
1000
997
NSUInteger percentage = (int )(self.progress * 100 );
1001
998
MaterialActivityIndicatorStringId keyIndex =
1002
999
kStr_MaterialActivityIndicatorProgressCompletedAccessibilityValue ;
1003
1000
NSString *key = kMaterialActivityIndicatorStringTable [keyIndex];
1004
- NSString *localizedString = NSLocalizedStringFromTableInBundle(key,
1005
- kMaterialActivityIndicatorStringsTableName ,
1006
- [[self class ] bundle ],
1007
- @" {percentage} Percent Complete" );
1001
+ NSString *localizedString = NSLocalizedStringFromTableInBundle(
1002
+ key, kMaterialActivityIndicatorStringsTableName , [[self class ] bundle ],
1003
+ @" {percentage} Percent Complete" );
1008
1004
return [NSString localizedStringWithFormat: localizedString, percentage];
1009
1005
}
1010
1006
} else {
1011
1007
MaterialActivityIndicatorStringId keyIndex =
1012
1008
kStr_MaterialActivityIndicatorProgressHaltedAccessibilityValue ;
1013
1009
NSString *key = kMaterialActivityIndicatorStringTable [keyIndex];
1014
- return NSLocalizedStringFromTableInBundle(key,
1015
- kMaterialActivityIndicatorStringsTableName ,
1016
- [[self class ] bundle ],
1017
- @" Progress Halted" );
1010
+ return NSLocalizedStringFromTableInBundle(key, kMaterialActivityIndicatorStringsTableName ,
1011
+ [[self class ] bundle ], @" Progress Halted" );
1018
1012
}
1019
1013
}
1020
1014
@@ -1030,6 +1024,6 @@ - (nonnull instancetype)initWithAnimation:(_Nonnull MDCActivityIndicatorAnimatio
1030
1024
if (self) {
1031
1025
self.animation = animation;
1032
1026
}
1033
- return self;
1027
+ return self;
1034
1028
}
1035
1029
@end
0 commit comments