Browse Source

settings added to the main menu, cancel button added to credentials controller if started from menu

Alla Reinsch 6 years ago
parent
commit
bbf013ef78
2 changed files with 24 additions and 5 deletions
  1. 9 2
      deltachat-ios/ChatListController.swift
  2. 15 3
      deltachat-ios/CredentialsController.swift

+ 9 - 2
deltachat-ios/ChatListController.swift

@@ -103,10 +103,17 @@ actionSheet.addAction(UIAlertAction(title: "Scan QR code",
                                             handler: {a in print("Show QR code")}))
         actionSheet.addAction(UIAlertAction(title: "Contact requests",
                                             style: .default,
-                                            handler: {a in print("Contact requests")}))
+                                            handler: {a in print("Contact requests")}))*/
         actionSheet.addAction(UIAlertAction(title: "Settings",
                                             style: .default,
-                                            handler: {a in print("Settings")}))*/
+                                            handler: {a in
+                                                print("Settings")
+                                                let credentials = CredentialsController(isCancellable: true)
+                                                let nav = UINavigationController(rootViewController: credentials)
+                                                self.present(nav, animated: true, completion: nil)
+                                                
+                                                
+        }))
         actionSheet.addAction(UIAlertAction(title: "Cancel",
                                             style: .cancel,
                                             handler: {a in print("Cancel")}))

+ 15 - 3
deltachat-ios/CredentialsController.swift

@@ -165,14 +165,22 @@ class CredentialsController: UITableViewController {
     
     let cells:[UITableViewCell]
     
-    init() {
+    init(isCancellable:Bool = false) {
         cells = [emailCell, passwordCell]
 
         super.init(style: .grouped)
         doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(didPressSaveAccountButton))
         doneButton?.isEnabled = false
         advancedButton = UIBarButtonItem(title: "Advanced", style: .done, target: self, action: #selector(didPressAdvancedButton))
-        navigationItem.rightBarButtonItem = doneButton
+        
+        let cancelButton = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(didPressCancelButton))
+        
+        if isCancellable {
+            navigationItem.rightBarButtonItems = [doneButton!, cancelButton]
+        } else {
+            navigationItem.rightBarButtonItem = doneButton
+        }
+        
         navigationItem.leftBarButtonItem = advancedButton
         
         // FIXME: refactor: do not use target/action here for text field changes
@@ -199,6 +207,10 @@ class CredentialsController: UITableViewController {
         emailCell.textField.becomeFirstResponder()
     }
     
+    @objc func didPressCancelButton() {
+        dismiss(animated: true, completion: nil)
+    }
+    
     @objc func didPressSaveAccountButton() {
         let m = model
         let a = advancedMode
@@ -301,7 +313,7 @@ class CredentialsController: UITableViewController {
                 imapCellSecurity.selectionStyle = .none
                 imapCellSecurity.detailTextLabel?.text = model.imapSecurity.rawValue
                 return imapCellSecurity
-        }
+            }
         }
         if section == 2 {
             if row == 0 {