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

move draft delegate to base class

cyberta 4 жил өмнө
parent
commit
004b2a09d5

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

@@ -1239,7 +1239,8 @@ extension ChatViewController: InputBarAccessoryViewDelegate {
     }
 }
 
-extension ChatViewController: QuotePreviewDelegate, MediaPreviewDelegate {
+extension ChatViewController: DraftPreviewDelegate {
+
     func onCancelQuote() {
         draft.setQuote(quotedMsg: nil)
         configureDraftArea(draft: draft)

+ 9 - 0
deltachat-ios/Chat/Views/DocumentPreview.swift

@@ -0,0 +1,9 @@
+//
+//  DocumentPreview.swift
+//  deltachat-ios
+//
+//  Created by Macci on 02.12.20.
+//  Copyright © 2020 Jonas Reinsch. All rights reserved.
+//
+
+import Foundation

+ 6 - 0
deltachat-ios/Chat/Views/DraftPreview.swift

@@ -2,6 +2,12 @@ import UIKit
 import InputBarAccessoryView
 import DcCore
 
+public protocol DraftPreviewDelegate: class {
+    func onAttachmentAdded()
+    func onCancelAttachment()
+    func onCancelQuote()
+}
+
 public class DraftPreview: UIView, InputItem {
 
     public var inputBarAccessoryView: InputBarAccessoryView?

+ 1 - 6
deltachat-ios/Chat/Views/MediaPreview.swift

@@ -1,13 +1,9 @@
 import UIKit
 import SDWebImage
 
-public protocol MediaPreviewDelegate: class {
-    func onCancelAttachment()
-    func onAttachmentAdded()
-}
 class MediaPreview: DraftPreview {
     var imageWidthConstraint: NSLayoutConstraint?
-    weak var delegate: MediaPreviewDelegate?
+    weak var delegate: DraftPreviewDelegate?
 
     lazy var contentImageView: SDAnimatedImageView = {
         let imageView = SDAnimatedImageView()
@@ -40,7 +36,6 @@ class MediaPreview: DraftPreview {
                     self.delegate?.onAttachmentAdded()
                 }
             })
-
             isHidden = false
         } else {
             isHidden = true

+ 1 - 5
deltachat-ios/Chat/Views/QuotePreview.swift

@@ -2,13 +2,9 @@ import UIKit
 import InputBarAccessoryView
 import DcCore
 
-public protocol QuotePreviewDelegate: class {
-    func onCancelQuote()
-}
-
 public class QuotePreview: DraftPreview {
 
-    public weak var delegate: QuotePreviewDelegate?
+    public weak var delegate: DraftPreviewDelegate?
 
     lazy var quoteView: QuoteView = {
         let view = QuoteView()