瀏覽代碼

hide avatars and sender name in 1:1 chats

cyberta 4 年之前
父節點
當前提交
b5cbddc5fa

+ 6 - 2
deltachat-ios/Chat/ChatViewControllerNew.swift

@@ -19,6 +19,9 @@ class ChatViewControllerNew: UITableViewController {
 
     var lastContentOffset: CGFloat = -1
     var isKeyboardShown: Bool = false
+    lazy var isGroupChat: Bool = {
+        return dcContext.getChat(chatId: chatId).isGroup
+    }()
 
     /// The `InputBarAccessoryView` used as the `inputAccessoryView` in the view controller.
     open var messageInputBar = InputBarAccessoryView()
@@ -357,7 +360,8 @@ class ChatViewControllerNew: UITableViewController {
         cell.baseDelegate = self
         cell.update(msg: message,
                     messageStyle: configureMessageStyle(for: message, at: indexPath),
-                    isAvatarVisible: configureAvatarVisibility(for: message, at: indexPath))
+                    isAvatarVisible: configureAvatarVisibility(for: message, at: indexPath),
+                    isGroup: isGroupChat)
         return cell
     }
 
@@ -404,7 +408,7 @@ class ChatViewControllerNew: UITableViewController {
     }
 
     func configureAvatarVisibility(for message: DcMsg, at indexPath: IndexPath) -> Bool {
-        return !message.isFromCurrentSender && !isNextMessageSameSender(currentMessage: message, at: indexPath)
+        return isGroupChat && !message.isFromCurrentSender && !isNextMessageSameSender(currentMessage: message, at: indexPath)
     }
 
     func configureMessageStyle(for message: DcMsg, at indexPath: IndexPath) -> UIRectCorner {

+ 2 - 2
deltachat-ios/Chat/Views/Cells/BaseMessageCell.swift

@@ -117,7 +117,7 @@ public class BaseMessageCell: UITableViewCell {
     }
 
     // update classes inheriting BaseMessageCell first before calling super.update(...)
-    func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool) {
+    func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool, isGroup: Bool) {
         if msg.isFromCurrentSender {
             topLabel.text = nil
             leadingConstraintCurrentSender?.isActive = true
@@ -127,7 +127,7 @@ public class BaseMessageCell: UITableViewCell {
             trailingConstraint?.isActive = false
 
         } else {
-            topLabel.text = msg.fromContact.displayName
+            topLabel.text = isGroup ? msg.fromContact.displayName : nil
             leadingConstraint?.isActive = true
             trailingConstraint?.isActive = true
             bottomSpacerConstraint?.isActive = false

+ 2 - 2
deltachat-ios/Chat/Views/Cells/NewAudioMessageCell.swift

@@ -44,7 +44,7 @@ public class NewAudioMessageCell: BaseMessageCell {
         delegate?.playButtonTapped(cell: self, messageId: messageId)
     }
 
-    override func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool) {
+    override func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool, isGroup: Bool) {
         //audioPlayerView.reset()
         messageId = msg.id
         if let text = msg.text {
@@ -54,7 +54,7 @@ public class NewAudioMessageCell: BaseMessageCell {
             mainContentView.spacing = 0
         }
 
-        super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible)
+        super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible, isGroup: isGroup)
     }
 
     public override func prepareForReuse() {

+ 2 - 2
deltachat-ios/Chat/Views/Cells/NewFileTextCell.swift

@@ -99,7 +99,7 @@ class NewFileTextCell: BaseMessageCell {
         fileImageView.image = nil
     }
 
-    override func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool) {
+    override func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool, isGroup: Bool) {
         if let text = msg.text, !text.isEmpty {
             messageLabel.text = text
             spacer?.isActive = true
@@ -114,7 +114,7 @@ class NewFileTextCell: BaseMessageCell {
         }
         fileTitle.text = msg.filename
         fileSubtitle.text = msg.getPrettyFileSize()
-        super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible)
+        super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible, isGroup: isGroup)
     }
 
     private func generateThumbnailFor(url: URL, placeholder: UIImage?) {

+ 2 - 2
deltachat-ios/Chat/Views/Cells/NewImageTextCell.swift

@@ -51,7 +51,7 @@ class NewImageTextCell: BaseMessageCell {
         contentImageView.addGestureRecognizer(gestureRecognizer)
     }
 
-    override func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool) {
+    override func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool, isGroup: Bool) {
         messageLabel.text = msg.text
         tag = msg.id
         if msg.type == DC_MSG_IMAGE, let image = msg.image {
@@ -94,7 +94,7 @@ class NewImageTextCell: BaseMessageCell {
                 setAspectRatioFor(message: msg, with: placeholderImage, isPlaceholder: true)
             }
         }
-        super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible)
+        super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible, isGroup: isGroup)
     }
 
     @objc func onImageTapped() {

+ 2 - 2
deltachat-ios/Chat/Views/Cells/NewTextMessageCell.swift

@@ -18,9 +18,9 @@ class NewTextMessageCell: BaseMessageCell {
         mainContentView.addArrangedSubview(messageLabel)        
     }
 
-    override func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool) {
+    override func update(msg: DcMsg, messageStyle: UIRectCorner, isAvatarVisible: Bool, isGroup: Bool) {
         messageLabel.text = msg.text
-        super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible)
+        super.update(msg: msg, messageStyle: messageStyle, isAvatarVisible: isAvatarVisible, isGroup: isGroup)
     }
 
     override func prepareForReuse() {