소스 검색

tapping advanced section now shows and hides cells - adjusts button

Bastian van de Wetering 6 년 전
부모
커밋
525c780497
2개의 변경된 파일27개의 추가작업 그리고 5개의 파일을 삭제
  1. 26 4
      deltachat-ios/AccountSetupController.swift
  2. 1 1
      deltachat-ios/TextFieldCell.swift

+ 26 - 4
deltachat-ios/AccountSetupController.swift

@@ -30,11 +30,15 @@ class AccountSetupController: UITableViewController {
         return cell
         return cell
     }()
     }()
 
 
-    
+    /*
+    Advanced Cells:
+     IMAP Server, IMAP User, IMAP Port, IMAP Security, SMTP Server, SMTP User, SMTP Port, SMTP Password, SMTP Security
+    */
+
 
 
-    private lazy var basicSectionCells:[UITableViewCell] = [emailCell, passwordCell]
-    private lazy var advancedSectionCells:[UITableViewCell] = [emailCell, passwordCell,emailCell, passwordCell,emailCell, passwordCell]
 
 
+    private lazy var basicSectionCells:[UITableViewCell] = [emailCell, passwordCell]
+    private lazy var advancedSectionCells:[UITableViewCell] = [TextFieldCell(description: "IMAP Server", placeholder: MRConfig.mailServer ?? MRConfig.configuredMailServer)]
 
 
     private var advancedSectionShowing: Bool = false
     private var advancedSectionShowing: Bool = false
 
 
@@ -145,7 +149,25 @@ class AccountSetupController: UITableViewController {
     }
     }
 
 
     private func toggleAdvancedSection(button: UIButton) {
     private func toggleAdvancedSection(button: UIButton) {
-        print("Toggle")
+
+        let willShow = !self.advancedSectionShowing
+
+        // extract indexPaths from advancedCells
+        let advancedIndexPaths:[IndexPath] = advancedSectionCells.indices.map({IndexPath(row: $0, section: 1)})
+
+        //advancedSectionCells.indices.map({indexPaths.append(IndexPath(row: $0, section: 1))}
+
+        // set flag before delete/insert operation, because cellForRowAt will be triggered and uses this flag
+        self.advancedSectionShowing = willShow
+
+        button.setTitle(willShow ? "Hide":"Show", for: .normal)
+
+        if willShow {
+            tableView.insertRows(at: advancedIndexPaths, with: .fade)
+        } else {
+            tableView.deleteRows(at: advancedIndexPaths, with: .fade)
+
+        }
 
 
     }
     }
 
 

+ 1 - 1
deltachat-ios/TextFieldCell.swift

@@ -1,6 +1,6 @@
 //
 //
 //  TextFieldCell.swift
 //  TextFieldCell.swift
-//  deltachat-ios
+//  deltachat-ios< 
 //
 //
 //  Created by Friedel Ziegelmayer on 27.12.18.
 //  Created by Friedel Ziegelmayer on 27.12.18.
 //  Copyright © 2018 Jonas Reinsch. All rights reserved.
 //  Copyright © 2018 Jonas Reinsch. All rights reserved.