Kaynağa Gözat

Merge pull request #1355 from deltachat/downloadOnDemand

Download on demand
cyBerta 3 yıl önce
ebeveyn
işleme
3c4afd87c2

+ 9 - 1
DcCore/DcCore/DC/Wrapper.swift

@@ -128,6 +128,10 @@ public class DcContext {
         dc_send_msg(contextPointer, UInt32(chatId), message.messagePointer)
     }
 
+    public func downloadFullMessage(id: Int) {
+        dc_download_full_msg(contextPointer, Int32(id))
+    }
+
     public func sendVideoChatInvitation(chatId: Int) -> Int {
         return Int(dc_send_videochat_invitation(contextPointer, UInt32(chatId)))
     }
@@ -1002,6 +1006,10 @@ public class DcMsg {
         }
     }
 
+    public var downloadState: Int32 {
+        return dc_msg_get_download_state(messagePointer)
+    }
+
     public var viewtype: MessageViewType? {
         switch dc_msg_get_viewtype(messagePointer) {
         case 0:
@@ -1157,7 +1165,7 @@ public class DcMsg {
 
     public func summary(chat: DcChat) -> DcLot {
         guard let chatPointer = chat.chatPointer else {
-            return DcLot(nil);
+            return DcLot(nil)
         }
         guard let dcLotPointer = dc_msg_get_summary(messagePointer, chatPointer) else {
             return DcLot(nil)

+ 4 - 0
deltachat-ios.xcodeproj/project.pbxproj

@@ -69,6 +69,7 @@
 		30734326249A280B00BF9AD1 /* MediaQualityController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30734325249A280B00BF9AD1 /* MediaQualityController.swift */; };
 		307A82CC25B8D26700748B57 /* ChatEditingBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307A82CB25B8D26700748B57 /* ChatEditingBar.swift */; };
 		307D822E241669C7006D2490 /* LocationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307D822D241669C7006D2490 /* LocationManager.swift */; };
+		30860EE926F49E64002651A6 /* DownloadOnDemandViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30860EE826F49E64002651A6 /* DownloadOnDemandViewController.swift */; };
 		3095A351237DD1F700AB07F7 /* MediaPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3095A350237DD1F700AB07F7 /* MediaPicker.swift */; };
 		30A4149724F6EFBE00EC91EB /* InfoMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30A4149624F6EFBE00EC91EB /* InfoMessageCell.swift */; };
 		30B0ACFA24AB5B99004D5E29 /* SettingsEphemeralMessageController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30B0ACF924AB5B99004D5E29 /* SettingsEphemeralMessageController.swift */; };
@@ -318,6 +319,7 @@
 		30734325249A280B00BF9AD1 /* MediaQualityController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaQualityController.swift; sourceTree = "<group>"; };
 		307A82CB25B8D26700748B57 /* ChatEditingBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatEditingBar.swift; sourceTree = "<group>"; };
 		307D822D241669C7006D2490 /* LocationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationManager.swift; sourceTree = "<group>"; };
+		30860EE826F49E64002651A6 /* DownloadOnDemandViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadOnDemandViewController.swift; sourceTree = "<group>"; };
 		3095A350237DD1F700AB07F7 /* MediaPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaPicker.swift; sourceTree = "<group>"; };
 		30A4149624F6EFBE00EC91EB /* InfoMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoMessageCell.swift; sourceTree = "<group>"; };
 		30AC265E237F1807002A943F /* AvatarHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvatarHelper.swift; sourceTree = "<group>"; };
@@ -809,6 +811,7 @@
 				AE76E5ED242BF2EA003CF461 /* WelcomeViewController.swift */,
 				AE8F503424753DFE007FEE0B /* GalleryViewController.swift */,
 				30734325249A280B00BF9AD1 /* MediaQualityController.swift */,
+				30860EE826F49E64002651A6 /* DownloadOnDemandViewController.swift */,
 				AED423D2249F578B00B6B2BB /* AddGroupMembersViewController.swift */,
 				AED423D6249F580700B6B2BB /* BlockedContactsViewController.swift */,
 				AE39D322249CFC1A007346A1 /* DocumentGalleryController.swift */,
@@ -1314,6 +1317,7 @@
 				30149D9322F21129003C12B5 /* QrViewController.swift in Sources */,
 				AEE56D80225504DB007DC082 /* Extensions.swift in Sources */,
 				7A0052C81FBE6CB40048C3BF /* NewContactController.swift in Sources */,
+				30860EE926F49E64002651A6 /* DownloadOnDemandViewController.swift in Sources */,
 				AEE56D762253431E007DC082 /* AccountSetupController.swift in Sources */,
 				AE8F503524753DFE007FEE0B /* GalleryViewController.swift in Sources */,
 				B2C42570265C325C00B95377 /* MultilineLabelCell.swift in Sources */,

+ 2 - 0
deltachat-ios/AppDelegate.swift

@@ -567,6 +567,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         dcContext.setStockTranslation(id: DC_STR_PROTECTION_DISABLED, localizationKey: "systemmsg_chat_protection_disabled")
         dcContext.setStockTranslation(id: DC_STR_REPLY_NOUN, localizationKey: "reply_noun")
         dcContext.setStockTranslation(id: DC_STR_FORWARDED, localizationKey: "forwarded")
+        dcContext.setStockTranslation(id: DC_STR_PARTIAL_DOWNLOAD_MSG_BODY, localizationKey: "n_bytes_message")
+        dcContext.setStockTranslation(id: DC_STR_DOWNLOAD_AVAILABILITY, localizationKey: "download_max_available_until")
     }
 
     func appIsInForeground() -> Bool {

+ 7 - 3
deltachat-ios/Chat/ChatViewController.swift

@@ -1508,13 +1508,17 @@ class ChatViewController: UITableViewController {
 // MARK: - BaseMessageCellDelegate
 extension ChatViewController: BaseMessageCellDelegate {
 
-    @objc func fullMessageTapped(indexPath: IndexPath) {
+    @objc func actionButtonTapped(indexPath: IndexPath) {
         if handleUIMenu() || handleSelection(indexPath: indexPath) {
             return
         }
         let msg = dcContext.getMessage(id: messageIds[indexPath.row])
-        let fullMessageViewController = FullMessageViewController(dcContext: dcContext, messageId: msg.id)
-        navigationController?.pushViewController(fullMessageViewController, animated: true)
+        if msg.downloadState != DC_DOWNLOAD_DONE {
+            dcContext.downloadFullMessage(id: msg.id)
+        } else {
+            let fullMessageViewController = FullMessageViewController(dcContext: dcContext, messageId: msg.id)
+            navigationController?.pushViewController(fullMessageViewController, animated: true)
+        }
     }
 
     @objc func quoteTapped(indexPath: IndexPath) {

+ 39 - 22
deltachat-ios/Chat/Views/Cells/BaseMessageCell.swift

@@ -10,11 +10,11 @@ public class BaseMessageCell: UITableViewCell {
     private var trailingConstraintCurrentSender: NSLayoutConstraint?
     private var mainContentBelowTopLabelConstraint: NSLayoutConstraint?
     private var mainContentUnderTopLabelConstraint: NSLayoutConstraint?
-    private var mainContentAboveFullMessageBtnConstraint: NSLayoutConstraint?
+    private var mainContentAboveActionBtnConstraint: NSLayoutConstraint?
     private var mainContentUnderBottomLabelConstraint: NSLayoutConstraint?
     private var mainContentViewLeadingConstraint: NSLayoutConstraint?
     private var mainContentViewTrailingConstraint: NSLayoutConstraint?
-    private var fullMessageZeroHeightConstraint: NSLayoutConstraint?
+    private var actionBtnZeroHeightConstraint: NSLayoutConstraint?
 
     public var mainContentViewHorizontalPadding: CGFloat {
         get {
@@ -46,7 +46,7 @@ public class BaseMessageCell: UITableViewCell {
             return mainContentUnderBottomLabelConstraint?.isActive ?? false
         }
         set {
-            mainContentAboveFullMessageBtnConstraint?.isActive = !newValue
+            mainContentAboveActionBtnConstraint?.isActive = !newValue
             mainContentUnderBottomLabelConstraint?.isActive = newValue
             bottomLabel.backgroundColor = newValue ?
                 UIColor(alpha: 200, red: 50, green: 50, blue: 50) :
@@ -54,15 +54,14 @@ public class BaseMessageCell: UITableViewCell {
         }
     }
 
-    public var isFullMessageButtonHidden: Bool {
+    public var isActionButtonHidden: Bool {
         get {
-            return fullMessageButton.isHidden
+            return actionButton.isHidden
         }
         set {
-            mainContentAboveFullMessageBtnConstraint?.constant = newValue ? -2 : 8
-            fullMessageButton.setTitle(newValue ? "" : String.localized("show_full_message"), for: .normal)
-            fullMessageZeroHeightConstraint?.isActive = newValue
-            fullMessageButton.isHidden = newValue
+            mainContentAboveActionBtnConstraint?.constant = newValue ? -2 : 8
+            actionBtnZeroHeightConstraint?.isActive = newValue
+            actionButton.isHidden = newValue
         }
     }
 
@@ -128,14 +127,15 @@ public class BaseMessageCell: UITableViewCell {
         return view
     }()
 
-    lazy var fullMessageButton: DynamicFontButton = {
+    lazy var actionButton: DynamicFontButton = {
         let button = DynamicFontButton()
         button.translatesAutoresizingMaskIntoConstraints = false
         button.setTitleColor(.systemBlue, for: .normal)
         button.setTitleColor(.gray, for: .highlighted)
         button.titleLabel?.lineBreakMode = .byWordWrapping
         button.titleLabel?.textAlignment = .left
-        button.addTarget(self, action: #selector(onFullMessageButtonTapped), for: .touchUpInside)
+        button.contentHorizontalAlignment = .left
+        button.addTarget(self, action: #selector(onActionButtonTapped), for: .touchUpInside)
         button.titleLabel?.font = UIFont.preferredFont(for: .body, weight: .regular)
         button.titleLabel?.adjustsFontForContentSizeCategory = true
         button.contentEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0)
@@ -184,7 +184,7 @@ public class BaseMessageCell: UITableViewCell {
         contentView.addSubview(messageBackgroundContainer)
         messageBackgroundContainer.addSubview(mainContentView)
         messageBackgroundContainer.addSubview(topLabel)
-        messageBackgroundContainer.addSubview(fullMessageButton)
+        messageBackgroundContainer.addSubview(actionButton)
         messageBackgroundContainer.addSubview(bottomLabel)
         contentView.addSubview(avatarView)
 
@@ -198,11 +198,11 @@ public class BaseMessageCell: UITableViewCell {
             topLabel.constraintAlignTrailingMaxTo(messageBackgroundContainer, paddingTrailing: 8),
             messageBackgroundContainer.constraintAlignTopTo(contentView, paddingTop: 3),
             messageBackgroundContainer.constraintAlignBottomTo(contentView, paddingBottom: 3),
-            fullMessageButton.constraintAlignLeadingTo(messageBackgroundContainer, paddingLeading: 12),
-            fullMessageButton.constraintAlignTrailingMaxTo(messageBackgroundContainer, paddingTrailing: 12),
+            actionButton.constraintAlignLeadingTo(messageBackgroundContainer, paddingLeading: 12),
+            actionButton.constraintAlignTrailingTo(messageBackgroundContainer, paddingTrailing: 12),
             bottomLabel.constraintAlignLeadingMaxTo(messageBackgroundContainer, paddingLeading: 8),
             bottomLabel.constraintAlignTrailingTo(messageBackgroundContainer, paddingTrailing: 8),
-            bottomLabel.constraintToBottomOf(fullMessageButton, paddingTop: 8, priority: .defaultHigh),
+            bottomLabel.constraintToBottomOf(actionButton, paddingTop: 8, priority: .defaultHigh),
             bottomLabel.constraintAlignBottomTo(messageBackgroundContainer, paddingBottom: 6)
         ])
 
@@ -219,14 +219,14 @@ public class BaseMessageCell: UITableViewCell {
 
         mainContentBelowTopLabelConstraint = mainContentView.constraintToBottomOf(topLabel, paddingTop: 6)
         mainContentUnderTopLabelConstraint = mainContentView.constraintAlignTopTo(messageBackgroundContainer)
-        mainContentAboveFullMessageBtnConstraint = fullMessageButton.constraintToBottomOf(mainContentView, paddingTop: 8, priority: .defaultHigh)
+        mainContentAboveActionBtnConstraint = actionButton.constraintToBottomOf(mainContentView, paddingTop: 8, priority: .defaultHigh)
         mainContentUnderBottomLabelConstraint = mainContentView.constraintAlignBottomTo(messageBackgroundContainer, paddingBottom: 0, priority: .defaultHigh)
 
-        fullMessageZeroHeightConstraint = fullMessageButton.constraintHeightTo(0)
+        actionBtnZeroHeightConstraint = actionButton.constraintHeightTo(0)
 
         topCompactView = false
         bottomCompactView = false
-        isFullMessageButtonHidden = true
+        isActionButtonHidden = true
         
 
         let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(onAvatarTapped))
@@ -265,9 +265,9 @@ public class BaseMessageCell: UITableViewCell {
         }
     }
 
-    @objc func onFullMessageButtonTapped() {
+    @objc func onActionButtonTapped() {
         if let tableView = self.superview as? UITableView, let indexPath = tableView.indexPath(for: self) {
-            baseDelegate?.fullMessageTapped(indexPath: indexPath)
+            baseDelegate?.actionButtonTapped(indexPath: indexPath)
         }
     }
 
@@ -310,7 +310,23 @@ public class BaseMessageCell: UITableViewCell {
             avatarView.isHidden = true
         }
 
-        isFullMessageButtonHidden = !msg.hasHtml
+        let downloadState = msg.downloadState
+        let hasHtml = msg.hasHtml
+        isActionButtonHidden = !hasHtml && downloadState == DC_DOWNLOAD_DONE
+        
+        switch downloadState {
+        case DC_DOWNLOAD_FAILURE, DC_DOWNLOAD_AVAILABLE:
+            actionButton.setTitle(String.localized("download"), for: .normal)
+        case DC_DOWNLOAD_IN_PROGRESS:
+            actionButton.isEnabled = false
+            actionButton.setTitle(String.localized("downloading"), for: .normal)
+        default:
+            break
+        }
+        
+        if hasHtml {
+            actionButton.setTitle(String.localized("show_full_message"), for: .normal)
+        }
 
         messageBackgroundContainer.update(rectCorners: messageStyle,
                                           color: getBackgroundColor(dcContext: dcContext, message: msg))
@@ -399,6 +415,7 @@ public class BaseMessageCell: UITableViewCell {
         messageLabel.attributedText = nil
         messageLabel.delegate = nil
         quoteView.prepareForReuse()
+        actionButton.isEnabled = true
     }
 
     // MARK: - Context menu
@@ -475,5 +492,5 @@ public protocol BaseMessageCellDelegate: class {
     func avatarTapped(indexPath: IndexPath)
     func textTapped(indexPath: IndexPath)
     func quoteTapped(indexPath: IndexPath)
-    func fullMessageTapped(indexPath: IndexPath)
+    func actionButtonTapped(indexPath: IndexPath)
 }

+ 83 - 0
deltachat-ios/Controller/DownloadOnDemandViewController.swift

@@ -0,0 +1,83 @@
+import UIKit
+import DcCore
+class DownloadOnDemandViewController: UITableViewController {
+
+    private var dcContext: DcContext
+
+    private var options: [Int]
+
+    private lazy var staticCells: [UITableViewCell] = {
+        return options.map({
+            let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
+            cell.textLabel?.text = DownloadOnDemandViewController.getValString(val: $0)
+            return cell
+        })
+    }()
+
+    init(dcContext: DcContext) {
+        self.dcContext = dcContext
+        self.options = [0, 40960, 163840, 655360, 5242880, 26214400]
+        super.init(style: .grouped)
+        self.title = String.localized("auto_download_messages")
+        hidesBottomBarWhenPushed = true
+    }
+
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+    }
+
+    static func getValString(val: Int) -> String {
+        switch val {
+        case 0:
+            return String.localized("pref_show_emails_all")
+        case 40960:
+            return String.localizedStringWithFormat(String.localized("up_to_x"), "40 KiB")
+        case 163840:
+            return String.localizedStringWithFormat(String.localized("up_to_x_most_worse_quality_images"), "160 KiB")
+        case 655360:
+            return String.localizedStringWithFormat(String.localized("up_to_x_most_balanced_quality_images"), "640 KiB")
+        case 5242880:
+            return String.localizedStringWithFormat(String.localized("up_to_x"), "5 MB")
+        case 26214400:
+            return String.localizedStringWithFormat(String.localized("up_to_x"), "25 MB")
+        default:
+            return "Err"
+        }
+    }
+
+    // MARK: - Table view data source
+
+    override func numberOfSections(in tableView: UITableView) -> Int {
+        return 1
+    }
+
+    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return options.count
+    }
+
+    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: true) // animated as no other elements pop up
+
+        if let lastSelectedIndex = options.index(of: dcContext.getConfigInt("download_limit")) {
+            let oldSelectedCell = tableView.cellForRow(at: IndexPath.init(row: lastSelectedIndex, section: 0))
+            oldSelectedCell?.accessoryType = .none
+        }
+
+        let newSelectedCell = tableView.cellForRow(at: IndexPath.init(row: indexPath.row, section: 0))
+        newSelectedCell?.accessoryType = .checkmark
+
+        dcContext.setConfigInt("download_limit", options[indexPath.row])
+    }
+
+    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = staticCells[indexPath.row]
+        if options[indexPath.row] == dcContext.getConfigInt("download_limit") {
+            cell.accessoryType = .checkmark
+        }
+        return cell
+    }
+}

+ 23 - 4
deltachat-ios/Controller/SettingsController.swift

@@ -25,9 +25,10 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         case help = 10
         case autodel = 11
         case mediaQuality = 12
-        case switchAccount = 13
-        case videoChat = 14
-        case connectivity = 15
+        case downloadOnDemand = 13
+        case switchAccount = 14
+        case videoChat = 15
+        case connectivity = 16
     }
 
     private var dcContext: DcContext
@@ -106,6 +107,15 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         return cell
     }()
 
+    private lazy var downloadOnDemandCell: UITableViewCell = {
+        let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
+        cell.tag = CellTags.downloadOnDemand.rawValue
+        cell.textLabel?.text = String.localized("auto_download_messages")
+        cell.accessoryType = .disclosureIndicator
+        cell.detailTextLabel?.text = DownloadOnDemandViewController.getValString(val: dcContext.getConfigInt("download_limit"))
+        return cell
+    }()
+
     private lazy var videoChatInstanceCell: UITableViewCell = {
         let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
         cell.tag = CellTags.videoChat.rawValue
@@ -220,7 +230,8 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         let preferencesSection = SectionConfigs(
             headerTitle: String.localized("pref_chats_and_media"),
             footerTitle: String.localized("pref_read_receipts_explain"),
-            cells: [showArchiveCell, showEmailsCell, blockedContactsCell, autodelCell, mediaQualityCell, videoChatInstanceCell, notificationCell, receiptConfirmationCell]
+            cells: [showArchiveCell, showEmailsCell, blockedContactsCell, mediaQualityCell, downloadOnDemandCell,
+                    autodelCell, videoChatInstanceCell, notificationCell, receiptConfirmationCell]
         )
         let autocryptSection = SectionConfigs(
             headerTitle: String.localized("autocrypt"),
@@ -334,6 +345,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         case .blockedContacts: showBlockedContacts()
         case .autodel: showAutodelOptions()
         case .mediaQuality: showMediaQuality()
+        case .downloadOnDemand: showDownloadOnDemand()
         case .videoChat: showVideoChatInstance()
         case .notifications: break
         case .receiptConfirmation: break
@@ -558,6 +570,8 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         profileCell.updateCell(cellViewModel: ProfileViewModel(context: dcContext))
         showEmailsCell.detailTextLabel?.text = SettingsClassicViewController.getValString(val: dcContext.showEmails)
         mediaQualityCell.detailTextLabel?.text = MediaQualityController.getValString(val: dcContext.getConfigInt("media_quality"))
+        downloadOnDemandCell.detailTextLabel?.text = DownloadOnDemandViewController.getValString(
+            val: dcContext.getConfigInt("download_limit"))
         videoChatInstanceCell.detailTextLabel?.text = dcContext.getConfig("webrtc_instance")
         autodelCell.detailTextLabel?.text = autodelSummary()
         connectivityCell.detailTextLabel?.text = DcUtils.getConnectivityString(dcContext: dcContext,
@@ -580,6 +594,11 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         navigationController?.pushViewController(mediaQualityController, animated: true)
     }
 
+    private func showDownloadOnDemand() {
+        let downloadOnDemandViewController = DownloadOnDemandViewController(dcContext: dcContext)
+        navigationController?.pushViewController(downloadOnDemandViewController, animated: true)
+    }
+
     private func showVideoChatInstance() {
         let videoInstanceController = SettingsVideoChatViewController(dcContext: dcContext)
         navigationController?.pushViewController(videoInstanceController, animated: true)

+ 9 - 2
deltachat-ios/Helper/MessageUtils.swift

@@ -36,10 +36,17 @@ public class MessageUtils {
                 attachLocation(to: text, color: tintColor)
             }
 
-            attachSendingState(message.state, to: text)
+            let messageState = message.downloadState == DC_DOWNLOAD_IN_PROGRESS ?
+                Int(DC_DOWNLOAD_IN_PROGRESS) :
+                message.state
+            attachSendingState(messageState, to: text)
             return text
         }
 
+        if message.downloadState == DC_DOWNLOAD_IN_PROGRESS {
+            attachSendingState(Int(DC_DOWNLOAD_IN_PROGRESS), to: text)
+        }
+        
         text.append(NSAttributedString(string: message.formattedSentDate(), attributes: timestampAttributes))
         if message.showPadlock() {
             attachPadlock(to: text)
@@ -100,7 +107,7 @@ public class MessageUtils {
         var offset: CGFloat = -2
 
         switch Int32(state) {
-        case DC_STATE_OUT_PENDING, DC_STATE_OUT_PREPARING:
+        case DC_STATE_OUT_PENDING, DC_STATE_OUT_PREPARING, DC_DOWNLOAD_IN_PROGRESS:
             imageAttachment.image = #imageLiteral(resourceName: "ic_hourglass_empty_white_36pt").scaleDownImage(toMax: 14)?.maskWithColor(color: DcColors.grayDateColor)
         case DC_STATE_OUT_DELIVERED:
             imageAttachment.image = #imageLiteral(resourceName: "ic_done_36pt").scaleDownImage(toMax: 16)?.sd_croppedImage(with: CGRect(x: 0, y: 4, width: 16, height: 14))