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

Commit d63bacb

Browse files
Luis PadronLuis Padron
Luis Padron
authored and
Luis Padron
committed
Version 1.3.0
- 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
1 parent 2177f82 commit d63bacb

15 files changed

+196
-94
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Version 1.3.0
2+
3+
- Add a property for accessing the current value of the progress ring while animating, closes [issue #14](https://github.com/luispadron/UICircularProgressRing/issues/14)
4+
- 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)
5+
- Fixed access levels for variables and functions, changed from `public` to `open` to allow subclassing.
6+
- Updated `docs` by running Jazzy
7+
8+
19
# Version 1.2.2
210

311
- Remove useless print statements from guards

UICircularProgressRing.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Pod::Spec.new do |s|
33

44
s.name = "UICircularProgressRing"
5-
s.version = "1.2.2"
5+
s.version = "1.3.0"
66
s.summary = "A highly customizable circular progress bar for iOS written in Swift 3"
77

88
s.description = <<-DESC

UICircularProgressRing/UICircularProgressRingView.swift

+51-28
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import UIKit
5656
## Author:
5757
Luis Padron
5858
*/
59-
public weak var delegate: UICircularProgressRingDelegate?
59+
open weak var delegate: UICircularProgressRingDelegate?
6060

6161
// MARK: Value Properties
6262

@@ -66,18 +66,39 @@ import UIKit
6666
## Important ##
6767
Default = 0
6868

69+
This cannot be used to get the value while the ring is animating, to get current value while animating use `currentValue`
70+
6971
The current value of the progress ring, use setProgress(value:) to alter the value with the option
7072
to animate and have a completion handler.
7173

7274
## Author:
7375
Luis Padron
7476
*/
75-
@IBInspectable public var value: CGFloat = 0 {
77+
@IBInspectable open var value: CGFloat = 0 {
7678
didSet {
7779
self.ringLayer.value = self.value
7880
}
7981
}
8082

83+
/**
84+
The current value of the progress ring
85+
86+
This will return the current value of the progress ring, if the ring is animating it will be updated in real time.
87+
If the ring is not currently animating then the value returned will be the `value` property of the ring
88+
89+
## Author:
90+
Luis Padron
91+
*/
92+
open var currentValue: CGFloat? {
93+
get {
94+
if isAnimating {
95+
return self.layer.presentation()?.value(forKey: "value") as? CGFloat
96+
} else {
97+
return self.value
98+
}
99+
}
100+
}
101+
81102
/**
82103
The max value for the progress ring. ex: 23/(100)
83104
Used to calculate amount of progress depending on self.value and self.maxValue
@@ -89,7 +110,7 @@ import UIKit
89110
## Author:
90111
Luis Padron
91112
*/
92-
@IBInspectable public var maxValue: CGFloat = 100 {
113+
@IBInspectable open var maxValue: CGFloat = 100 {
93114
didSet {
94115
self.ringLayer.maxValue = self.maxValue
95116
}
@@ -116,7 +137,7 @@ import UIKit
116137
## Author:
117138
Luis Padron
118139
*/
119-
@IBInspectable public var viewStyle: Int = 1 {
140+
@IBInspectable open var viewStyle: Int = 1 {
120141
didSet {
121142
self.ringLayer.viewStyle = self.viewStyle
122143
}
@@ -131,7 +152,7 @@ import UIKit
131152
## Author:
132153
Luis Padron
133154
*/
134-
public var patternForDashes: [CGFloat] = [7.0, 7.0] {
155+
open var patternForDashes: [CGFloat] = [7.0, 7.0] {
135156
didSet {
136157
self.ringLayer.patternForDashes = self.patternForDashes
137158
}
@@ -151,7 +172,7 @@ import UIKit
151172
## Author:
152173
Luis Padron
153174
*/
154-
@IBInspectable public var startAngle: CGFloat = 0 {
175+
@IBInspectable open var startAngle: CGFloat = 0 {
155176
didSet {
156177
self.ringLayer.startAngle = self.startAngle
157178
}
@@ -171,7 +192,7 @@ import UIKit
171192
## Author:
172193
Luis Padron
173194
*/
174-
@IBInspectable public var endAngle: CGFloat = 360 {
195+
@IBInspectable open var endAngle: CGFloat = 360 {
175196
didSet {
176197
self.ringLayer.endAngle = self.endAngle
177198
}
@@ -188,7 +209,7 @@ import UIKit
188209
## Author:
189210
Luis Padron
190211
*/
191-
@IBInspectable public var outerRingWidth: CGFloat = 10.0 {
212+
@IBInspectable open var outerRingWidth: CGFloat = 10.0 {
192213
didSet {
193214
self.ringLayer.outerRingWidth = self.outerRingWidth
194215
}
@@ -203,7 +224,7 @@ import UIKit
203224
## Author:
204225
Luis Padron
205226
*/
206-
@IBInspectable public var outerRingColor: UIColor = UIColor.gray {
227+
@IBInspectable open var outerRingColor: UIColor = UIColor.gray {
207228
didSet {
208229
self.ringLayer.outerRingColor = self.outerRingColor
209230
}
@@ -223,7 +244,7 @@ import UIKit
223244
## Author:
224245
Luis Padron
225246
*/
226-
@IBInspectable public var outerRingCapStyle: Int = 1 {
247+
@IBInspectable open var outerRingCapStyle: Int = 1 {
227248
didSet {
228249
switch self.outerRingCapStyle{
229250
case 1:
@@ -263,7 +284,7 @@ import UIKit
263284
## Author:
264285
Luis Padron
265286
*/
266-
@IBInspectable public var innerRingWidth: CGFloat = 5.0 {
287+
@IBInspectable open var innerRingWidth: CGFloat = 5.0 {
267288
didSet {
268289
self.ringLayer.innerRingWidth = self.innerRingWidth
269290
}
@@ -278,7 +299,7 @@ import UIKit
278299
## Author:
279300
Luis Padron
280301
*/
281-
@IBInspectable public var innerRingColor: UIColor = UIColor.blue {
302+
@IBInspectable open var innerRingColor: UIColor = UIColor.blue {
282303
didSet {
283304
self.ringLayer.innerRingColor = self.innerRingColor
284305
}
@@ -295,7 +316,7 @@ import UIKit
295316
## Author:
296317
Luis Padron
297318
*/
298-
@IBInspectable public var innerRingSpacing: CGFloat = 1 {
319+
@IBInspectable open var innerRingSpacing: CGFloat = 1 {
299320
didSet {
300321
self.ringLayer.innerRingSpacing = self.innerRingSpacing
301322
}
@@ -319,7 +340,7 @@ import UIKit
319340
## Author:
320341
Luis Padron
321342
*/
322-
@IBInspectable public var innerRingCapStyle: Int = 2 {
343+
@IBInspectable open var innerRingCapStyle: Int = 2 {
323344
didSet {
324345
switch self.innerRingCapStyle {
325346
case 1:
@@ -361,7 +382,7 @@ import UIKit
361382
## Author:
362383
Luis Padron
363384
*/
364-
@IBInspectable public var shouldShowValueText: Bool = true {
385+
@IBInspectable open var shouldShowValueText: Bool = true {
365386
didSet {
366387
self.ringLayer.shouldShowValueText = self.shouldShowValueText
367388
}
@@ -377,7 +398,7 @@ import UIKit
377398
## Author:
378399
Luis Padron
379400
*/
380-
@IBInspectable public var fontColor: UIColor = UIColor.black {
401+
@IBInspectable open var fontColor: UIColor = UIColor.black {
381402
didSet {
382403
self.ringLayer.fontColor = self.fontColor
383404
}
@@ -394,7 +415,7 @@ import UIKit
394415
## Author:
395416
Luis Padron
396417
*/
397-
@IBInspectable public var fontSize: CGFloat = 18 {
418+
@IBInspectable open var fontSize: CGFloat = 18 {
398419
didSet {
399420
self.ringLayer.fontSize = self.fontSize
400421
}
@@ -413,7 +434,7 @@ import UIKit
413434
## Author:
414435
Luis Padron
415436
*/
416-
@IBInspectable public var customFontWithName: String? {
437+
@IBInspectable open var customFontWithName: String? {
417438
didSet {
418439
self.ringLayer.customFontWithName = self.customFontWithName
419440
}
@@ -430,7 +451,7 @@ import UIKit
430451
## Author:
431452
Luis Padron
432453
*/
433-
@IBInspectable public var valueIndicator: String = "%" {
454+
@IBInspectable open var valueIndicator: String = "%" {
434455
didSet {
435456
self.ringLayer.valueIndicator = self.valueIndicator
436457
}
@@ -448,7 +469,7 @@ import UIKit
448469
## Author:
449470
Luis Padron
450471
*/
451-
@IBInspectable public var showFloatingPoint: Bool = false {
472+
@IBInspectable open var showFloatingPoint: Bool = false {
452473
didSet {
453474
self.ringLayer.showFloatingPoint = self.showFloatingPoint
454475
}
@@ -465,7 +486,7 @@ import UIKit
465486
## Author:
466487
Luis Padron
467488
*/
468-
@IBInspectable public var decimalPlaces: Int = 2 {
489+
@IBInspectable open var decimalPlaces: Int = 2 {
469490
didSet {
470491
self.ringLayer.decimalPlaces = self.decimalPlaces
471492
}
@@ -486,7 +507,7 @@ import UIKit
486507
## Author:
487508
Luis Padron
488509
*/
489-
public var animationStyle: String = kCAMediaTimingFunctionEaseIn {
510+
open var animationStyle: String = kCAMediaTimingFunctionEaseIn {
490511
didSet {
491512
self.ringLayer.animationStyle = self.animationStyle
492513
}
@@ -501,7 +522,7 @@ import UIKit
501522
## Author:
502523
Luis Padron
503524
*/
504-
public var isAnimating: Bool {
525+
open var isAnimating: Bool {
505526
get { return (self.layer.animation(forKey: "value") != nil) ? true : false }
506527
}
507528

@@ -510,7 +531,7 @@ import UIKit
510531
/**
511532
Set the ring layer to the default layer, cated as custom layer
512533
*/
513-
var ringLayer: UICircularProgressRingLayer {
534+
internal var ringLayer: UICircularProgressRingLayer {
514535
return self.layer as! UICircularProgressRingLayer
515536
}
516537

@@ -592,20 +613,22 @@ import UIKit
592613
public typealias ProgressCompletion = (() -> Void)
593614

594615
/**
595-
Sets the current value for the progress ring
616+
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.
596617

597618
- Parameter newVal: The value to be set for the progress ring
598619
- Parameter animationDuration: The time interval duration for the animation
599620
- Parameter completion: The completion closure block that will be called when animtion is finished (also called when animationDuration = 0), default is nil
600621

601622
## Important ##
602-
Animatin duration = 0 will cause no animation to occur
623+
Animatin duration = 0 will cause no animation to occur, and value will instantly be set
603624

604625
## Author:
605626
Luis Padron
606627
*/
607-
public func setProgress(value: CGFloat, animationDuration: TimeInterval, completion: ProgressCompletion? = nil) {
608-
// Only animte if duration sent is greater than zero
628+
open func setProgress(value: CGFloat, animationDuration: TimeInterval, completion: ProgressCompletion? = nil) {
629+
// Remove the current animation, so that new can be processed
630+
if isAnimating { self.layer.removeAnimation(forKey: "value") }
631+
// Only animate if duration sent is greater than zero
609632
self.ringLayer.animated = animationDuration > 0
610633
self.ringLayer.animationDuration = animationDuration
611634
// Create a transaction to be notified when animation is complete

docs/Classes.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h4>Declaration</h4>
123123
</article>
124124
</div>
125125
<section class="footer">
126-
<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>
126+
<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>
127127
<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>
128128
</section>
129129
</body>

0 commit comments

Comments
 (0)