Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Version 1.3.0
Browse files Browse the repository at this point in the history
- Add a property for accessing the current value of the progress ring while animating, closes [issue #14](#14)
- Add fix for removing a currently running animation when calling `setProgress(:)` while ring is animating, closes [issue #19](#19)
- Fixed access levels for variables and functions, changed from `public` to `open` to allow subclassing.
- Updated `docs` by running Jazzy
  • Loading branch information
Luis Padron authored and Luis Padron committed Mar 2, 2017
1 parent 2177f82 commit d63bacb
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 94 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Version 1.3.0

- Add a property for accessing the current value of the progress ring while animating, closes [issue #14](https://github.com/luispadron/UICircularProgressRing/issues/14)
- Add fix for removing a currently running animation when calling `setProgress(:)` while ring is animating, closes [issue #19](https://github.com/luispadron/UICircularProgressRing/issues/19)
- Fixed access levels for variables and functions, changed from `public` to `open` to allow subclassing.
- Updated `docs` by running Jazzy


# Version 1.2.2

- Remove useless print statements from guards
Expand Down
2 changes: 1 addition & 1 deletion UICircularProgressRing.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pod::Spec.new do |s|

s.name = "UICircularProgressRing"
s.version = "1.2.2"
s.version = "1.3.0"
s.summary = "A highly customizable circular progress bar for iOS written in Swift 3"

s.description = <<-DESC
Expand Down
79 changes: 51 additions & 28 deletions UICircularProgressRing/UICircularProgressRingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import UIKit
## Author:
Luis Padron
*/
public weak var delegate: UICircularProgressRingDelegate?
open weak var delegate: UICircularProgressRingDelegate?

// MARK: Value Properties

Expand All @@ -66,18 +66,39 @@ import UIKit
## Important ##
Default = 0
This cannot be used to get the value while the ring is animating, to get current value while animating use `currentValue`
The current value of the progress ring, use setProgress(value:) to alter the value with the option
to animate and have a completion handler.
## Author:
Luis Padron
*/
@IBInspectable public var value: CGFloat = 0 {
@IBInspectable open var value: CGFloat = 0 {
didSet {
self.ringLayer.value = self.value
}
}

/**
The current value of the progress ring
This will return the current value of the progress ring, if the ring is animating it will be updated in real time.
If the ring is not currently animating then the value returned will be the `value` property of the ring
## Author:
Luis Padron
*/
open var currentValue: CGFloat? {
get {
if isAnimating {
return self.layer.presentation()?.value(forKey: "value") as? CGFloat
} else {
return self.value
}
}
}

/**
The max value for the progress ring. ex: 23/(100)
Used to calculate amount of progress depending on self.value and self.maxValue
Expand All @@ -89,7 +110,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var maxValue: CGFloat = 100 {
@IBInspectable open var maxValue: CGFloat = 100 {
didSet {
self.ringLayer.maxValue = self.maxValue
}
Expand All @@ -116,7 +137,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var viewStyle: Int = 1 {
@IBInspectable open var viewStyle: Int = 1 {
didSet {
self.ringLayer.viewStyle = self.viewStyle
}
Expand All @@ -131,7 +152,7 @@ import UIKit
## Author:
Luis Padron
*/
public var patternForDashes: [CGFloat] = [7.0, 7.0] {
open var patternForDashes: [CGFloat] = [7.0, 7.0] {
didSet {
self.ringLayer.patternForDashes = self.patternForDashes
}
Expand All @@ -151,7 +172,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var startAngle: CGFloat = 0 {
@IBInspectable open var startAngle: CGFloat = 0 {
didSet {
self.ringLayer.startAngle = self.startAngle
}
Expand All @@ -171,7 +192,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var endAngle: CGFloat = 360 {
@IBInspectable open var endAngle: CGFloat = 360 {
didSet {
self.ringLayer.endAngle = self.endAngle
}
Expand All @@ -188,7 +209,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var outerRingWidth: CGFloat = 10.0 {
@IBInspectable open var outerRingWidth: CGFloat = 10.0 {
didSet {
self.ringLayer.outerRingWidth = self.outerRingWidth
}
Expand All @@ -203,7 +224,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var outerRingColor: UIColor = UIColor.gray {
@IBInspectable open var outerRingColor: UIColor = UIColor.gray {
didSet {
self.ringLayer.outerRingColor = self.outerRingColor
}
Expand All @@ -223,7 +244,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var outerRingCapStyle: Int = 1 {
@IBInspectable open var outerRingCapStyle: Int = 1 {
didSet {
switch self.outerRingCapStyle{
case 1:
Expand Down Expand Up @@ -263,7 +284,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var innerRingWidth: CGFloat = 5.0 {
@IBInspectable open var innerRingWidth: CGFloat = 5.0 {
didSet {
self.ringLayer.innerRingWidth = self.innerRingWidth
}
Expand All @@ -278,7 +299,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var innerRingColor: UIColor = UIColor.blue {
@IBInspectable open var innerRingColor: UIColor = UIColor.blue {
didSet {
self.ringLayer.innerRingColor = self.innerRingColor
}
Expand All @@ -295,7 +316,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var innerRingSpacing: CGFloat = 1 {
@IBInspectable open var innerRingSpacing: CGFloat = 1 {
didSet {
self.ringLayer.innerRingSpacing = self.innerRingSpacing
}
Expand All @@ -319,7 +340,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var innerRingCapStyle: Int = 2 {
@IBInspectable open var innerRingCapStyle: Int = 2 {
didSet {
switch self.innerRingCapStyle {
case 1:
Expand Down Expand Up @@ -361,7 +382,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var shouldShowValueText: Bool = true {
@IBInspectable open var shouldShowValueText: Bool = true {
didSet {
self.ringLayer.shouldShowValueText = self.shouldShowValueText
}
Expand All @@ -377,7 +398,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var fontColor: UIColor = UIColor.black {
@IBInspectable open var fontColor: UIColor = UIColor.black {
didSet {
self.ringLayer.fontColor = self.fontColor
}
Expand All @@ -394,7 +415,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var fontSize: CGFloat = 18 {
@IBInspectable open var fontSize: CGFloat = 18 {
didSet {
self.ringLayer.fontSize = self.fontSize
}
Expand All @@ -413,7 +434,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var customFontWithName: String? {
@IBInspectable open var customFontWithName: String? {
didSet {
self.ringLayer.customFontWithName = self.customFontWithName
}
Expand All @@ -430,7 +451,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var valueIndicator: String = "%" {
@IBInspectable open var valueIndicator: String = "%" {
didSet {
self.ringLayer.valueIndicator = self.valueIndicator
}
Expand All @@ -448,7 +469,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var showFloatingPoint: Bool = false {
@IBInspectable open var showFloatingPoint: Bool = false {
didSet {
self.ringLayer.showFloatingPoint = self.showFloatingPoint
}
Expand All @@ -465,7 +486,7 @@ import UIKit
## Author:
Luis Padron
*/
@IBInspectable public var decimalPlaces: Int = 2 {
@IBInspectable open var decimalPlaces: Int = 2 {
didSet {
self.ringLayer.decimalPlaces = self.decimalPlaces
}
Expand All @@ -486,7 +507,7 @@ import UIKit
## Author:
Luis Padron
*/
public var animationStyle: String = kCAMediaTimingFunctionEaseIn {
open var animationStyle: String = kCAMediaTimingFunctionEaseIn {
didSet {
self.ringLayer.animationStyle = self.animationStyle
}
Expand All @@ -501,7 +522,7 @@ import UIKit
## Author:
Luis Padron
*/
public var isAnimating: Bool {
open var isAnimating: Bool {
get { return (self.layer.animation(forKey: "value") != nil) ? true : false }
}

Expand All @@ -510,7 +531,7 @@ import UIKit
/**
Set the ring layer to the default layer, cated as custom layer
*/
var ringLayer: UICircularProgressRingLayer {
internal var ringLayer: UICircularProgressRingLayer {
return self.layer as! UICircularProgressRingLayer
}

Expand Down Expand Up @@ -592,20 +613,22 @@ import UIKit
public typealias ProgressCompletion = (() -> Void)

/**
Sets the current value for the progress ring
Sets the current value for the progress ring, calling this method while ring is animating will cancel the previously set animation and start a new one.
- Parameter newVal: The value to be set for the progress ring
- Parameter animationDuration: The time interval duration for the animation
- Parameter completion: The completion closure block that will be called when animtion is finished (also called when animationDuration = 0), default is nil
## Important ##
Animatin duration = 0 will cause no animation to occur
Animatin duration = 0 will cause no animation to occur, and value will instantly be set
## Author:
Luis Padron
*/
public func setProgress(value: CGFloat, animationDuration: TimeInterval, completion: ProgressCompletion? = nil) {
// Only animte if duration sent is greater than zero
open func setProgress(value: CGFloat, animationDuration: TimeInterval, completion: ProgressCompletion? = nil) {
// Remove the current animation, so that new can be processed
if isAnimating { self.layer.removeAnimation(forKey: "value") }
// Only animate if duration sent is greater than zero
self.ringLayer.animated = animationDuration > 0
self.ringLayer.animationDuration = animationDuration
// Create a transaction to be notified when animation is complete
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-01-27)</p>
<p>&copy; 2017 <a class="link" href="https://luispadron.com" target="_blank" rel="external">Luis</a>. All rights reserved. (Last updated: 2017-03-02)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.2</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
Expand Down
Loading

0 comments on commit d63bacb

Please sign in to comment.