فهرست منبع

allow selection background for video invite messages as well

cyberta 3 سال پیش
والد
کامیت
b733d70f72
2فایلهای تغییر یافته به همراه19 افزوده شده و 1 حذف شده
  1. 1 0
      deltachat-ios/Chat/ChatViewController.swift
  2. 18 1
      deltachat-ios/Chat/Views/Cells/VideoInviteCell.swift

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

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

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

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