Эх сурвалжийг харах

Merge pull request #553 from deltachat/sending_state_icons

replace textual sending state representation of messages by icons (#550)
bjoern 5 жил өмнө
parent
commit
fb7121710c
15 өөрчлөгдсөн 37 нэмэгдсэн , 33 устгасан
  1. BIN
      deltachat-ios/Assets.xcassets/ic_done_all_black_36dp/ios/ic_done_all_36pt.imageset/ic_done_all_36pt.png
  2. BIN
      deltachat-ios/Assets.xcassets/ic_done_all_black_36dp/ios/ic_done_all_36pt.imageset/ic_done_all_36pt_2x.png
  3. BIN
      deltachat-ios/Assets.xcassets/ic_done_all_black_36dp/ios/ic_done_all_36pt.imageset/ic_done_all_36pt_3x.png
  4. BIN
      deltachat-ios/Assets.xcassets/ic_done_black_36dp/ios/ic_done_36pt.imageset/ic_done_36pt.png
  5. BIN
      deltachat-ios/Assets.xcassets/ic_done_black_36dp/ios/ic_done_36pt.imageset/ic_done_36pt_2x.png
  6. BIN
      deltachat-ios/Assets.xcassets/ic_done_black_36dp/ios/ic_done_36pt.imageset/ic_done_36pt_3x.png
  7. BIN
      deltachat-ios/Assets.xcassets/ic_error_black_36dp/ios/ic_error_36pt.imageset/ic_error_36pt.png
  8. BIN
      deltachat-ios/Assets.xcassets/ic_error_black_36dp/ios/ic_error_36pt.imageset/ic_error_36pt_2x.png
  9. BIN
      deltachat-ios/Assets.xcassets/ic_error_black_36dp/ios/ic_error_36pt.imageset/ic_error_36pt_3x.png
  10. BIN
      deltachat-ios/Assets.xcassets/ic_hourglass_empty_black_36dp/ios/ic_hourglass_empty_36pt.imageset/ic_hourglass_empty_36pt.png
  11. BIN
      deltachat-ios/Assets.xcassets/ic_hourglass_empty_black_36dp/ios/ic_hourglass_empty_36pt.imageset/ic_hourglass_empty_36pt_2x.png
  12. BIN
      deltachat-ios/Assets.xcassets/ic_hourglass_empty_black_36dp/ios/ic_hourglass_empty_36pt.imageset/ic_hourglass_empty_36pt_3x.png
  13. 32 24
      deltachat-ios/Controller/ChatViewController.swift
  14. 1 1
      deltachat-ios/Extensions/UIImage+Extension.swift
  15. 4 8
      deltachat-ios/View/ContactCell.swift

BIN
deltachat-ios/Assets.xcassets/ic_done_all_black_36dp/ios/ic_done_all_36pt.imageset/ic_done_all_36pt.png


BIN
deltachat-ios/Assets.xcassets/ic_done_all_black_36dp/ios/ic_done_all_36pt.imageset/ic_done_all_36pt_2x.png


BIN
deltachat-ios/Assets.xcassets/ic_done_all_black_36dp/ios/ic_done_all_36pt.imageset/ic_done_all_36pt_3x.png


BIN
deltachat-ios/Assets.xcassets/ic_done_black_36dp/ios/ic_done_36pt.imageset/ic_done_36pt.png


BIN
deltachat-ios/Assets.xcassets/ic_done_black_36dp/ios/ic_done_36pt.imageset/ic_done_36pt_2x.png


BIN
deltachat-ios/Assets.xcassets/ic_done_black_36dp/ios/ic_done_36pt.imageset/ic_done_36pt_3x.png


BIN
deltachat-ios/Assets.xcassets/ic_error_black_36dp/ios/ic_error_36pt.imageset/ic_error_36pt.png


BIN
deltachat-ios/Assets.xcassets/ic_error_black_36dp/ios/ic_error_36pt.imageset/ic_error_36pt_2x.png


BIN
deltachat-ios/Assets.xcassets/ic_error_black_36dp/ios/ic_error_36pt.imageset/ic_error_36pt_3x.png


BIN
deltachat-ios/Assets.xcassets/ic_hourglass_empty_black_36dp/ios/ic_hourglass_empty_36pt.imageset/ic_hourglass_empty_36pt.png


BIN
deltachat-ios/Assets.xcassets/ic_hourglass_empty_black_36dp/ios/ic_hourglass_empty_36pt.imageset/ic_hourglass_empty_36pt_2x.png


BIN
deltachat-ios/Assets.xcassets/ic_hourglass_empty_black_36dp/ios/ic_hourglass_empty_36pt.imageset/ic_hourglass_empty_36pt_3x.png


+ 32 - 24
deltachat-ios/Controller/ChatViewController.swift

@@ -797,30 +797,7 @@ extension ChatViewController: MessagesDataSource {
                 attachPadlock(to: text)
             }
 
-            // TODO: this should be replaced by the respective icons,
-            // for accessibility, the a11y strings should be added
-            var stateDescription: String
-            switch Int32(m.state) {
-            case DC_STATE_OUT_PENDING:
-                stateDescription = "Pending"
-            case DC_STATE_OUT_DELIVERED:
-                stateDescription = "Sent"
-            case DC_STATE_OUT_MDN_RCVD:
-                stateDescription = "Read"
-            case DC_STATE_OUT_FAILED:
-                stateDescription = "Failed"
-            default:
-                stateDescription = "Unknown"
-            }
-
-            text.append(NSAttributedString(
-                string: " - " + stateDescription,
-                attributes: [
-                    .font: UIFont.systemFont(ofSize: 12),
-                    .foregroundColor: DcColors.defaultTextColor,
-                ]
-            ))
-
+            attachSendingState(m.state, to: text)
             return text
         }
 
@@ -848,6 +825,37 @@ extension ChatViewController: MessagesDataSource {
         text.append(imageString)
     }
 
+    private func attachSendingState(_ state: Int, to text: NSMutableAttributedString) {
+        let imageAttachment = NSTextAttachment()
+        var offset = -4
+
+
+        switch Int32(state) {
+        case DC_STATE_OUT_PENDING, DC_STATE_OUT_PREPARING:
+            imageAttachment.image = #imageLiteral(resourceName: "ic_hourglass_empty_36pt").scaleDownImage(toMax: 16)
+            imageAttachment.image?.accessibilityIdentifier = String.localized("a11y_delivery_status_sending")
+            offset = -2
+        case DC_STATE_OUT_DELIVERED:
+            imageAttachment.image = #imageLiteral(resourceName: "ic_done_36pt").scaleDownImage(toMax: 18)
+            imageAttachment.image?.accessibilityIdentifier = String.localized("a11y_delivery_status_delivered")
+        case DC_STATE_OUT_MDN_RCVD:
+            imageAttachment.image = #imageLiteral(resourceName: "ic_done_all_36pt").scaleDownImage(toMax: 18)
+            imageAttachment.image?.accessibilityIdentifier = String.localized("a11y_delivery_status_read")
+            text.append(NSAttributedString(string: " "))
+        case DC_STATE_OUT_FAILED:
+            imageAttachment.image = #imageLiteral(resourceName: "ic_error_36pt").scaleDownImage(toMax: 16)
+            imageAttachment.image?.accessibilityIdentifier = String.localized("a11y_delivery_status_error")
+            offset = -2
+        default:
+            imageAttachment.image = nil
+        }
+
+        let imageString = NSMutableAttributedString(attachment: imageAttachment)
+        imageString.addAttributes([.baselineOffset: offset],
+                                  range: NSRange(location: 0, length: 1))
+        text.append(imageString)
+    }
+
     func updateMessage(_ messageId: Int) {
         if let index = messageList.firstIndex(where: { $0.id == messageId }) {
             dc_markseen_msgs(mailboxPointer, UnsafePointer([UInt32(messageId)]), 1)

+ 1 - 1
deltachat-ios/Extensions/UIImage+Extension.swift

@@ -64,7 +64,7 @@ extension UIImage {
 
     func scaleDownImage(toMax: CGFloat) -> UIImage? {
         let rect = getResizedRectangle(toMax: Float(toMax))
-        UIGraphicsBeginImageContextWithOptions(rect.size, false, 1.0)
+        UIGraphicsBeginImageContextWithOptions(rect.size, false, 0.0)
         draw(in: rect)
         let newImage = UIGraphicsGetImageFromCurrentImageContext()
         UIGraphicsEndImageContext()

+ 4 - 8
deltachat-ios/View/ContactCell.swift

@@ -187,17 +187,13 @@ class ContactCell: UITableViewCell {
         } else {
             switch Int32(status) {
             case DC_STATE_OUT_PENDING, DC_STATE_OUT_PREPARING:
-                deliveryStatusIndicator.image = #imageLiteral(resourceName: "ic_hourglass_empty_36pt").withRenderingMode(.alwaysTemplate)
-                deliveryStatusIndicator.tintColor = UIColor.black.withAlphaComponent(0.5)
+                deliveryStatusIndicator.image = #imageLiteral(resourceName: "ic_hourglass_empty_36pt")
             case DC_STATE_OUT_DELIVERED:
-                deliveryStatusIndicator.image = #imageLiteral(resourceName: "ic_done_36pt").withRenderingMode(.alwaysTemplate)
-                deliveryStatusIndicator.tintColor = DcColors.checkmarkGreen
+                deliveryStatusIndicator.image = #imageLiteral(resourceName: "ic_done_36pt")
             case DC_STATE_OUT_FAILED:
-                deliveryStatusIndicator.image = #imageLiteral(resourceName: "ic_error_36pt").withRenderingMode(.alwaysTemplate)
-                deliveryStatusIndicator.tintColor = UIColor.red
+                deliveryStatusIndicator.image = #imageLiteral(resourceName: "ic_error_36pt")
             case DC_STATE_OUT_MDN_RCVD:
-                deliveryStatusIndicator.image = #imageLiteral(resourceName: "ic_done_all_36pt").withRenderingMode(.alwaysTemplate)
-                deliveryStatusIndicator.tintColor = DcColors.checkmarkGreen
+                deliveryStatusIndicator.image = #imageLiteral(resourceName: "ic_done_all_36pt")
             default:
                 deliveryStatusIndicator.image = nil
             }