Adjusted the progress bar so that it will make it to 100%
This commit is contained in:
parent
bec1aacffc
commit
612d7d0755
@ -45,7 +45,6 @@ public final class NavigationProgressView: UIView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ====================================================================== */
|
/* ====================================================================== */
|
||||||
// MARK: - initializer
|
// MARK: - initializer
|
||||||
/* ====================================================================== */
|
/* ====================================================================== */
|
||||||
@ -119,14 +118,15 @@ public final class NavigationProgressView: UIView {
|
|||||||
// MARK: - Method
|
// MARK: - Method
|
||||||
/* ====================================================================== */
|
/* ====================================================================== */
|
||||||
|
|
||||||
internal func setProgress(_ progress: Float, animated: Bool) {
|
internal func setProgress(_ progress: Float, animated: Bool, completion: @escaping () -> Void) {
|
||||||
let duration: TimeInterval = animated ? 0.1 : 0
|
let duration: TimeInterval = animated ? 0.2 : 0
|
||||||
|
|
||||||
self.progress = progress
|
self.progress = progress
|
||||||
|
|
||||||
UIView.animate(withDuration: duration, animations: {
|
UIView.animate(withDuration: duration, animations: { self.layoutIfNeeded() }) { _ in
|
||||||
self.layoutIfNeeded()
|
completion()
|
||||||
})
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,9 +95,9 @@ public extension UINavigationController {
|
|||||||
- parameter progress: The new progress value.
|
- parameter progress: The new progress value.
|
||||||
- parameter animated: true if the change should be animated, false if the change should happen immediately.
|
- parameter animated: true if the change should be animated, false if the change should happen immediately.
|
||||||
*/
|
*/
|
||||||
func setProgress(_ progress: Float, animated: Bool) {
|
func setProgress(_ progress: Float, animated: Bool, completion: @escaping () -> Void) {
|
||||||
progressView.bar.alpha = 1
|
progressView.bar.alpha = 1
|
||||||
progressView.setProgress(progress, animated: animated)
|
progressView.setProgress(progress, animated: animated, completion: completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,26 +105,22 @@ public extension UINavigationController {
|
|||||||
*/
|
*/
|
||||||
func finishProgress() {
|
func finishProgress() {
|
||||||
progressView.bar.alpha = 1
|
progressView.bar.alpha = 1
|
||||||
progressView.setProgress(1, animated: true)
|
progressView.setProgress(1, animated: true) {
|
||||||
|
UIView.animate(withDuration: 0.5, animations: { self.progressView.bar.alpha = 0 }) { finished in
|
||||||
UIView.animate(withDuration: 0.25,
|
self.progressView.progress = 0
|
||||||
animations: {
|
}
|
||||||
self.progressView.bar.alpha = 0
|
|
||||||
}, completion: { finished in
|
|
||||||
self.progressView.progress = 0
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
While progress is changed to 0.0, the bar will fade out.
|
While progress is changed to 0.0, the bar will fade out.
|
||||||
*/
|
*/
|
||||||
func cancelProgress() {
|
func cancelProgress() {
|
||||||
progressView.setProgress(0, animated: true)
|
progressView.setProgress(0, animated: true) {
|
||||||
|
UIView.animate(withDuration: 0.5, animations: {
|
||||||
UIView.animate(withDuration: 0.25, animations: {
|
self.progressView.bar.alpha = 0
|
||||||
self.progressView.bar.alpha = 0
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAccountRefreshProgressIndicator() {
|
func updateAccountRefreshProgressIndicator() {
|
||||||
@ -137,7 +133,7 @@ public extension UINavigationController {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let percent = Float(progress.numberCompleted) / Float(progress.numberOfTasks)
|
let percent = Float(progress.numberCompleted) / Float(progress.numberOfTasks)
|
||||||
setProgress(percent, animated: true)
|
setProgress(percent, animated: true) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user