show transfer progress

This commit is contained in:
Bob Sun 2017-01-23 17:36:10 +08:00
parent 1b0f8fcb05
commit a4b26b3bd3
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
3 changed files with 36 additions and 12 deletions

View file

@ -24,19 +24,29 @@ class SettingsTableViewController: UITableViewController {
Defaults[.gitRepositoryURL] = URL(string: controller.gitRepositoryURLTextField.text!)
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.show(withStatus: "Cloning Remote Repository")
SVProgressHUD.show(withStatus: "Prepare Repository")
//SVProgressHUD.showProgress(0.0, status: "Clone Remote Repository")
DispatchQueue.global(qos: .userInitiated).async {
let ret = PasswordStore.shared.cloneRepository(remoteRepoURL: Defaults[.gitRepositoryURL]!)
let ret = PasswordStore.shared.cloneRepository(remoteRepoURL: Defaults[.gitRepositoryURL]!,
transferProgressBlock:{ (git_transfer_progress, stop) in
DispatchQueue.main.async {
SVProgressHUD.showProgress(Float(git_transfer_progress.pointee.received_objects)/Float(git_transfer_progress.pointee.total_objects), status: "Clone Remote Repository")
}
},
checkoutProgressBlock: { (path, completedSteps, totalSteps) in
DispatchQueue.main.async {
SVProgressHUD.showProgress(Float(completedSteps)/Float(totalSteps), status: "Checkout Master Branch")
}
})
DispatchQueue.main.async {
if ret {
SVProgressHUD.dismiss()
SVProgressHUD.setMaximumDismissTimeInterval(1)
SVProgressHUD.showSuccess(withStatus: "Success")
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
SVProgressHUD.showSuccess(withStatus: "Done")
SVProgressHUD.dismiss(withDelay: 1)
NotificationCenter.default.post(Notification(name: Notification.Name("passwordUpdated")))
} else {
SVProgressHUD.showError(withStatus: "Error")
SVProgressHUD.showError(withStatus: "Error")
}
}
}