Quellcode durchsuchen

add contact profile screen

Alla Reinsch vor 7 Jahren
Ursprung
Commit
92535ef948

+ 4 - 0
deltachat-ios.xcodeproj/project.pbxproj

@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		7092474120B3869500AF8799 /* ContactProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7092474020B3869500AF8799 /* ContactProfileViewController.swift */; };
 		70A4C09B208007B700D577B3 /* mrmailbox_receive_imf.c in Sources */ = {isa = PBXBuildFile; fileRef = 70A4C089208007B500D577B3 /* mrmailbox_receive_imf.c */; };
 		70A4C09C208007B700D577B3 /* mrmailbox_securejoin.c in Sources */ = {isa = PBXBuildFile; fileRef = 70A4C08B208007B500D577B3 /* mrmailbox_securejoin.c */; };
 		70A4C09D208007B700D577B3 /* mrarray.c in Sources */ = {isa = PBXBuildFile; fileRef = 70A4C08C208007B600D577B3 /* mrarray.c */; };
@@ -105,6 +106,7 @@
 
 /* Begin PBXFileReference section */
 		6241BE1534A653E79AD5D01D /* Pods_deltachat_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_deltachat_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		7092474020B3869500AF8799 /* ContactProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactProfileViewController.swift; sourceTree = "<group>"; };
 		70A4C081208007B400D577B3 /* mrarray-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mrarray-private.h"; sourceTree = "<group>"; };
 		70A4C082208007B400D577B3 /* mrchatlist-private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "mrchatlist-private.h"; sourceTree = "<group>"; };
 		70A4C083208007B400D577B3 /* mrevent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mrevent.h; sourceTree = "<group>"; };
@@ -380,6 +382,7 @@
 				70B8882D2091B8550074812E /* ContactCell.swift */,
 				AE0D26FC1FB1FE88002FAFCE /* ChatListController.swift */,
 				7A0052A01FBC50C40048C3BF /* CredentialsController.swift */,
+				7092474020B3869500AF8799 /* ContactProfileViewController.swift */,
 				7A0052C71FBE6CB40048C3BF /* NewContactController.swift */,
 				AEACE2DC1FB323CA00DCDD78 /* ChatViewController.swift */,
 				7AE0A5481FC42F65005ECB4B /* NewChatViewController.swift */,
@@ -706,6 +709,7 @@
 				7A9FB54A1FB08557001FEA36 /* mrmimefactory.c in Sources */,
 				7A451D941FB1B1DB00177250 /* wrapper.c in Sources */,
 				7A9FB54D1FB08557001FEA36 /* mrosnative.c in Sources */,
+				7092474120B3869500AF8799 /* ContactProfileViewController.swift in Sources */,
 				7A9FB5471FB08557001FEA36 /* mrmailbox_imex.c in Sources */,
 				7A79236A1FB0A2C800BC2DE5 /* compress.c in Sources */,
 				7A451DB01FB1F84900177250 /* AppCoordinator.swift in Sources */,

+ 93 - 0
deltachat-ios/ContactProfileViewController.swift

@@ -0,0 +1,93 @@
+//
+//  TableViewController.swift
+//  deltachat-ios
+//
+//  Created by Alla Reinsch on 22.05.18.
+//  Copyright © 2018 Jonas Reinsch. All rights reserved.
+//
+
+import UIKit
+
+class ContactProfileViewController: UITableViewController {
+    let contactId:Int
+    var name:String {
+        return MRContact(id: contactId).name
+    }
+    var email:String {
+        return MRContact(id: contactId).email
+    }
+    
+    init(contactId: Int) {
+        self.contactId = contactId
+        super.init(style: .plain)
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        navigationController?.navigationBar.prefersLargeTitles = false
+        tableView.reloadData()
+    }
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+
+        // Uncomment the following line to preserve selection between presentations
+        // self.clearsSelectionOnViewWillAppear = false
+
+        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
+        // self.navigationItem.rightBarButtonItem = self.editButtonItem
+    }
+
+    override func didReceiveMemoryWarning() {
+        super.didReceiveMemoryWarning()
+        // Dispose of any resources that can be recreated.
+    }
+
+    // MARK: - Table view data source
+
+    override func numberOfSections(in tableView: UITableView) -> Int {
+        return 1
+    }
+
+    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return 5
+    }
+
+    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let row = indexPath.row
+        if row == 0 {
+            let contactCell = ContactCell()
+            contactCell.nameLabel.text = name
+            contactCell.emailLabel.text = email
+            contactCell.initialsLabel.text = Utils.getInitials(inputName: name)
+            return contactCell
+        }
+        let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
+
+        if row == 1 {
+            cell.textLabel?.text = "Settings"
+        }
+        if row == 2 {
+            cell.textLabel?.text = "Edit name"
+        }
+        if row == 3 {
+            cell.textLabel?.text = "Encryption"
+        }
+        if row == 4 {
+            cell.textLabel?.text = "New chat"
+        }
+        return cell
+    }
+    
+    
+    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        let row = indexPath.row
+        if row == 2 {
+            let newContactController = NewContactController(contactIdForUpdate: contactId)
+            navigationController?.pushViewController(newContactController, animated: true)
+        }
+    }
+}

+ 4 - 2
deltachat-ios/NewChatViewController.swift

@@ -130,8 +130,10 @@ class NewChatViewController: UITableViewController {
         if row > 1 {
             let contactIndex = row - 2
             let contactId = contactIds[contactIndex]
-            let newContactController = NewContactController(contactIdForUpdate: contactId)
-            navigationController?.pushViewController(newContactController, animated: true)
+            // let newContactController = NewContactController(contactIdForUpdate: contactId)
+            // navigationController?.pushViewController(newContactController, animated: true)
+            let contactProfileController = ContactProfileViewController(contactId: contactId)
+            navigationController?.pushViewController(contactProfileController, animated: true)
         }
     }
 

+ 4 - 0
deltachat-ios/NewContactController.swift

@@ -51,6 +51,10 @@ class NewContactController: UITableViewController {
         }
     }
     
+    override func viewWillAppear(_ animated: Bool) {
+        navigationController?.setNavigationBarHidden(false, animated: false)
+    }
+    
     // for creating a new contact
     init() {
         cells = [emailCell, nameCell]