IOS-1542 UI only allows one verification at a time. IOS-1542
authorDirk Zimmermann <dz@pep.security>
Tue, 07 May 2019 16:12:52 +0200
branchIOS-1542
changeset 8514c206dd336c3f
parent 8513 091acae7b422
child 8515 b62aeaa96238
IOS-1542 UI only allows one verification at a time.
pEpForiOS/UI/Settings/Setting/AccountSettings/AccountSettingsTableViewController.swift
     1.1 --- a/pEpForiOS/UI/Settings/Setting/AccountSettings/AccountSettingsTableViewController.swift	Tue May 07 16:12:52 2019 +0200
     1.2 +++ b/pEpForiOS/UI/Settings/Setting/AccountSettings/AccountSettingsTableViewController.swift	Tue May 07 16:12:52 2019 +0200
     1.3 @@ -27,6 +27,7 @@
     1.4      @IBOutlet weak var passwordTableViewCell: UITableViewCell!
     1.5      @IBOutlet weak var oauth2TableViewCell: UITableViewCell!
     1.6      @IBOutlet weak var oauth2ActivityIndicator: UIActivityIndicatorView!
     1.7 +
     1.8      private let spinner: UIActivityIndicatorView = {
     1.9          let createe = UIActivityIndicatorView()
    1.10          createe.hidesWhenStopped = true
    1.11 @@ -48,6 +49,10 @@
    1.12       should trigger the reauthorization.
    1.13       */
    1.14      var oauth2ReauthIndexPath: IndexPath?
    1.15 +
    1.16 +    /// The last button item that triggered a verification.
    1.17 +    /// One of the UI elements that should get disabled during verification.
    1.18 +    var doneButton: UIBarButtonItem? = nil
    1.19      
    1.20       override func viewDidLoad() {
    1.21          super.viewDidLoad()
    1.22 @@ -245,7 +250,7 @@
    1.23                  password = nil
    1.24              }
    1.25  
    1.26 -            showSpinnerAndDisableUI()
    1.27 +            showSpinnerAndDisableUI(sender: sender)
    1.28              viewModel?.update(loginName: validated.loginName, name: validated.accountName,
    1.29                                password: password, imap: imap, smtp: smtp)
    1.30  
    1.31 @@ -346,8 +351,11 @@
    1.32  
    1.33  extension AccountSettingsTableViewController {
    1.34      /// Shows the spinner and disables UI parts that could lead to
    1.35 -    /// reentrant verifications.
    1.36 -    private func showSpinnerAndDisableUI() {
    1.37 +    /// launching another verification while one is already in process.
    1.38 +    private func showSpinnerAndDisableUI(sender: UIBarButtonItem) {
    1.39 +        doneButton = sender
    1.40 +        sender.isEnabled = false
    1.41 +
    1.42          spinner.center =
    1.43              CGPoint(x: tableView.frame.width / 2,
    1.44                      y:
    1.45 @@ -360,6 +368,7 @@
    1.46  
    1.47      /// Hides the spinner and enables all UI elements again.
    1.48      private func hideSpinnerAndEnableUI() {
    1.49 +        doneButton?.isEnabled = true
    1.50          tableView.isUserInteractionEnabled = true
    1.51          spinner.stopAnimating()
    1.52      }