Explorar el Código

renamed labels of ContactCell to make them more generic

nayooti hace 5 años
padre
commit
7fe7508bee

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

@@ -166,7 +166,7 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
         let summary = chatList.getSummary(index: row)
         let unreadMessages = dcContext.getUnreadMessages(chatId: chatId)
 
-        cell.nameLabel.attributedText = (unreadMessages > 0) ?
+        cell.titleLabel.attributedText = (unreadMessages > 0) ?
             NSAttributedString(string: chat.name, attributes: [ .font: UIFont.systemFont(ofSize: 16, weight: .bold) ]) :
             NSAttributedString(string: chat.name, attributes: [ .font: UIFont.systemFont(ofSize: 16, weight: .medium) ])
 
@@ -198,7 +198,7 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
             result = "\(result1)\(result2)"
         }
 
-        cell.emailLabel.text = result
+        cell.subtitleLabel.text = result
         cell.setTimeLabel(summary.timestamp)
         cell.setUnreadMessageCounter(unreadMessages)
         cell.setDeliveryStatusIndicator(summary.state)

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

@@ -186,8 +186,8 @@ extension GroupChatDetailViewController: UITableViewDelegate, UITableViewDataSou
                 if let contactCell = cell as? ContactCell {
                     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? ContactCell {
                 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 {

+ 12 - 13
deltachat-ios/View/ContactCell.swift

@@ -15,13 +15,13 @@ class ContactCell: UITableViewCell {
     private let imgSize: CGFloat = 20
 
     lazy var toplineStackView: UIStackView = {
-        let stackView = UIStackView(arrangedSubviews: [nameLabel, timeLabel])
+        let stackView = UIStackView(arrangedSubviews: [titleLabel, timeLabel])
         stackView.axis = .horizontal
         return stackView
     }()
 
     lazy var bottomlineStackView: UIStackView = {
-        let stackView = UIStackView(arrangedSubviews: [emailLabel, deliveryStatusIndicator])
+        let stackView = UIStackView(arrangedSubviews: [subtitleLabel, deliveryStatusIndicator])
         stackView.axis = .horizontal
         stackView.spacing = 10
         return stackView
@@ -36,30 +36,29 @@ class ContactCell: UITableViewCell {
         return badge
     }()
 
-    let nameLabel: UILabel = {
+    let titleLabel: UILabel = {
         let label = UILabel()
         label.font = UIFont.systemFont(ofSize: 16, weight: .medium)
         label.lineBreakMode = .byTruncatingTail
         label.textColor = DcColors.defaultTextColor
         label.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 1), for: NSLayoutConstraint.Axis.horizontal)
         return label
-
     }()
 
-    let emailLabel: UILabel = {
+    private let timeLabel: UILabel = {
         let label = UILabel()
         label.font = UIFont.systemFont(ofSize: 14)
         label.textColor = UIColor(hexString: "848ba7")
-        label.lineBreakMode = .byTruncatingTail
+        label.textAlignment = .right
+        label.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 2), for: NSLayoutConstraint.Axis.horizontal)
         return label
     }()
 
-    private let timeLabel: UILabel = {
+    let subtitleLabel: UILabel = {
         let label = UILabel()
         label.font = UIFont.systemFont(ofSize: 14)
         label.textColor = UIColor(hexString: "848ba7")
-        label.textAlignment = .right
-        label.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 2), for: NSLayoutConstraint.Axis.horizontal)
+        label.lineBreakMode = .byTruncatingTail
         return label
     }()
 
@@ -220,7 +219,7 @@ class ContactCell: UITableViewCell {
 
     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):
@@ -228,9 +227,9 @@ class ContactCell: 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 {
@@ -247,7 +246,7 @@ class ContactCell: UITableViewCell {
 
         case .CONTACT(let contactData):
             let contact = DcContact(id: contactData.contactId)
-            nameLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: nameLabel.font.pointSize)
+            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: ContactCell {
     }
 
     func updateDetails(title: String?, subtitle: String?) {
-        nameLabel.text = title
-        emailLabel.text = subtitle
+        titleLabel.text = title
+        subtitleLabel.text = subtitle
     }
 }