Эх сурвалжийг харах

avatar now updated for contact cell on search

nayooti 5 жил өмнө
parent
commit
107150719e

+ 2 - 2
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -186,8 +186,8 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
                 if let contactCell = cell as? AvatarTextCell {
                     let contact = groupMembers[row - sectionMembersStaticRowCount]
                     let displayName = contact.displayName
-                    contactCell.nameLabel.text = displayName
-                    contactCell.emailLabel.text = contact.email
+                    contactCell.titleLabel.text = displayName
+                    contactCell.subtitleLabel.text = contact.email
                     contactCell.avatar.setName(displayName)
                     contactCell.avatar.setColor(contact.color)
                     if let profileImage = contact.profileImage {

+ 8 - 8
deltachat-ios/Controller/GroupMembersViewController.swift

@@ -420,11 +420,11 @@ class GroupMembersViewController: UITableViewController, UISearchResultsUpdating
         let contact = contactWithHighlight.contact
         let displayName = contact.displayName
 
-        let emailLabelFontSize = cell.emailLabel.font.pointSize
-        let nameLabelFontSize = cell.nameLabel.font.pointSize
+        let emailLabelFontSize = cell.subtitleLabel.font.pointSize
+        let nameLabelFontSize = cell.titleLabel.font.pointSize
 
-        cell.nameLabel.text = displayName
-        cell.emailLabel.text = contact.email
+        cell.titleLabel.text = displayName
+        cell.subtitleLabel.text = contact.email
         cell.avatar.setName(displayName)
         cell.avatar.setColor(contact.color)
         if let profileImage = contact.profileImage {
@@ -434,15 +434,15 @@ class GroupMembersViewController: UITableViewController, UISearchResultsUpdating
 
         if let emailHighlightedIndexes = contactWithHighlight.indexesToHighlight.filter({ $0.contactDetail == .EMAIL }).first {
             // gets here when contact is a result of current search -> highlights relevant indexes
-            cell.emailLabel.attributedText = contact.email.boldAt(indexes: emailHighlightedIndexes.indexes, fontSize: emailLabelFontSize)
+            cell.subtitleLabel.attributedText = contact.email.boldAt(indexes: emailHighlightedIndexes.indexes, fontSize: emailLabelFontSize)
         } else {
-            cell.emailLabel.attributedText = contact.email.boldAt(indexes: [], fontSize: emailLabelFontSize)
+            cell.subtitleLabel.attributedText = contact.email.boldAt(indexes: [], fontSize: emailLabelFontSize)
         }
 
         if let nameHighlightedIndexes = contactWithHighlight.indexesToHighlight.filter({ $0.contactDetail == .NAME }).first {
-            cell.nameLabel.attributedText = displayName.boldAt(indexes: nameHighlightedIndexes.indexes, fontSize: nameLabelFontSize)
+            cell.titleLabel.attributedText = displayName.boldAt(indexes: nameHighlightedIndexes.indexes, fontSize: nameLabelFontSize)
         } else {
-            cell.nameLabel.attributedText = displayName.boldAt(indexes: [], fontSize: nameLabelFontSize)
+            cell.titleLabel.attributedText = displayName.boldAt(indexes: [], fontSize: nameLabelFontSize)
         }
     }
 

+ 8 - 8
deltachat-ios/Controller/NewChatViewController.swift

@@ -322,11 +322,11 @@ class NewChatViewController: UITableViewController {
         let contact = contactWithHighlight.contact
         let displayName = contact.displayName
 
-        let emailLabelFontSize = cell.emailLabel.font.pointSize
-        let nameLabelFontSize = cell.nameLabel.font.pointSize
+        let emailLabelFontSize = cell.subtitleLabel.font.pointSize
+        let nameLabelFontSize = cell.titleLabel.font.pointSize
 
-        cell.nameLabel.text = displayName
-        cell.emailLabel.text = contact.email
+        cell.titleLabel.text = displayName
+        cell.subtitleLabel.text = contact.email
         cell.avatar.setName(displayName)
         cell.avatar.setColor(contact.color)
         if let profileImage = contact.profileImage {
@@ -336,15 +336,15 @@ class NewChatViewController: UITableViewController {
 
         if let emailHighlightedIndexes = contactWithHighlight.indexesToHighlight.filter({ $0.contactDetail == .EMAIL }).first {
             // gets here when contact is a result of current search -> highlights relevant indexes
-            cell.emailLabel.attributedText = contact.email.boldAt(indexes: emailHighlightedIndexes.indexes, fontSize: emailLabelFontSize)
+            cell.subtitleLabel.attributedText = contact.email.boldAt(indexes: emailHighlightedIndexes.indexes, fontSize: emailLabelFontSize)
         } else {
-            cell.emailLabel.attributedText = contact.email.boldAt(indexes: [], fontSize: emailLabelFontSize)
+            cell.subtitleLabel.attributedText = contact.email.boldAt(indexes: [], fontSize: emailLabelFontSize)
         }
 
         if let nameHighlightedIndexes = contactWithHighlight.indexesToHighlight.filter({ $0.contactDetail == .NAME }).first {
-            cell.nameLabel.attributedText = displayName.boldAt(indexes: nameHighlightedIndexes.indexes, fontSize: nameLabelFontSize)
+            cell.titleLabel.attributedText = displayName.boldAt(indexes: nameHighlightedIndexes.indexes, fontSize: nameLabelFontSize)
         } else {
-            cell.nameLabel.attributedText = displayName.boldAt(indexes: [], fontSize: nameLabelFontSize)
+            cell.titleLabel.attributedText = displayName.boldAt(indexes: [], fontSize: nameLabelFontSize)
         }
     }
 

+ 2 - 2
deltachat-ios/Controller/NewGroupController.swift

@@ -181,8 +181,8 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
             if let contactCell = cell as? AvatarTextCell {
                 let contact = DcContact(id: groupContactIds[row])
                 let displayName = contact.displayName
-                contactCell.nameLabel.text = displayName
-                contactCell.emailLabel.text = contact.email
+                contactCell.titleLabel.text = displayName
+                contactCell.subtitleLabel.text = contact.email
                 contactCell.avatar.setName(displayName)
                 contactCell.avatar.setColor(contact.color)
                 if let profileImage = contact.profileImage {

+ 15 - 9
deltachat-ios/View/AvatarTextCell.swift

@@ -21,7 +21,7 @@ class AvatarTextCell: UITableViewCell {
         return badge
     }()
 
-    let nameLabel: UILabel = {
+    let titleLabel: UILabel = {
         let label = UILabel()
         label.font = UIFont.systemFont(ofSize: 16, weight: .medium)
         label.lineBreakMode = .byTruncatingTail
@@ -34,7 +34,7 @@ class AvatarTextCell: UITableViewCell {
         return label
     }()
 
-    let emailLabel: UILabel = {
+    let subtitleLabel: UILabel = {
         let label = UILabel()
         label.font = UIFont.systemFont(ofSize: 14)
         label.textColor = UIColor(hexString: "848ba7")
@@ -47,8 +47,11 @@ class AvatarTextCell: UITableViewCell {
         label.font = UIFont.systemFont(ofSize: 14)
         label.textColor = UIColor(hexString: "848ba7")
         label.textAlignment = .right
+<<<<<<< HEAD
         label.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 2), for: NSLayoutConstraint.Axis.horizontal)
         // label.makeBorder()
+=======
+>>>>>>> avatar now updated for contact cell on search
         return label
     }()
 
@@ -99,10 +102,10 @@ class AvatarTextCell: UITableViewCell {
         let bottomLineStackView = UIStackView()
         bottomLineStackView.axis = .horizontal
 
-        toplineStackView.addArrangedSubview(nameLabel)
+        toplineStackView.addArrangedSubview(titleLabel)
         toplineStackView.addArrangedSubview(timeLabel)
 
-        bottomLineStackView.addArrangedSubview(emailLabel)
+        bottomLineStackView.addArrangedSubview(subtitleLabel)
         bottomLineStackView.addArrangedSubview(deliveryStatusIndicator)
         bottomLineStackView.addArrangedSubview(unreadMessageCounter)
 
@@ -196,11 +199,11 @@ class AvatarTextCell: UITableViewCell {
         fatalError("init(coder:) has not been implemented")
     }
 
-    // use this to update cells in cellForRowAt -
+    // use this to update cells in cellForRowAt
     func updateCell(cellViewModel: AvatarCellViewModel) {
 
         // subtitle
-        emailLabel.attributedText = cellViewModel.subtitle.boldAt(indexes: cellViewModel.subtitleHighlightIndexes, fontSize: emailLabel.font.pointSize)
+        subtitleLabel.attributedText = cellViewModel.subtitle.boldAt(indexes: cellViewModel.subtitleHighlightIndexes, fontSize: subtitleLabel.font.pointSize)
 
         switch cellViewModel.type {
         case .CHAT(let chatData):
@@ -208,9 +211,9 @@ class AvatarTextCell: UITableViewCell {
 
             // text bold if chat contains unread messages - otherwise hightlight search results if needed
             if chatData.unreadMessages > 0 {
-                nameLabel.attributedText = NSAttributedString(string: cellViewModel.title, attributes: [ .font: UIFont.systemFont(ofSize: 16, weight: .bold) ])
+                titleLabel.attributedText = NSAttributedString(string: cellViewModel.title, attributes: [ .font: UIFont.systemFont(ofSize: 16, weight: .bold) ])
             } else {
-                nameLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: nameLabel.font.pointSize)
+                titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
             }
 
             if let img = chat.profileImage {
@@ -225,7 +228,10 @@ class AvatarTextCell: UITableViewCell {
             setDeliveryStatusIndicator(chatData.summary.state)
 
         case .CONTACT(let contactData):
-            nameLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: nameLabel.font.pointSize)
+            let contact = DcContact(id: contactData.contactId)
+            titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
+            avatar.setName(cellViewModel.title)
+            avatar.setColor(contact.color)
         }
     }
 

+ 2 - 2
deltachat-ios/View/ContactDetailHeader.swift

@@ -13,7 +13,7 @@ class ContactDetailHeader: AvatarTextCell {
     }
 
     func updateDetails(title: String?, subtitle: String?) {
-        nameLabel.text = title
-        emailLabel.text = subtitle
+        titleLabel.text = title
+        subtitleLabel.text = subtitle
     }
 }