소스 검색

preview drafted images, gifs and videos

cyberta 4 년 전
부모
커밋
792ecc6dcd
3개의 변경된 파일19개의 추가작업 그리고 1개의 파일을 삭제
  1. 10 0
      deltachat-ios/Chat/ChatViewController.swift
  2. 1 0
      deltachat-ios/Chat/Views/DraftPreview.swift
  3. 8 1
      deltachat-ios/Chat/Views/MediaPreview.swift

+ 10 - 0
deltachat-ios/Chat/ChatViewController.swift

@@ -1217,4 +1217,14 @@ extension ChatViewController: DraftPreviewDelegate {
     func onAttachmentAdded() {
         evaluateInputBar(draft: draft)
     }
+
+    func onAttachmentTapped() {
+        if let attachmentPath = draft.draftAttachment {
+            let attachmentURL = URL(fileURLWithPath: attachmentPath, isDirectory: false)
+            let previewController = PreviewController(type: .single(attachmentURL))
+            let nav = UINavigationController(rootViewController: previewController)
+            nav.modalPresentationStyle = .fullScreen
+            navigationController?.present(nav, animated: true)
+        }
+    }
 }

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

@@ -5,6 +5,7 @@ public protocol DraftPreviewDelegate: class {
     func onAttachmentAdded()
     func onCancelAttachment()
     func onCancelQuote()
+    func onAttachmentTapped()
 }
 
 public class DraftPreview: UIView {

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

@@ -6,12 +6,13 @@ class MediaPreview: DraftPreview {
     var imageWidthConstraint: NSLayoutConstraint?
     weak var delegate: DraftPreviewDelegate?
 
-    lazy var contentImageView: SDAnimatedImageView = {
+    public lazy var contentImageView: SDAnimatedImageView = {
         let imageView = SDAnimatedImageView()
         imageView.translatesAutoresizingMaskIntoConstraints = false
         imageView.contentMode = .scaleAspectFit
         imageView.clipsToBounds = true
         imageView.layer.cornerRadius = 4
+        imageView.isUserInteractionEnabled = true
         return imageView
     }()
 
@@ -25,6 +26,8 @@ class MediaPreview: DraftPreview {
             contentImageView.constraintAlignBottomTo(mainContentView),
             contentImageView.constraintHeightTo(90)
         ])
+        let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped))
+        contentImageView.addGestureRecognizer(gestureRecognizer)
     }
 
     override func configure(draft: DraftModel) {
@@ -75,4 +78,8 @@ class MediaPreview: DraftPreview {
         imageWidthConstraint = contentImageView.widthAnchor.constraint(lessThanOrEqualTo: contentImageView.heightAnchor, multiplier: width / height)
         imageWidthConstraint?.isActive = true
     }
+
+    @objc func imageTapped() {
+        delegate?.onAttachmentTapped()
+    }
 }