فهرست منبع

use the same color for a certain contact both in contact list and contact profile

Alla Reinsch 7 سال پیش
والد
کامیت
815a4a34a1
3فایلهای تغییر یافته به همراه12 افزوده شده و 3 حذف شده
  1. 4 1
      deltachat-ios/ContactProfileViewController.swift
  2. 3 2
      deltachat-ios/NewChatViewController.swift
  3. 5 0
      deltachat-ios/Utils.swift

+ 4 - 1
deltachat-ios/ContactProfileViewController.swift

@@ -10,6 +10,7 @@ import UIKit
 
 class ContactProfileViewController: UITableViewController {
     let contactId:Int
+    let contactColor:UIColor
     var name:String {
         return MRContact(id: contactId).name
     }
@@ -17,8 +18,9 @@ class ContactProfileViewController: UITableViewController {
         return MRContact(id: contactId).email
     }
     
-    init(contactId: Int) {
+    init(contactId: Int, contactColor: UIColor) {
         self.contactId = contactId
+        self.contactColor = contactColor
         super.init(style: .plain)
     }
     
@@ -64,6 +66,7 @@ class ContactProfileViewController: UITableViewController {
             contactCell.nameLabel.text = name
             contactCell.emailLabel.text = email
             contactCell.initialsLabel.text = Utils.getInitials(inputName: name)
+            contactCell.setColor(self.contactColor)
             return contactCell
         }
         let cell = UITableViewCell(style: .default, reuseIdentifier: nil)

+ 3 - 2
deltachat-ios/NewChatViewController.swift

@@ -96,7 +96,7 @@ class NewChatViewController: UITableViewController {
         cell.nameLabel.text = contact.name
         cell.emailLabel.text = contact.email
         cell.initialsLabel.text = Utils.getInitials(inputName: contact.name)
-        let contactColor = Utils.color(row: contactRow, colors: Constants.chatColors)
+        let contactColor = Utils.contactColor(row: contactRow)
         cell.setColor(contactColor)
         
         cell.accessoryType = .detailDisclosureButton
@@ -132,7 +132,8 @@ class NewChatViewController: UITableViewController {
             let contactId = contactIds[contactIndex]
             // let newContactController = NewContactController(contactIdForUpdate: contactId)
             // navigationController?.pushViewController(newContactController, animated: true)
-            let contactProfileController = ContactProfileViewController(contactId: contactId)
+            let contactColor = Utils.contactColor(row: contactIndex)
+            let contactProfileController = ContactProfileViewController(contactId: contactId, contactColor: contactColor)
             navigationController?.pushViewController(contactProfileController, animated: true)
         }
     }

+ 5 - 0
deltachat-ios/Utils.swift

@@ -19,6 +19,11 @@ struct Utils {
         return colors[index]
     }
     
+    static func contactColor(row: Int) -> UIColor {
+        let contactColor = Utils.color(row: row, colors: Constants.chatColors)
+        return contactColor
+    }
+    
     static func getContactIds() -> [Int] {
         let c_contacts = mrmailbox_get_contacts(mailboxPointer, 0, nil)
         return Utils.copyAndFreeArray(inputArray: c_contacts)