Browse Source

Show stickers without background color and sender/forwarded header. Show sent footer outside of the sticker image

cyberta 4 years ago
parent
commit
6ad676fc6e

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

@@ -553,7 +553,7 @@ class ChatViewController: UITableViewController {
         }
 
         let cell: BaseMessageCell
-        if message.type == DC_MSG_IMAGE || message.type == DC_MSG_GIF || message.type == DC_MSG_VIDEO {
+        if message.type == DC_MSG_IMAGE || message.type == DC_MSG_GIF || message.type == DC_MSG_VIDEO || message.type == DC_MSG_STICKER {
             cell = tableView.dequeueReusableCell(withIdentifier: "image", for: indexPath) as? ImageTextCell ?? ImageTextCell()
         } else if message.type == DC_MSG_FILE {
             if message.isSetupMessage {

+ 20 - 5
deltachat-ios/Chat/Views/Cells/BaseMessageCell.swift

@@ -66,6 +66,8 @@ public class BaseMessageCell: UITableViewCell {
         }
     }
 
+    public var isTransparent: Bool = false
+
     public weak var baseDelegate: BaseMessageCellDelegate?
 
     public lazy var quoteView: QuoteView = {
@@ -311,7 +313,7 @@ public class BaseMessageCell: UITableViewCell {
         isFullMessageButtonHidden = !msg.hasHtml
 
         messageBackgroundContainer.update(rectCorners: messageStyle,
-                                          color: msg.isFromCurrentSender ? DcColors.messagePrimaryColor : DcColors.messageSecondaryColor)
+                                          color: getBackgroundColor(message: msg))
 
         if !msg.isInfo {
             bottomLabel.attributedText = getFormattedBottomLine(message: msg)
@@ -369,6 +371,18 @@ public class BaseMessageCell: UITableViewCell {
             "\(getFormattedBottomLineAccessibilityString(message: message))"
     }
 
+    func getBackgroundColor(message: DcMsg) -> UIColor {
+        var backgroundColor: UIColor
+        if isTransparent {
+            backgroundColor = UIColor.init(alpha: 0, red: 0, green: 0, blue: 0)
+        } else if message.isFromCurrentSender {
+            backgroundColor =  DcColors.messagePrimaryColor
+        } else {
+            backgroundColor = DcColors.messageSecondaryColor
+        }
+        return backgroundColor
+    }
+
     func getFormattedBottomLineAccessibilityString(message: DcMsg) -> String {
         let padlock =  message.showPadlock() ? "\(String.localized("encrypted_message")), " : ""
         let date = "\(message.formattedSentDate()), "
@@ -391,21 +405,22 @@ public class BaseMessageCell: UITableViewCell {
 
         let text = NSMutableAttributedString()
         if message.fromContactId == Int(DC_CONTACT_ID_SELF) {
+            let tintColor: UIColor? = !(bottomCompactView || isTransparent) ? DcColors.checkmarkGreen : nil
             if let style = NSMutableParagraphStyle.default.mutableCopy() as? NSMutableParagraphStyle {
                 style.alignment = .right
                 timestampAttributes[.paragraphStyle] = style
-                if !bottomCompactView {
-                    timestampAttributes[.foregroundColor] = DcColors.checkmarkGreen
+                if let tintColor = tintColor {
+                    timestampAttributes[.foregroundColor] = tintColor
                 }
             }
 
             text.append(NSAttributedString(string: message.formattedSentDate(), attributes: timestampAttributes))
             if message.showPadlock() {
-                attachPadlock(to: text, color: bottomCompactView ? nil : DcColors.checkmarkGreen)
+                attachPadlock(to: text, color: tintColor)
             }
             
             if message.hasLocation {
-                attachLocation(to: text, color: bottomCompactView ? nil : DcColors.checkmarkGreen)
+                attachLocation(to: text, color: tintColor)
             }
 
             attachSendingState(message.state, to: text)

+ 6 - 5
deltachat-ios/Chat/Views/Cells/ImageTextCell.swift

@@ -44,16 +44,17 @@ class ImageTextCell: BaseMessageCell {
 
     override func update(msg: DcMsg, messageStyle: UIRectCorner, showAvatar: Bool, showName: Bool) {
         messageLabel.text = msg.text
-        bottomCompactView = msg.text?.isEmpty ?? true
+        bottomCompactView = msg.type != DC_MSG_STICKER && msg.text?.isEmpty ?? true
         mainContentView.spacing = msg.text?.isEmpty ?? false ? 0 : 6
         topCompactView = msg.quoteText == nil ? true : false
+        isTransparent = msg.type == DC_MSG_STICKER
+        topLabel.isHidden = msg.type == DC_MSG_STICKER
         tag = msg.id
 
         if let url = msg.fileURL,
-           ((msg.type == DC_MSG_IMAGE) ||
-            (msg.type == DC_MSG_GIF) ||
-                msg.type == DC_MSG_STICKER ||
-                (msg.type == DC_MSG_IMAGE && url.pathExtension == "webp")) {
+           (msg.type == DC_MSG_IMAGE ||
+            msg.type == DC_MSG_GIF ||
+                msg.type == DC_MSG_STICKER) {
             contentImageView.sd_setImage(with: url,
                                          placeholderImage: UIImage(color: UIColor.init(alpha: 0,
                                                                                        red: 255,