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

Add option for using play icon instead of download icon #19

Open
wants to merge 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
*/
@property (readwrite) BOOL hideProgressIcons;

/**
* Use the play icond instead of the download icon
*/
@property (readwrite) BOOL usePlayIcon;


/**
* Make the background layer to spin around its center. This should be called in the main thread.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ @implementation FFCircularProgressView
#define kArrowSizeRatio .12
#define kStopSizeRatio .3
#define kTickWidthRatio .3
#define kPlaySizeRatio .4

- (id)initWithFrame:(CGRect)frame
{
Expand Down Expand Up @@ -133,8 +134,13 @@ - (void)drawRect:(CGRect)rect
} else {
if (!self.iconView && !self.iconPath)
{
if (!_hideProgressIcons)
[self drawArrow];
if (!_hideProgressIcons) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems redundant

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying it's redundant because of the iconView?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies! Misread the code (late on Friday night). It looks fine.

if(_usePlayIcon)
[self drawPlay];
else
[self drawArrow];
}

}
else if (self.iconPath)
{
Expand Down Expand Up @@ -258,6 +264,25 @@ - (void) drawArrow {
_iconLayer.fillColor = nil;
}

- (void) drawPlay {
CGFloat radius = (self.bounds.size.width)/2;
CGFloat ratio = kPlaySizeRatio;
CGFloat sideSize = self.bounds.size.width * ratio;

UIBezierPath *stopPath = [UIBezierPath bezierPath];
[stopPath moveToPoint:CGPointMake(.25*sideSize, 0)];
[stopPath addLineToPoint:CGPointMake(sideSize, .5*sideSize)];
[stopPath addLineToPoint:CGPointMake(.25*sideSize, sideSize)];
[stopPath closePath];

// ...and move it into the right place.
[stopPath applyTransform:CGAffineTransformMakeTranslation(radius * (1-ratio), radius* (1-ratio))];

[_iconLayer setPath:stopPath.CGPath];
[_iconLayer setStrokeColor:_progressLayer.strokeColor];
[_iconLayer setFillColor:self.tintColor.CGColor];
}

#pragma mark Setters

- (void)setProgress:(CGFloat)progress {
Expand Down