Переглянути джерело

allow selection background for video invite messages as well

cyberta 3 роки тому
батько
коміт
b733d70f72

+ 1 - 0
deltachat-ios/Chat/ChatViewController.swift

@@ -684,6 +684,7 @@ class ChatViewController: UITableViewController {
         switch Int32(message.type) {
         switch Int32(message.type) {
         case DC_MSG_VIDEOCHAT_INVITATION:
         case DC_MSG_VIDEOCHAT_INVITATION:
             let videoInviteCell = tableView.dequeueReusableCell(withIdentifier: "video_invite", for: indexPath) as? VideoInviteCell ?? VideoInviteCell()
             let videoInviteCell = tableView.dequeueReusableCell(withIdentifier: "video_invite", for: indexPath) as? VideoInviteCell ?? VideoInviteCell()
+            videoInviteCell.showSelectionBackground(tableView.isEditing)
             videoInviteCell.update(dcContext: dcContext, msg: message)
             videoInviteCell.update(dcContext: dcContext, msg: message)
             return videoInviteCell
             return videoInviteCell
 
 

+ 18 - 1
deltachat-ios/Chat/Views/Cells/VideoInviteCell.swift

@@ -66,9 +66,12 @@ public class VideoInviteCell: UITableViewCell {
         label.backgroundColor = DcColors.systemMessageBackgroundColor
         label.backgroundColor = DcColors.systemMessageBackgroundColor
         return label
         return label
     }()
     }()
+    
+    private var showSelectionBackground: Bool
 
 
 
 
     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+        showSelectionBackground = false
         super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
         super.init(style: .subtitle, reuseIdentifier: reuseIdentifier)
         clipsToBounds = false
         clipsToBounds = false
         backgroundColor = .clear
         backgroundColor = .clear
@@ -108,7 +111,6 @@ public class VideoInviteCell: UITableViewCell {
             bottomLabel.constraintAlignLeadingMaxTo(contentView, paddingLeading: UIDevice.current.userInterfaceIdiom == .pad ? 150 : 50),
             bottomLabel.constraintAlignLeadingMaxTo(contentView, paddingLeading: UIDevice.current.userInterfaceIdiom == .pad ? 150 : 50),
             bottomLabel.constraintAlignBottomTo(contentView, paddingBottom: 12)
             bottomLabel.constraintAlignBottomTo(contentView, paddingBottom: 12)
         ])
         ])
-        selectionStyle = .none
     }
     }
 
 
     func update(dcContext: DcContext, msg: DcMsg) {
     func update(dcContext: DcContext, msg: DcMsg) {
@@ -137,6 +139,15 @@ public class VideoInviteCell: UITableViewCell {
         messageBackgroundContainer.update(rectCorners: corners, color: DcColors.systemMessageBackgroundColor)
         messageBackgroundContainer.update(rectCorners: corners, color: DcColors.systemMessageBackgroundColor)
     }
     }
 
 
+    public override func setSelected(_ selected: Bool, animated: Bool) {
+         super.setSelected(selected, animated: animated)
+         if selected && showSelectionBackground {
+             selectedBackgroundView?.backgroundColor = DcColors.chatBackgroundColor.withAlphaComponent(0.5)
+         } else {
+             selectedBackgroundView?.backgroundColor = .clear
+         }
+     }
+
     public override func prepareForReuse() {
     public override func prepareForReuse() {
         super.prepareForReuse()
         super.prepareForReuse()
         messageLabel.text = nil
         messageLabel.text = nil
@@ -146,6 +157,12 @@ public class VideoInviteCell: UITableViewCell {
         openLabel.text = nil
         openLabel.text = nil
         openLabel.attributedText = nil
         openLabel.attributedText = nil
         avatarView.reset()
         avatarView.reset()
+        showSelectionBackground = false
     }
     }
+}
 
 
+extension VideoInviteCell: SelectableCell {
+    public func showSelectionBackground(_ show: Bool) {
+        showSelectionBackground = show
+    }
 }
 }