Переглянути джерело

don't react on taps on texts, Images etc. if editing mode is enabled

cyberta 4 роки тому
батько
коміт
052073eb67
1 змінених файлів з 20 додано та 2 видалено
  1. 20 2
      deltachat-ios/Chat/ChatViewController.swift

+ 20 - 2
deltachat-ios/Chat/ChatViewController.swift

@@ -1191,12 +1191,25 @@ class ChatViewController: UITableViewController {
         }
         }
         return false
         return false
     }
     }
+
+    func handleSelection(indexPath: IndexPath) -> Bool {
+        if tableView.isEditing {
+            if (tableView.indexPathsForSelectedRows?.contains(indexPath) ?? false) {
+                tableView.deselectRow(at: indexPath, animated: false)
+            } else {
+                tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
+            }
+            return true
+        }
+        return false
+    }
 }
 }
 
 
 // MARK: - BaseMessageCellDelegate
 // MARK: - BaseMessageCellDelegate
 extension ChatViewController: BaseMessageCellDelegate {
 extension ChatViewController: BaseMessageCellDelegate {
 
 
     @objc func quoteTapped(indexPath: IndexPath) {
     @objc func quoteTapped(indexPath: IndexPath) {
+        if handleSelection(indexPath: indexPath) { return }
         _ = handleUIMenu()
         _ = handleUIMenu()
         let msg = DcMsg(id: messageIds[indexPath.row])
         let msg = DcMsg(id: messageIds[indexPath.row])
         if let quoteMsg = msg.quoteMessage {
         if let quoteMsg = msg.quoteMessage {
@@ -1205,7 +1218,10 @@ extension ChatViewController: BaseMessageCellDelegate {
     }
     }
 
 
     @objc func textTapped(indexPath: IndexPath) {
     @objc func textTapped(indexPath: IndexPath) {
-        if handleUIMenu() { return }
+        if handleUIMenu() || handleSelection(indexPath: indexPath) {
+            return
+        }
+
         let message = DcMsg(id: messageIds[indexPath.row])
         let message = DcMsg(id: messageIds[indexPath.row])
         if message.isSetupMessage {
         if message.isSetupMessage {
             didTapAsm(msg: message, orgText: "")
             didTapAsm(msg: message, orgText: "")
@@ -1235,7 +1251,9 @@ extension ChatViewController: BaseMessageCellDelegate {
     }
     }
 
 
     @objc func imageTapped(indexPath: IndexPath) {
     @objc func imageTapped(indexPath: IndexPath) {
-        if handleUIMenu() { return }
+        if handleUIMenu() || handleSelection(indexPath: indexPath) {
+            return
+        }
         showMediaGalleryFor(indexPath: indexPath)
         showMediaGalleryFor(indexPath: indexPath)
     }
     }