Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Added a animate for a while feature. #15

Open
wants to merge 1 commit into
base: dev
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
3 changes: 2 additions & 1 deletion LinearProgressBarDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ViewController: UIViewController {

prepareNavigationController()

showProgressBar()
let view = showProgressBar(5)

}
}

Expand Down
7 changes: 7 additions & 0 deletions Sources/LinearProgressBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ open class LinearProgressBar: UIView {
completion?()
}

open func animateForAWhile(_ duration: TimeInterval) {
startAnimating()
DispatchQueue.main.asyncAfter(deadline: .now() + duration) {
self.stopAnimating()
}
}

// MARK: - Private

private func applyProgressAnimations() {
Expand Down
17 changes: 17 additions & 0 deletions Sources/ProgressBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import UIKit
return ProgressBar.showProgressBar(self.view)
}

@discardableResult
func showProgressBar(_ duration: TimeInterval) -> UIView {
ProgressBar.showProgressBar(duration: duration, self.view)
}

func hideProgressBar() {
ProgressBar.removeAllProgressBars(self.view)
}
Expand Down Expand Up @@ -79,4 +84,16 @@ open class ProgressBar: NSObject {
}
}
}

open class func showProgressBar(duration: TimeInterval,_ parentView: UIView) -> UIView {
let progressBar = LinearProgressBar()
progressBar.tag = progressBarViewTag

parentView.addSubview(progressBar)

Layout.toTop(progressBar)
progressBar.animateForAWhile(duration)

return progressBar
}
}