Ver Fonte

add location streaming indicator to chat list

cyberta há 5 anos atrás
pai
commit
e2ae45eb31

+ 23 - 0
deltachat-ios/Assets.xcassets/ic_location.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "ic_location_on_white_24dp-2.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "ic_location_on_white_24dp-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "ic_location_on_white_24dp.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
deltachat-ios/Assets.xcassets/ic_location.imageset/ic_location_on_white_24dp-1.png


BIN
deltachat-ios/Assets.xcassets/ic_location.imageset/ic_location_on_white_24dp-2.png


BIN
deltachat-ios/Assets.xcassets/ic_location.imageset/ic_location_on_white_24dp.png


+ 1 - 1
deltachat-ios/Controller/ChatListController.swift

@@ -216,7 +216,7 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
 
 
         cell.subtitleLabel.text = result
         cell.subtitleLabel.text = result
         cell.setTimeLabel(summary.timestamp)
         cell.setTimeLabel(summary.timestamp)
-        cell.setStatusIndicators(unreadCount: unreadMessages, status: summary.state, visibility: chat.visibility)
+        cell.setStatusIndicators(unreadCount: unreadMessages, status: summary.state, visibility: chat.visibility, isLocationStreaming: chat.isSendingLocations)
         return cell
         return cell
     }
     }
 
 

+ 4 - 0
deltachat-ios/DC/Wrapper.swift

@@ -564,6 +564,10 @@ class DcChat {
         }
         }
         return nil
         return nil
         }()
         }()
+
+    var isSendingLocations: Bool {
+        return dc_chat_is_sending_locations(chatPointer) == 1
+    }
 }
 }
 
 
 class DcArray {
 class DcArray {

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

@@ -15,7 +15,7 @@ class ContactCell: UITableViewCell {
     private let imgSize: CGFloat = 20
     private let imgSize: CGFloat = 20
 
 
     lazy var toplineStackView: UIStackView = {
     lazy var toplineStackView: UIStackView = {
-        let stackView = UIStackView(arrangedSubviews: [titleLabel, pinnedIndicator, timeLabel])
+        let stackView = UIStackView(arrangedSubviews: [titleLabel, pinnedIndicator, timeLabel, locationStreamingIndicator])
         stackView.axis = .horizontal
         stackView.axis = .horizontal
         stackView.spacing = 4
         stackView.spacing = 4
         return stackView
         return stackView
@@ -66,6 +66,17 @@ class ContactCell: UITableViewCell {
         return label
         return label
     }()
     }()
 
 
+    private let locationStreamingIndicator: UIImageView = {
+        let view = UIImageView()
+        view.translatesAutoresizingMaskIntoConstraints = false
+        view.heightAnchor.constraint(equalToConstant: 16).isActive = true
+        view.widthAnchor.constraint(equalToConstant: 16).isActive = true
+        view.tintColor = DcColors.checkmarkGreen
+        view.image = #imageLiteral(resourceName: "ic_location").withRenderingMode(.alwaysTemplate)
+        view.isHidden = true
+        return view
+    }()
+
     let subtitleLabel: UILabel = {
     let subtitleLabel: UILabel = {
         let label = UILabel()
         let label = UILabel()
         label.font = UIFont.systemFont(ofSize: 14)
         label.font = UIFont.systemFont(ofSize: 14)
@@ -171,7 +182,7 @@ class ContactCell: UITableViewCell {
         avatar.setName(name)
         avatar.setName(name)
     }
     }
 
 
-    func setStatusIndicators(unreadCount: Int, status: Int, visibility: Int32) {
+    func setStatusIndicators(unreadCount: Int, status: Int, visibility: Int32, isLocationStreaming: Bool) {
         if visibility==DC_CHAT_VISIBILITY_ARCHIVED {
         if visibility==DC_CHAT_VISIBILITY_ARCHIVED {
             pinnedIndicator.isHidden = true
             pinnedIndicator.isHidden = true
             unreadMessageCounter.isHidden = true
             unreadMessageCounter.isHidden = true
@@ -207,6 +218,8 @@ class ContactCell: UITableViewCell {
             deliveryStatusIndicator.isHidden = deliveryStatusIndicator.image == nil ? true : false
             deliveryStatusIndicator.isHidden = deliveryStatusIndicator.image == nil ? true : false
             archivedIndicator.isHidden = true
             archivedIndicator.isHidden = true
         }
         }
+
+        locationStreamingIndicator.isHidden = !isLocationStreaming
     }
     }
 
 
     func setTimeLabel(_ timestamp: Int64?) {
     func setTimeLabel(_ timestamp: Int64?) {
@@ -254,14 +267,14 @@ class ContactCell: UITableViewCell {
             }
             }
             setVerified(isVerified: chat.isVerified)
             setVerified(isVerified: chat.isVerified)
             setTimeLabel(chatData.summary.timestamp)
             setTimeLabel(chatData.summary.timestamp)
-            setStatusIndicators(unreadCount: chatData.unreadMessages, status: chatData.summary.state, visibility: chat.visibility)
+            setStatusIndicators(unreadCount: chatData.unreadMessages, status: chatData.summary.state, visibility: chat.visibility, isLocationStreaming: chat.isSendingLocations)
 
 
         case .CONTACT(let contactData):
         case .CONTACT(let contactData):
             let contact = DcContact(id: contactData.contactId)
             let contact = DcContact(id: contactData.contactId)
             titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
             titleLabel.attributedText = cellViewModel.title.boldAt(indexes: cellViewModel.titleHighlightIndexes, fontSize: titleLabel.font.pointSize)
             avatar.setName(cellViewModel.title)
             avatar.setName(cellViewModel.title)
             avatar.setColor(contact.color)
             avatar.setColor(contact.color)
-            setStatusIndicators(unreadCount: 0, status: 0, visibility: 0)
+            setStatusIndicators(unreadCount: 0, status: 0, visibility: 0, isLocationStreaming: false)
         }
         }
     }
     }
 }
 }