Ver código fonte

open media gallery on if user taps on a message containing a attachment

cyberta 4 anos atrás
pai
commit
d1e6da664d
1 arquivos alterados com 15 adições e 1 exclusões
  1. 15 1
      deltachat-ios/Chat/ChatViewControllerNew.swift

+ 15 - 1
deltachat-ios/Chat/ChatViewControllerNew.swift

@@ -121,7 +121,6 @@ class ChatViewControllerNew: UITableViewController {
         tableView.register(NewAudioMessageCell.self, forCellReuseIdentifier: "audio")
         tableView.rowHeight = UITableView.automaticDimension
         tableView.separatorStyle = .none
-        tableView.allowsSelection = false
         super.viewDidLoad()
         if !dcContext.isConfigured() {
             // TODO: display message about nothing being configured
@@ -329,9 +328,24 @@ class ChatViewControllerNew: UITableViewController {
         cell.update(msg: message,
                     messageStyle: configureMessageStyle(for: message, at: indexPath),
                     isAvatarVisible: configureAvatarVisibility(for: message, at: indexPath))
+        cell.selectionStyle = .none
         return cell
     }
 
+    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        let messageId = messageIds[indexPath.row]
+        let message = DcMsg(id: messageId)
+        if let url = message.fileURL {
+            // find all other messages with same message type
+            let previousUrls: [URL] = message.previousMediaURLs()
+            let nextUrls: [URL] = message.nextMediaURLs()
+
+            // these are the files user will be able to swipe trough
+            let mediaUrls: [URL] = previousUrls + [url] + nextUrls
+            showMediaGallery(currentIndex: previousUrls.count, mediaUrls: mediaUrls)
+        }
+    }
+
     func configureAvatarVisibility(for message: DcMsg, at indexPath: IndexPath) -> Bool {
         return !message.isFromCurrentSender && !isNextMessageSameSender(currentMessage: message, at: indexPath)
     }