Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{clang-format} Format the components. #6347

Merged
merged 5 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3,565 changes: 2,993 additions & 572 deletions catalog/MaterialCatalog/MDCCatalogTiles.m

Large diffs are not rendered by default.

37 changes: 18 additions & 19 deletions components/ActionSheet/src/MDCActionSheetController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ @implementation MDCActionSheetAction
+ (instancetype)actionWithTitle:(NSString *)title
image:(UIImage *)image
handler:(void (^__nullable)(MDCActionSheetAction *action))handler {
return [[MDCActionSheetAction alloc] initWithTitle:title
image:image
handler:handler];
return [[MDCActionSheetAction alloc] initWithTitle:title image:image handler:handler];
}

- (instancetype)initWithTitle:(NSString *)title
Expand All @@ -63,7 +61,8 @@ - (id)copyWithZone:(__unused NSZone *)zone {
@end

@interface MDCActionSheetController () <MDCBottomSheetPresentationControllerDelegate,
UITableViewDelegate, UITableViewDataSource>
UITableViewDelegate,
UITableViewDataSource>
@property(nonatomic, strong) UITableView *tableView;
@property(nonatomic, strong) MDCActionSheetHeaderView *header;
@end
Expand Down Expand Up @@ -100,8 +99,8 @@ - (instancetype)initWithTitle:(NSString *)title message:(NSString *)message {
super.modalPresentationStyle = UIModalPresentationCustom;
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_transitionController.trackingScrollView = _tableView;
_tableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth
| UIViewAutoresizingFlexibleHeight);
_tableView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.estimatedRowHeight = 56;
Expand Down Expand Up @@ -211,8 +210,7 @@ - (BOOL)accessibilityPerformEscape {
- (void)preferredContentSizeDidChangeForChildContentContainer:(id<UIContentContainer>)container {
[super preferredContentSizeDidChangeForChildContentContainer:container];

[self.presentationController
preferredContentSizeDidChangeForChildContentContainer:self];
[self.presentationController preferredContentSizeDidChangeForChildContentContainer:self];
}

- (UIScrollView *)trackingScrollView {
Expand All @@ -234,7 +232,7 @@ - (void)setDismissOnBackgroundTap:(BOOL)dismissOnBackgroundTap {

/* Disable setter. Always use internal transition controller */
- (void)setTransitioningDelegate:
(__unused id<UIViewControllerTransitioningDelegate>)transitioningDelegate {
(__unused id<UIViewControllerTransitioningDelegate>)transitioningDelegate {
NSAssert(NO, @"MDCActionSheetController.transitioningDelegate cannot be changed.");
return;
}
Expand All @@ -255,11 +253,12 @@ - (void)updateTable {
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MDCActionSheetAction *action = self.actions[indexPath.row];

[self.presentingViewController dismissViewControllerAnimated:YES completion:^(void){
if (action.completionHandler) {
action.completionHandler(action);
}
}];
[self.presentingViewController dismissViewControllerAnimated:YES
yarneo marked this conversation as resolved.
Show resolved Hide resolved
completion:^(void) {
if (action.completionHandler) {
action.completionHandler(action);
}
}];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
Expand Down Expand Up @@ -364,12 +363,12 @@ - (void)mdc_setAdjustsFontForContentSizeCategory:(BOOL)adjusts {
}

- (void)updateTableFonts {
UIFont *finalActionsFont = _actionFont ?:
[UIFont mdc_standardFontForMaterialTextStyle:MDCFontTextStyleSubheadline];
UIFont *finalActionsFont =
_actionFont ?: [UIFont mdc_standardFontForMaterialTextStyle:MDCFontTextStyleSubheadline];
if (self.mdc_adjustsFontForContentSizeCategory) {
finalActionsFont =
[finalActionsFont mdc_fontSizedForMaterialTextStyle:MDCFontTextStyleSubheadline
scaledForDynamicType:self.mdc_adjustsFontForContentSizeCategory];
finalActionsFont = [finalActionsFont
mdc_fontSizedForMaterialTextStyle:MDCFontTextStyleSubheadline
scaledForDynamicType:self.mdc_adjustsFontForContentSizeCategory];
}
_actionFont = finalActionsFont;
[self updateTable];
Expand Down
22 changes: 11 additions & 11 deletions components/ActionSheet/src/private/MDCActionSheetHeaderView.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ - (void)updateFonts {
}

- (void)updateTitleFont {
UIFont *titleFont = self.titleFont ?:
[UIFont mdc_standardFontForMaterialTextStyle:MDCFontTextStyleSubheadline];
UIFont *titleFont =
self.titleFont ?: [UIFont mdc_standardFontForMaterialTextStyle:MDCFontTextStyleSubheadline];
if (self.mdc_adjustsFontForContentSizeCategory) {
self.titleLabel.font =
[titleFont mdc_fontSizedForMaterialTextStyle:MDCFontTextStyleSubheadline
Expand All @@ -165,8 +165,8 @@ - (void)updateTitleFont {
}

- (void)updateMessageFont {
UIFont *messageFont = self.messageFont ?:
[UIFont mdc_standardFontForMaterialTextStyle:MDCFontTextStyleBody1];
UIFont *messageFont =
self.messageFont ?: [UIFont mdc_standardFontForMaterialTextStyle:MDCFontTextStyleBody1];
if (self.mdc_adjustsFontForContentSizeCategory) {
self.messageLabel.font =
[messageFont mdc_fontSizedForMaterialTextStyle:MDCFontTextStyleBody1
Expand All @@ -181,14 +181,14 @@ - (void)updateMessageFont {
- (void)mdc_setAdjustsFontForContentSizeCategory:(BOOL)adjusts {
_mdc_adjustsFontForContentSizeCategory = adjusts;
if (_mdc_adjustsFontForContentSizeCategory) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateFonts)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateFonts)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
} else {
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIContentSizeCategoryDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIContentSizeCategoryDidChangeNotification
object:nil];
}
[self updateFonts];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ - (void)setActionFont:(UIFont *)actionFont {
}

- (void)updateTitleFont {
UIFont *titleFont = _actionFont ?:
[UIFont mdc_standardFontForMaterialTextStyle:MDCFontTextStyleSubheadline];
UIFont *titleFont =
_actionFont ?: [UIFont mdc_standardFontForMaterialTextStyle:MDCFontTextStyleSubheadline];
if (self.mdc_adjustsFontForContentSizeCategory) {
self.actionLabel.font =
[titleFont mdc_fontSizedForMaterialTextStyle:MDCFontTextStyleSubheadline
Expand Down
86 changes: 40 additions & 46 deletions components/ActivityIndicator/src/MDCActivityIndicator.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

#import "MDCActivityIndicator.h"

#import <QuartzCore/QuartzCore.h>
#import <MDFInternationalization/MDFInternationalization.h>
#import <MotionAnimator/MotionAnimator.h>
#import <QuartzCore/QuartzCore.h>

#import "MaterialApplication.h"
#import "MaterialPalettes.h"
#import "private/MDCActivityIndicatorMotionSpec.h"
#import "private/MDCActivityIndicator+Private.h"
#import "private/MDCActivityIndicatorMotionSpec.h"
#import "private/MaterialActivityIndicatorStrings.h"
#import "private/MaterialActivityIndicatorStrings_table.h"

Expand Down Expand Up @@ -248,7 +248,7 @@ - (void)startAnimating {
if (!self.window || _backgrounded) {
return;
}

[self actuallyStartAnimating];
}

Expand Down Expand Up @@ -289,7 +289,8 @@ - (void)startAnimatingWithTransition:(nonnull MDCActivityIndicatorTransition *)s

[self actuallyStartAnimating];

self.cycleColorsIndex = self.cycleColors.count > 0 ? cycleStartIndex % self.cycleColors.count : 0;
self.cycleColorsIndex =
self.cycleColors.count > 0 ? cycleStartIndex % self.cycleColors.count : 0;
[self applyPropertiesWithoutAnimation:^{
[self updateStrokeColor];
}];
Expand Down Expand Up @@ -523,10 +524,8 @@ - (void)setCycleColors:(NSArray<UIColor *> *)cycleColors {
- (void)addStopAnimation {
MDCActivityIndicatorTransition *stopTransition = self.stopTransition;

CGFloat innerRotation =
[[_strokeLayer valueForKeyPath:MDMKeyPathRotation] floatValue];
CGFloat outerRotation =
[[_outerRotationLayer valueForKeyPath:MDMKeyPathRotation] floatValue];
CGFloat innerRotation = [[_strokeLayer valueForKeyPath:MDMKeyPathRotation] floatValue];
CGFloat outerRotation = [[_outerRotationLayer valueForKeyPath:MDMKeyPathRotation] floatValue];
CGFloat totalRotation =
(CGFloat)fmod(innerRotation + outerRotation, 2 * M_PI) / (CGFloat)(2 * M_PI);

Expand Down Expand Up @@ -603,27 +602,29 @@ - (void)addStrokeRotationCycle {

[_animator animateWithTiming:timing.outerRotation
toLayer:_outerRotationLayer
withValues:@[@(kOuterRotationIncrement * _cycleCount),
@(kOuterRotationIncrement * (_cycleCount + 1))]
withValues:@[
@(kOuterRotationIncrement * _cycleCount),
@(kOuterRotationIncrement * (_cycleCount + 1))
]
keyPath:MDMKeyPathRotation];

CGFloat startRotation = _cycleCount * (CGFloat)M_PI;
CGFloat endRotation = startRotation + kCycleRotation * (CGFloat)M_PI;
[_animator animateWithTiming:timing.innerRotation
toLayer:_strokeLayer
withValues:@[@(startRotation), @(endRotation)]
withValues:@[ @(startRotation), @(endRotation) ]
keyPath:MDMKeyPathRotation];

[_animator animateWithTiming:timing.strokeStart
toLayer:_strokeLayer
withValues:@[@0, @(kStrokeLength)]
withValues:@[ @0, @(kStrokeLength) ]
keyPath:MDMKeyPathStrokeStart];

// Ensure the stroke never completely disappears on start by animating from non-zero start and
// to a value slightly larger than the strokeStart's final value.
[_animator animateWithTiming:timing.strokeEnd
toLayer:_strokeLayer
withValues:@[@(_minStrokeDifference), @(kStrokeLength + _minStrokeDifference)]
withValues:@[ @(_minStrokeDifference), @(kStrokeLength + _minStrokeDifference) ]
keyPath:MDMKeyPathStrokeEnd];

[CATransaction commit];
Expand Down Expand Up @@ -668,8 +669,8 @@ - (void)addTransitionToIndeterminateCycle {
CGFloat pointCycleDuration = (CGFloat)MDCActivityIndicatorMotionSpec.pointCycleDuration;
CGFloat pointCycleMinimumVariableDuration =
(CGFloat)MDCActivityIndicatorMotionSpec.pointCycleMinimumVariableDuration;
CGFloat normalizedDuration = 2 * (targetRotation + _currentProgress) / kSingleCycleRotation *
pointCycleDuration;
CGFloat normalizedDuration =
2 * (targetRotation + _currentProgress) / kSingleCycleRotation * pointCycleDuration;
CGFloat strokeEndTravelDistance = targetRotation - _currentProgress + _minStrokeDifference;
CGFloat totalDistance = targetRotation + strokeEndTravelDistance;
CGFloat strokeStartDuration =
Expand Down Expand Up @@ -698,14 +699,14 @@ - (void)addTransitionToIndeterminateCycle {
timing.strokeStart.delay = strokeEndDuration;
[_animator animateWithTiming:timing.strokeStart
toLayer:_strokeLayer
withValues:@[@0, @(targetRotation)]
withValues:@[ @0, @(targetRotation) ]
keyPath:MDMKeyPathStrokeStart];

timing.strokeEnd.duration = strokeEndDuration;
timing.strokeEnd.delay = 0;
[_animator animateWithTiming:timing.strokeEnd
toLayer:_strokeLayer
withValues:@[@(_currentProgress), @(targetRotation + _minStrokeDifference)]
withValues:@[ @(_currentProgress), @(targetRotation + _minStrokeDifference) ]
keyPath:MDMKeyPathStrokeEnd];
}
[CATransaction commit];
Expand Down Expand Up @@ -746,7 +747,8 @@ - (void)addTransitionToDeterminateCycle {
[CATransaction setCompletionBlock:^{
[self
strokeRotationCycleFinishedFromState:MDCActivityIndicatorStateTransitionToDeterminate];
if ([self.delegate respondsToSelector:@selector(activityIndicatorModeTransitionDidFinish:)]) {
if ([self.delegate
respondsToSelector:@selector(activityIndicatorModeTransitionDidFinish:)]) {
[self.delegate activityIndicatorModeTransitionDidFinish:self];
}
}];
Expand All @@ -763,14 +765,14 @@ - (void)addTransitionToDeterminateCycle {
CGFloat endRotation = startRotation + rotationDelta * 2 * (CGFloat)M_PI;
[_animator animateWithTiming:spec.innerRotation
toLayer:_strokeLayer
withValues:@[@(startRotation), @(endRotation)]
withValues:@[ @(startRotation), @(endRotation) ]
keyPath:MDMKeyPathRotation];

_strokeLayer.strokeStart = 0;

[_animator animateWithTiming:spec.strokeEnd
toLayer:_strokeLayer
withValues:@[@(_minStrokeDifference), @(_currentProgress)]
withValues:@[ @(_minStrokeDifference), @(_currentProgress) ]
keyPath:MDMKeyPathStrokeEnd];
}
[CATransaction commit];
Expand Down Expand Up @@ -800,7 +802,7 @@ - (void)addProgressAnimation {

[_animator animateWithTiming:MDCActivityIndicatorMotionSpec.willChangeProgress.strokeEnd
toLayer:_strokeLayer
withValues:@[@(_lastProgress), @(_currentProgress)]
withValues:@[ @(_lastProgress), @(_currentProgress) ]
keyPath:MDMKeyPathStrokeEnd];
}

Expand Down Expand Up @@ -912,8 +914,8 @@ - (void)removeAnimations {
[_strokeLayer removeAllAnimations];
[_outerRotationLayer removeAllAnimations];

// Reset current and latest progress, to ensure addProgressAnimationIfRequired adds a progress animation
// when returning from hidden.
// Reset current and latest progress, to ensure addProgressAnimationIfRequired adds a progress
// animation when returning from hidden.
_currentProgress = 0;
_lastProgress = 0;

Expand All @@ -931,11 +933,10 @@ + (CGFloat)defaultHeight {
static NSArray<UIColor *> *s_defaultCycleColors;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
s_defaultCycleColors =
@[ MDCPalette.bluePalette.tint500,
MDCPalette.redPalette.tint500,
MDCPalette.yellowPalette.tint500,
MDCPalette.greenPalette.tint500 ];
s_defaultCycleColors = @[
yarneo marked this conversation as resolved.
Show resolved Hide resolved
MDCPalette.bluePalette.tint500, MDCPalette.redPalette.tint500,
MDCPalette.yellowPalette.tint500, MDCPalette.greenPalette.tint500
];
});
return s_defaultCycleColors;
}
Expand Down Expand Up @@ -967,7 +968,7 @@ + (NSString *)bundlePathWithName:(NSString *)bundleName {
// not be in the main .app bundle, but rather in a nested framework, so figure out where we live
// and use that as the search location.
NSBundle *bundle = [NSBundle bundleForClass:[MDCActivityIndicator class]];
NSString *resourcePath = [(nil == bundle ? [NSBundle mainBundle] : bundle)resourcePath];
NSString *resourcePath = [(nil == bundle ? [NSBundle mainBundle] : bundle) resourcePath];
return [resourcePath stringByAppendingPathComponent:bundleName];
}

Expand All @@ -980,10 +981,8 @@ - (BOOL)isAccessibilityElement {
- (NSString *)defaultAccessibilityLabel {
MaterialActivityIndicatorStringId keyIndex = kStr_MaterialActivityIndicatorAccessibilityLabel;
NSString *key = kMaterialActivityIndicatorStringTable[keyIndex];
return NSLocalizedStringFromTableInBundle(key,
kMaterialActivityIndicatorStringsTableName,
[[self class] bundle],
@"Activity Indicator");
return NSLocalizedStringFromTableInBundle(key, kMaterialActivityIndicatorStringsTableName,
yarneo marked this conversation as resolved.
Show resolved Hide resolved
[[self class] bundle], @"Activity Indicator");
}

- (NSString *)accessibilityValue {
Expand All @@ -992,29 +991,24 @@ - (NSString *)accessibilityValue {
MaterialActivityIndicatorStringId keyIndex =
kStr_MaterialActivityIndicatorInProgressAccessibilityValue;
NSString *key = kMaterialActivityIndicatorStringTable[keyIndex];
return NSLocalizedStringFromTableInBundle(key,
kMaterialActivityIndicatorStringsTableName,
[[self class] bundle],
@"In Progress");
return NSLocalizedStringFromTableInBundle(key, kMaterialActivityIndicatorStringsTableName,
yarneo marked this conversation as resolved.
Show resolved Hide resolved
[[self class] bundle], @"In Progress");
} else {
NSUInteger percentage = (int)(self.progress * 100);
MaterialActivityIndicatorStringId keyIndex =
kStr_MaterialActivityIndicatorProgressCompletedAccessibilityValue;
NSString *key = kMaterialActivityIndicatorStringTable[keyIndex];
NSString *localizedString = NSLocalizedStringFromTableInBundle(key,
kMaterialActivityIndicatorStringsTableName,
[[self class] bundle],
@"{percentage} Percent Complete");
NSString *localizedString = NSLocalizedStringFromTableInBundle(
yarneo marked this conversation as resolved.
Show resolved Hide resolved
key, kMaterialActivityIndicatorStringsTableName, [[self class] bundle],
@"{percentage} Percent Complete");
return [NSString localizedStringWithFormat:localizedString, percentage];
}
} else {
MaterialActivityIndicatorStringId keyIndex =
kStr_MaterialActivityIndicatorProgressHaltedAccessibilityValue;
NSString *key = kMaterialActivityIndicatorStringTable[keyIndex];
return NSLocalizedStringFromTableInBundle(key,
kMaterialActivityIndicatorStringsTableName,
[[self class] bundle],
@"Progress Halted");
return NSLocalizedStringFromTableInBundle(key, kMaterialActivityIndicatorStringsTableName,
yarneo marked this conversation as resolved.
Show resolved Hide resolved
[[self class] bundle], @"Progress Halted");
}
}

Expand All @@ -1030,6 +1024,6 @@ - (nonnull instancetype)initWithAnimation:(_Nonnull MDCActivityIndicatorAnimatio
if (self) {
self.animation = animation;
}
return self;
return self;
}
@end
Loading