Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions components/ProgressView/examples/ProgressViewExample.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ - (void)setupProgressViews {

_backwardProgressAnimateView = [[MDCProgressView alloc] init];
_backwardProgressAnimateView.translatesAutoresizingMaskIntoConstraints = NO;
_backwardProgressAnimateView.backwardProgressAnimationMode = MDCProgressViewBackwardAnimationModeAnimate;
_backwardProgressAnimateView.backwardProgressAnimationMode =
MDCProgressViewBackwardAnimationModeAnimate;
[self.view addSubview:_backwardProgressAnimateView];
// Have a non-zero progress at setup time.
_backwardProgressAnimateView.progress = 0.33;
Expand Down Expand Up @@ -155,16 +156,16 @@ - (void)setupConstraints {
@"h" : @2,
};

NSArray *verticalConstraints =
[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(p)-"
"[stockView(==h)]-(p)-[stockLabel]-(s)-"
"[tintedView(==h)]-(p)-[tintedLabel]-(s)-"
"[coloredView(==h)]-(p)-[coloredLabel]-(s)-"
"[backwardResetView(==h)]-(p)-[backwardResetLabel]-(s)-"
"[backwardAnimateView(==h)]-(p)-[backwardAnimateLabel]"
options:0
metrics:metrics
views:views];
NSArray *verticalConstraints = [NSLayoutConstraint
constraintsWithVisualFormat:@"V:|-(p)-"
"[stockView(==h)]-(p)-[stockLabel]-(s)-"
"[tintedView(==h)]-(p)-[tintedLabel]-(s)-"
"[coloredView(==h)]-(p)-[coloredLabel]-(s)-"
"[backwardResetView(==h)]-(p)-[backwardResetLabel]-(s)-"
"[backwardAnimateView(==h)]-(p)-[backwardAnimateLabel]"
options:0
metrics:metrics
views:views];
[self.view addConstraints:verticalConstraints];

NSMutableArray *horizontalConstraints = [NSMutableArray array];
Expand Down Expand Up @@ -240,12 +241,13 @@ - (void)animateBackwardProgressResetView {
__weak ProgressViewExample *weakSelf = self;

[_backwardProgressResetView setProgress:1 - _backwardProgressResetView.progress
animated:YES
completion:^(BOOL finished) {
[weakSelf performSelector:@selector(animateBackwardProgressResetView)
withObject:nil
afterDelay:MDCProgressViewAnimationDuration];
}];
animated:YES
completion:^(BOOL finished) {
[weakSelf
performSelector:@selector(animateBackwardProgressResetView)
withObject:nil
afterDelay:MDCProgressViewAnimationDuration];
}];
}

- (void)animateBackwardProgressAnimateView {
Expand All @@ -254,9 +256,10 @@ - (void)animateBackwardProgressAnimateView {
[_backwardProgressAnimateView setProgress:1 - _backwardProgressResetView.progress
animated:YES
completion:^(BOOL finished) {
[weakSelf performSelector:@selector(animateBackwardProgressAnimateView)
withObject:nil
afterDelay:MDCProgressViewAnimationDuration];
[weakSelf
performSelector:@selector(animateBackwardProgressAnimateView)
withObject:nil
afterDelay:MDCProgressViewAnimationDuration];
}];
}

Expand Down
2 changes: 1 addition & 1 deletion components/ProgressView/src/MDCProgressView.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ IB_DESIGNABLE

/**
The backward progress animation mode.

When animating progress which is lower than the current progress value, this mode
will determine which animation to use. The default is MDCProgressViewBackwardAnimationModeReset.
*/
Expand Down
3 changes: 2 additions & 1 deletion components/ProgressView/src/MDCProgressView.m
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ - (void)setProgress:(float)progress {
- (void)setProgress:(float)progress
animated:(BOOL)animated
completion:(void (^__nullable)(BOOL finished))completion {
if (progress < self.progress && self.backwardProgressAnimationMode == MDCProgressViewBackwardAnimationModeReset) {
if (progress < self.progress &&
self.backwardProgressAnimationMode == MDCProgressViewBackwardAnimationModeReset) {
self.progress = 0;
[self updateProgressView];
}
Expand Down