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

replace Option enum with simple boolean flag

cyberta 4 роки тому
батько
коміт
e9b52056d3

+ 2 - 7
deltachat-ios/Controller/ContextMenuController.swift

@@ -150,7 +150,7 @@ class ContextMenuProvider {
                 image: image,
                 handler: { _ in item.onPerform?(indexPath) }
             )
-            if item.option == .delete {
+            if item.isDestructive {
                 action.attributes = [.destructive]
             }
             children.append(action)
@@ -176,10 +176,6 @@ class ContextMenuProvider {
         }.first?.onPerform?(indexPath)
     }
 
-    enum Option {
-        case showInChat
-        case delete
-    }
 }
 
 extension ContextMenuProvider {
@@ -187,9 +183,8 @@ extension ContextMenuProvider {
     struct ContextMenuItem {
         var title: String
         var imageNames: (ImageSystemName, ImageSystemName?) // (0,1) -> define 1 as backup if 0 is not available in iOS 13
-        let option: Option
+        let isDestructive: Bool
         var action: Selector
         var onPerform: ((IndexPath) -> Void)?
     }
 }
-

+ 2 - 2
deltachat-ios/Controller/DocumentGalleryController.swift

@@ -26,7 +26,7 @@ class DocumentGalleryController: UIViewController {
         let deleteItem = ContextMenuProvider.ContextMenuItem(
             title: String.localized("delete"),
             imageNames: ("trash", nil),
-            option: .delete,
+            isDestructive: true,
             action: #selector(DocumentGalleryFileCell.itemDelete(_:)),
             onPerform: { [weak self] indexPath in
                 self?.askToDeleteItem(at: indexPath)
@@ -35,7 +35,7 @@ class DocumentGalleryController: UIViewController {
         let showInChatItem = ContextMenuProvider.ContextMenuItem(
             title: String.localized("show_in_chat"),
             imageNames: ("doc.text.magnifyingglass", nil),
-            option: .showInChat,
+            isDestructive: false,
             action: #selector(DocumentGalleryFileCell.showInChat(_:)),
             onPerform: { [weak self] indexPath in
                 self?.redirectToMessage(of: indexPath)

+ 2 - 2
deltachat-ios/Controller/GalleryViewController.swift

@@ -51,7 +51,7 @@ class GalleryViewController: UIViewController {
         let deleteItem = ContextMenuProvider.ContextMenuItem(
             title: String.localized("delete"),
             imageNames: ("trash", nil),
-            option: .delete,
+            isDestructive: true,
             action: #selector(GalleryCell.itemDelete(_:)),
             onPerform: { [weak self] indexPath in
                 self?.askToDeleteItem(at: indexPath)
@@ -60,7 +60,7 @@ class GalleryViewController: UIViewController {
         let showInChatItem = ContextMenuProvider.ContextMenuItem(
             title: String.localized("show_in_chat"),
             imageNames: ("doc.text.magnifyingglass", nil),
-            option: .showInChat,
+            isDestructive: false,
             action: #selector(GalleryCell.showInChat(_:)),
             onPerform: { [weak self] indexPath in
                 self?.redirectToMessage(of: indexPath)