From 5d38abd659270a4d008e33ad67acd0117128f6b1 Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 18 Feb 2022 19:33:12 +0800 Subject: [PATCH] feat: dismiss image preview when tap empty area --- .../Scene/MediaPreview/MediaPreviewViewController.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift index b8355c3a3..ae55134c4 100644 --- a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift +++ b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift @@ -222,7 +222,11 @@ extension MediaPreviewViewController: PageboyViewControllerDelegate { extension MediaPreviewViewController: MediaPreviewImageViewControllerDelegate { func mediaPreviewImageViewController(_ viewController: MediaPreviewImageViewController, tapGestureRecognizerDidTrigger tapGestureRecognizer: UITapGestureRecognizer) { - // do nothing + let location = tapGestureRecognizer.location(in: viewController.previewImageView.imageView) + let isContainsTap = viewController.previewImageView.imageView.frame.contains(location) + + guard !isContainsTap else { return } + dismiss(animated: true, completion: nil) } func mediaPreviewImageViewController(_ viewController: MediaPreviewImageViewController, longPressGestureRecognizerDidTrigger longPressGestureRecognizer: UILongPressGestureRecognizer) {