Răsfoiți Sursa

email + pw cell content is refreshed everytime the account setup controller is shown

nayooti 5 ani în urmă
părinte
comite
03b48afb6e

+ 9 - 4
deltachat-ios/Controller/AccountSetupController.swift

@@ -91,7 +91,6 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         cell.tag = tagEmailCell
         cell.tag = tagEmailCell
         cell.textField.addTarget(self, action: #selector(emailCellEdited), for: .editingChanged)
         cell.textField.addTarget(self, action: #selector(emailCellEdited), for: .editingChanged)
         cell.textField.tag = tagTextFieldEmail // will be used to eventually show oAuth-Dialogue when pressing return key
         cell.textField.tag = tagTextFieldEmail // will be used to eventually show oAuth-Dialogue when pressing return key
-        cell.setText(text: dcContext.addr ?? nil)
         cell.textField.delegate = self
         cell.textField.delegate = self
         cell.textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
         cell.textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
         return cell
         return cell
@@ -102,7 +101,6 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         cell.tag = tagPasswordCell
         cell.tag = tagPasswordCell
         cell.textField.tag = tagTextFieldPassword  // will be used to eventually show oAuth-Dialogue when selecting
         cell.textField.tag = tagTextFieldPassword  // will be used to eventually show oAuth-Dialogue when selecting
         cell.textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
         cell.textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
-        cell.setText(text: dcContext.mailPw ?? nil)
         cell.textField.delegate = self
         cell.textField.delegate = self
         return cell
         return cell
     }()
     }()
@@ -370,7 +368,9 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
     override func viewWillAppear(_ animated: Bool) {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         super.viewWillAppear(animated)
         initSelectionCells()
         initSelectionCells()
+        updateCellData()
         handleLoginButton()
         handleLoginButton()
+
     }
     }
 
 
     override func viewDidAppear(_ animated: Bool) {
     override func viewDidAppear(_ animated: Bool) {
@@ -502,6 +502,12 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
         }
         }
     }
     }
 
 
+    // MARK: - updates
+    private func updateCellData() {
+        emailCell.setText(text: dcContext.addr ?? nil)
+        passwordCell.setText(text: dcContext.mailPw ?? nil)
+    }
+
     // MARK: - actions
     // MARK: - actions
     private func toggleAdvancedSection() {
     private func toggleAdvancedSection() {
         let willShow = !advancedSectionShowing
         let willShow = !advancedSectionShowing
@@ -787,7 +793,6 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
             DatabaseHelper().clearAccountData()
             DatabaseHelper().clearAccountData()
             appDelegate.open()
             appDelegate.open()
             appDelegate.start()
             appDelegate.start()
-
             appDelegate.appCoordinator.presentWelcomeController()
             appDelegate.appCoordinator.presentWelcomeController()
         }))
         }))
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel))
         alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel))
@@ -851,7 +856,7 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
 
 
 }
 }
 
 
-// MARK: -
+// MARK: - UITextFieldDelegate
 extension AccountSetupController: UITextFieldDelegate {
 extension AccountSetupController: UITextFieldDelegate {
     func textFieldShouldReturn(_ textField: UITextField) -> Bool {
     func textFieldShouldReturn(_ textField: UITextField) -> Bool {
         let currentTag = textField.tag
         let currentTag = textField.tag

+ 1 - 1
deltachat-ios/Controller/WelcomeViewController.swift

@@ -19,7 +19,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
         let view = WelcomeContentView()
         let view = WelcomeContentView()
         view.onLogin = {
         view.onLogin = {
             [unowned self] in
             [unowned self] in
-            self.coordinator?.showLogin()
+            self.coordinator?.presentLogin()
         }
         }
         view.onScanQRCode = {
         view.onScanQRCode = {
             [unowned self] in
             [unowned self] in

+ 2 - 2
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -157,7 +157,7 @@ class AppCoordinator: NSObject, Coordinator {
 // MARK: - WelcomeCoordinator
 // MARK: - WelcomeCoordinator
 extension AppCoordinator: WelcomeCoordinator {
 extension AppCoordinator: WelcomeCoordinator {
 
 
-    func showLogin() {
+    func presentLogin() {
         // add cancel button item to accountSetupController
         // add cancel button item to accountSetupController
         if let nav = loginController as? UINavigationController, let loginController = nav.topViewController as? AccountSetupController {
         if let nav = loginController as? UINavigationController, let loginController = nav.topViewController as? AccountSetupController {
             loginController.navigationItem.leftBarButtonItem = UIBarButtonItem(
             loginController.navigationItem.leftBarButtonItem = UIBarButtonItem(
@@ -893,7 +893,7 @@ protocol EditContactCoordinatorProtocol: class {
 }
 }
 
 
 protocol WelcomeCoordinator: class {
 protocol WelcomeCoordinator: class {
-    func showLogin()
+    func presentLogin()
     func handleLoginSuccess()
     func handleLoginSuccess()
     func handleQRAccountCreationSuccess()
     func handleQRAccountCreationSuccess()
 }
 }