[Delta Sync] Displays activity indicator when signing-in

Without an indicator it can feel like the app has froze, when really it’s just preparing to sync.
This commit is contained in:
Riley Testut 2023-07-07 14:54:25 -05:00
parent 19fb333a67
commit 043fb923ae

View File

@ -32,6 +32,7 @@ extension SyncingServicesViewController
class SyncingServicesViewController: UITableViewController
{
@IBOutlet private var syncingEnabledSwitch: UISwitch!
private var activityIndicatorView: UIActivityIndicatorView!
private var selectedSyncingService = Settings.syncingService
@ -39,6 +40,12 @@ class SyncingServicesViewController: UITableViewController
{
super.viewDidLoad()
self.activityIndicatorView = UIActivityIndicatorView(style: .medium)
self.activityIndicatorView.hidesWhenStopped = true
let barButtonItem = UIBarButtonItem(customView: self.activityIndicatorView)
self.navigationItem.rightBarButtonItem = barButtonItem
self.syncingEnabledSwitch.onTintColor = .deltaPurple
self.syncingEnabledSwitch.isOn = (self.selectedSyncingService != nil)
}
@ -215,6 +222,8 @@ extension SyncingServicesViewController
}
else
{
self.activityIndicatorView.startAnimating()
SyncManager.shared.authenticate(presentingViewController: self) { (result) in
DispatchQueue.main.async {
do
@ -233,6 +242,8 @@ extension SyncingServicesViewController
let alertController = UIAlertController(title: NSLocalizedString("Failed to Sign In", comment: ""), error: error)
self.present(alertController, animated: true, completion: nil)
}
self.activityIndicatorView.stopAnimating()
}
}
}