Browse Source

Merge pull request #309 from deltachat/move-account-edit

move account-edit to profile
cyBerta 5 years ago
parent
commit
a5c98a8dd0

+ 42 - 6
deltachat-ios/Controller/EditSettingsController.swift

@@ -2,6 +2,7 @@ import UIKit
 
 class EditSettingsController: UITableViewController {
 
+    private let dcContext: DcContext
     private var displayNameBackup: String?
     private var statusCellBackup: String?
 
@@ -9,7 +10,12 @@ class EditSettingsController: UITableViewController {
     private let section1Name = 0
     private let section1Status = 1
     private let section1RowCount = 2
-    private let sectionCount = 1
+
+    private let section2 = 1
+    private let section2AccountSettings = 0
+    private let section2RowCount = 1
+
+    private let sectionCount = 2
 
     private lazy var displayNameCell: TextFieldCell = {
         let cell = TextFieldCell(description: String.localized("pref_your_name"), placeholder: String.localized("pref_your_name"))
@@ -23,7 +29,16 @@ class EditSettingsController: UITableViewController {
         return cell
     }()
 
-    init() {
+    lazy var accountSettingsCell: UITableViewCell = {
+        let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
+        cell.textLabel?.text = String.localized("pref_password_and_account_settings")
+        cell.accessoryType = .disclosureIndicator
+        cell.accessibilityIdentifier = "accountSettingsCell"
+        return cell
+    }()
+
+    init(dcContext: DcContext) {
+        self.dcContext = dcContext
         super.init(style: .grouped)
     }
 
@@ -56,14 +71,23 @@ class EditSettingsController: UITableViewController {
     }
 
     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return section1RowCount
+        if section == section1 {
+            return section1RowCount
+        } else {
+            return section2RowCount
+        }
     }
 
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        if indexPath.section == section1 && indexPath.row == section1Name {
-            return displayNameCell
+        if indexPath.section == section1 {
+            if indexPath.row == section1Name {
+                return displayNameCell
+            } else {
+                return statusCell
+            }
+        } else {
+            return accountSettingsCell
         }
-        return statusCell
     }
 
     override func tableView(_: UITableView, titleForFooterInSection section: Int) -> String? {
@@ -73,4 +97,16 @@ class EditSettingsController: UITableViewController {
             return nil
         }
     }
+
+    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        guard let cell = tableView.cellForRow(at: indexPath) else { return }
+        if cell.accessibilityIdentifier == "accountSettingsCell" {
+            tableView.deselectRow(at: indexPath, animated: true)
+            guard let nc = navigationController else { return }
+            let accountSetupVC = AccountSetupController(dcContext: dcContext, editView: true)
+            let coordinator = AccountSetupCoordinator(dcContext: dcContext, navigationController: nc)
+            accountSetupVC.coordinator = coordinator
+            nc.pushViewController(accountSetupVC, animated: true)
+        }
+    }
 }

+ 7 - 7
deltachat-ios/Controller/SettingsController.swift

@@ -87,8 +87,13 @@ internal final class SettingsViewController: QuickTableViewController {
     }
 
     private func setTable() {
-        let subtitle = String.localized("pref_default_status_label") + ": "
-            + (DcConfig.selfstatus ?? "-")
+        let addr = (DcConfig.addr ?? "")
+        let status = (DcConfig.selfstatus ?? "-")
+        var subtitle = addr
+        if !addr.isEmpty && !status.isEmpty {
+            subtitle += ", " + String.localized("pref_default_status_label") + ": "
+        }
+        subtitle += status
 
         var appNameAndVersion = "Delta Chat"
         if let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
@@ -104,11 +109,6 @@ internal final class SettingsViewController: QuickTableViewController {
                         action: { _ in
                             self.coordinator?.showEditSettingsController()
                     }),
-                    NavigationRow(text: String.localized("pref_password_and_account_settings"),
-                        detailText: .none,
-                        action: { _ in
-                            self.coordinator?.showAccountSetupController()
-                    }),
                 ]
             ),
 

+ 1 - 9
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -173,16 +173,8 @@ class SettingsCoordinator: Coordinator {
         self.navigationController = navigationController
     }
 
-    func showAccountSetupController() {
-        let accountSetupVC = AccountSetupController(dcContext: dcContext, editView: true)
-        let coordinator = AccountSetupCoordinator(dcContext: dcContext, navigationController: navigationController)
-        childCoordinators.append(coordinator)
-        accountSetupVC.coordinator = coordinator
-        navigationController.pushViewController(accountSetupVC, animated: true)
-    }
-
     func showEditSettingsController() {
-        let editController = EditSettingsController()
+        let editController = EditSettingsController(dcContext: dcContext)
         navigationController.pushViewController(editController, animated: true)
     }