Quellcode durchsuchen

showing spinner again right before alert disappear

nayooti vor 5 Jahren
Ursprung
Commit
22a386f2a8

+ 11 - 5
deltachat-ios/Controller/WelcomeViewController.swift

@@ -133,17 +133,19 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
         let success = dcContext.configureAccountFromQR(qrCode: code)
         scannedQrCode = nil
         if success {
-            if let loginCompletion = self.onProgressSuccess {
-                addProgressAlertListener(onSuccess: loginCompletion)
-                showProgressAlert(title: String.localized("login_header"))
-                activateSpinner(false)
-            }
+            addProgressAlertListener(onSuccess: handleLoginSuccess)
+            showProgressAlert(title: String.localized("login_header"))
+            activateSpinner(false)
             dcContext.configure()
         } else {
             accountCreationErrorAlert()
         }
     }
 
+    private func handleLoginSuccess() {
+        onProgressSuccess?()
+    }
+
     private func accountCreationErrorAlert() {
         func handleRepeat() {
             showQRReader(completion: { [unowned self] in
@@ -172,6 +174,10 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
         alert.addAction(repeatAction)
         present(alert, animated: true)
     }
+
+    func progressAlertWillDismiss() {
+        activateSpinner(true)
+    }
 }
 
 extension WelcomeViewController: QrCodeReaderDelegate {

+ 7 - 1
deltachat-ios/Handler/ProgressAlertHandler.swift

@@ -4,12 +4,12 @@ import DcCore
 protocol ProgressAlertHandler: UIViewController {
     var progressAlert: UIAlertController { get }
     var configureProgressObserver: Any? { get set }
-    var onProgressSuccess: VoidFunction? { get set }
     func showProgressAlert(title: String)
     func updateProgressAlertValue(value: Int?)
     func updateProgressAlert(error: String?)
     func updateProgressAlertSuccess(completion: VoidFunction?)
     func addProgressAlertListener(onSuccess: @escaping VoidFunction)
+    func progressAlertWillDismiss()
 }
 
 extension ProgressAlertHandler {
@@ -38,6 +38,8 @@ extension ProgressAlertHandler {
 
     func updateProgressAlertSuccess(completion onComplete: VoidFunction?) {
         updateProgressAlertValue(value: 1000)
+        progressAlertWillDismiss()
+        // delay so the user has time to read the success message
         DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
             self.progressAlert.dismiss(animated: true) {
                 onComplete?()
@@ -63,5 +65,9 @@ extension ProgressAlertHandler {
             }
         }
     }
+
+    func progressAlertWillDismiss() {
+        // can be overwritten if needed
+    }
 }