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

Fix crash when a small change in progress #108

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions src/Components/MRActivityIndicatorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#pragma clang diagnostic pop
}

@property (nonatomic, assign) float runnerSize;

/**
A float value to indicate how thick the line of the activivity indicator is.

Expand Down
10 changes: 6 additions & 4 deletions src/Components/MRActivityIndicatorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ - (void)commonInit {
self.accessibilityLabel = NSLocalizedString(@"Indeterminate Progress", @"Accessibility label for activity indicator view");

self.hidesWhenStopped = YES;

self.runnerSize = 0.9;

CAShapeLayer *shapeLayer = [CAShapeLayer new];
shapeLayer.borderWidth = 0;
shapeLayer.fillColor = UIColor.clearColor.CGColor;
Expand Down Expand Up @@ -118,11 +119,12 @@ - (void)layoutSubviews {
- (UIBezierPath *)layoutPath {
const double TWO_M_PI = 2.0*M_PI;
double startAngle = 0.75 * TWO_M_PI;
double endAngle = startAngle + TWO_M_PI * 0.9;
double endAngle = startAngle + TWO_M_PI * self.runnerSize;

CGFloat width = self.bounds.size.width;
CGFloat lineWidth = self.lineWidth;
return [UIBezierPath bezierPathWithArcCenter:CGPointMake(width/2.0f, width/2.0f)
radius:width/2.2f
radius:(width - lineWidth)/2.0f
startAngle:startAngle
endAngle:endAngle
clockwise:YES];
Expand Down Expand Up @@ -205,7 +207,7 @@ - (void)addAnimation {
CABasicAnimation *spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
spinAnimation.toValue = @(1*2*M_PI);
spinAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
spinAnimation.duration = 1.0;
spinAnimation.duration = 1.2;
spinAnimation.repeatCount = INFINITY;
[self.shapeLayer addAnimation:spinAnimation forKey:MRActivityIndicatorViewSpinAnimationKey];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/MRCircularProgressView.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ - (void)updateLabel:(float)progress {

- (void)setProgress:(float)progress animated:(BOOL)animated {
if (animated) {
if (ABS(self.progress - progress) < CGFLOAT_MIN) {
if (ABS(self.progress - progress) * 100 < 1) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/MRProgressHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static inline CGRect MRCenterCGSizeInCGRect(CGSize innerRectSize, CGRect outerRe
}


static inline CGFloat MRRotationForStatusBarOrientation() {
static inline CGFloat MRRotationForStatusBarOrientation() NS_EXTENSION_UNAVAILABLE_IOS("Status bar orientation is not available in extensions.") {
UIInterfaceOrientation orientation = UIApplication.sharedApplication.statusBarOrientation;
if (orientation == UIInterfaceOrientationLandscapeLeft) {
return -M_PI_2;
Expand Down