Displays progress when downloading/refreshing apps

Refactors download/refresh steps into separate Operation subclasses
This commit is contained in:
Riley Testut
2019-06-10 15:03:47 -07:00
parent 4f372f959a
commit a932e0759e
19 changed files with 1330 additions and 962 deletions

View File

@@ -124,7 +124,11 @@ private extension AppDetailViewController
sender.isIndicatingActivity = true
AppManager.shared.install(self.app, presentingViewController: self) { (result) in
let progressView = UIProgressView(progressViewStyle: .bar)
progressView.translatesAutoresizingMaskIntoConstraints = false
progressView.progress = 0.0
let progress = AppManager.shared.install(self.app, presentingViewController: self) { (result) in
do
{
let installedApp = try result.get()
@@ -138,7 +142,7 @@ private extension AppDetailViewController
toastView.show(in: self.navigationController!.view, duration: 2)
}
}
catch AppManager.AppError.authentication(AuthenticationOperation.Error.cancelled)
catch OperationError.cancelled
{
// Ignore
}
@@ -150,12 +154,28 @@ private extension AppDetailViewController
toastView.show(in: self.navigationController!.view, duration: 2)
}
}
DispatchQueue.main.async {
UIView.animate(withDuration: 0.4, animations: {
progressView.alpha = 0.0
}) { _ in
progressView.removeFromSuperview()
}
sender.isIndicatingActivity = false
self.update()
}
}
progressView.observedProgress = progress
if let navigationBar = self.navigationController?.navigationBar
{
navigationBar.addSubview(progressView)
NSLayoutConstraint.activate([progressView.widthAnchor.constraint(equalTo: navigationBar.widthAnchor),
progressView.bottomAnchor.constraint(equalTo: navigationBar.bottomAnchor)])
}
}
}