Pārlūkot izejas kodu

preparation for progress bar, redisplay credentials screen upon failed configuration

Alla Reinsch 6 gadi atpakaļ
vecāks
revīzija
a2ddb23dfb

+ 8 - 4
deltachat-ios/AppCoordinator.swift

@@ -29,13 +29,17 @@ class AppCoordinator: Coordinator {
 //            let password = "foobar"
 //            initCore(email: email, password: password)
             
-            let credentialsController = CredentialsController()
-            let credentialsNav = UINavigationController(rootViewController: credentialsController)
-
-            baseController.present(credentialsNav, animated: false, completion: nil)
+            displayCredentialsController()
         }
     }
     
+    func displayCredentialsController() {
+        let credentialsController = CredentialsController()
+        let credentialsNav = UINavigationController(rootViewController: credentialsController)
+        
+        baseController.present(credentialsNav, animated: false, completion: nil)
+    }
+    
     func setupInnerViewControllers() {
 
         let chatViewController = ChatListController()

+ 10 - 1
deltachat-ios/AppDelegate.swift

@@ -43,7 +43,16 @@ public func callbackSwift(event: CInt, data1: CUnsignedLong, data2: CUnsignedLon
     // - 1 when offline
     case DC_EVENT_CONFIGURE_PROGRESS:
         DispatchQueue.main.async {
-            print(data1) // progress in promille, 0 - error, 1000 - completed
+            // progress in promille, 0 - error, 1000 - completed
+            let progressInPromille = Float(data1)
+            let progress = progressInPromille / 1000
+            
+            if data1 == 1000 {
+                AppDelegate.appCoordinator.setupInnerViewControllers()
+            }
+            if data1 == 0 {
+                AppDelegate.appCoordinator.displayCredentialsController()
+            }
         }
         return nil
     case DC_EVENT_IS_OFFLINE:

+ 0 - 1
deltachat-ios/CredentialsController.swift

@@ -139,7 +139,6 @@ class CredentialsController: UITableViewController {
     @objc func saveAccountButtonPressed() {
         dismiss(animated: true) {
             initCore(withCredentials: true, email: self.model.email, password: self.model.password)
-            AppDelegate.appCoordinator.setupInnerViewControllers()
         }
     }