Disallow interactive gallery dismissal while editing attachment description
This commit is contained in:
parent
4fb7cacf31
commit
370b589a6b
@ -1,5 +1,5 @@
|
||||
//
|
||||
// EditAttachmentWrapperGalleryContentViewController.swift
|
||||
// AttachmentWrapperGalleryContentViewController.swift
|
||||
// ComposeUI
|
||||
//
|
||||
// Created by Shadowfacts on 11/22/24.
|
||||
@ -8,7 +8,7 @@
|
||||
import UIKit
|
||||
import GalleryVC
|
||||
|
||||
class EditAttachmentWrapperGalleryContentViewController: UIViewController, GalleryContentViewController {
|
||||
class AttachmentWrapperGalleryContentViewController: UIViewController, GalleryContentViewController {
|
||||
let draftAttachment: DraftAttachment
|
||||
let wrapped: any GalleryContentViewController
|
||||
|
||||
@ -94,6 +94,15 @@ class EditAttachmentWrapperGalleryContentViewController: UIViewController, Galle
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func galleryShouldBeginInteractiveDismiss() -> Bool {
|
||||
if editDescriptionViewController.textView.isFirstResponder {
|
||||
editDescriptionViewController.textView.resignFirstResponder()
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class EditAttachmentDescriptionViewController: UIViewController {
|
@ -60,7 +60,7 @@ struct AttachmentsGalleryDataSource: GalleryDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
return EditAttachmentWrapperGalleryContentViewController(draftAttachment: attachment, wrapped: content)
|
||||
return AttachmentWrapperGalleryContentViewController(draftAttachment: attachment, wrapped: content)
|
||||
}
|
||||
|
||||
func galleryContentTransitionSourceView(forItemAt index: Int) -> UIView? {
|
||||
|
@ -23,6 +23,7 @@ public protocol GalleryContentViewController: UIViewController {
|
||||
func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool)
|
||||
func galleryContentDidAppear()
|
||||
func galleryContentWillDisappear()
|
||||
func galleryShouldBeginInteractiveDismiss() -> Bool
|
||||
}
|
||||
|
||||
public extension GalleryContentViewController {
|
||||
@ -58,6 +59,10 @@ public extension GalleryContentViewController {
|
||||
|
||||
func galleryContentWillDisappear() {
|
||||
}
|
||||
|
||||
func galleryShouldBeginInteractiveDismiss() -> Bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
public enum GalleryContentPresentationAnimation {
|
||||
|
@ -106,12 +106,8 @@ extension GalleryDismissInteraction: UIGestureRecognizerDelegate {
|
||||
let itemVC = viewController.currentItemViewController
|
||||
if viewController.galleryDataSource.galleryContentTransitionSourceView(forItemAt: itemVC.itemIndex) == nil {
|
||||
return false
|
||||
} else if itemVC.scrollView.zoomScale > itemVC.scrollView.minimumZoomScale {
|
||||
return false
|
||||
} else if !itemVC.scrollAndZoomEnabled {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
return itemVC.shouldBeginInteractiveDismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -528,6 +528,16 @@ class GalleryItemViewController: UIViewController {
|
||||
present(activityVC, animated: true)
|
||||
}
|
||||
|
||||
func shouldBeginInteractiveDismiss() -> Bool {
|
||||
if scrollView.zoomScale > scrollView.minimumZoomScale {
|
||||
false
|
||||
} else if !scrollAndZoomEnabled {
|
||||
false
|
||||
} else {
|
||||
content.galleryShouldBeginInteractiveDismiss()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension GalleryItemViewController: GalleryContentViewControllerContainer {
|
||||
|
Loading…
x
Reference in New Issue
Block a user