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
|
// ComposeUI
|
||||||
//
|
//
|
||||||
// Created by Shadowfacts on 11/22/24.
|
// Created by Shadowfacts on 11/22/24.
|
||||||
@ -8,7 +8,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import GalleryVC
|
import GalleryVC
|
||||||
|
|
||||||
class EditAttachmentWrapperGalleryContentViewController: UIViewController, GalleryContentViewController {
|
class AttachmentWrapperGalleryContentViewController: UIViewController, GalleryContentViewController {
|
||||||
let draftAttachment: DraftAttachment
|
let draftAttachment: DraftAttachment
|
||||||
let wrapped: any GalleryContentViewController
|
let wrapped: any GalleryContentViewController
|
||||||
|
|
||||||
@ -94,6 +94,15 @@ class EditAttachmentWrapperGalleryContentViewController: UIViewController, Galle
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func galleryShouldBeginInteractiveDismiss() -> Bool {
|
||||||
|
if editDescriptionViewController.textView.isFirstResponder {
|
||||||
|
editDescriptionViewController.textView.resignFirstResponder()
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class EditAttachmentDescriptionViewController: UIViewController {
|
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? {
|
func galleryContentTransitionSourceView(forItemAt index: Int) -> UIView? {
|
||||||
|
@ -23,6 +23,7 @@ public protocol GalleryContentViewController: UIViewController {
|
|||||||
func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool)
|
func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool)
|
||||||
func galleryContentDidAppear()
|
func galleryContentDidAppear()
|
||||||
func galleryContentWillDisappear()
|
func galleryContentWillDisappear()
|
||||||
|
func galleryShouldBeginInteractiveDismiss() -> Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension GalleryContentViewController {
|
public extension GalleryContentViewController {
|
||||||
@ -58,6 +59,10 @@ public extension GalleryContentViewController {
|
|||||||
|
|
||||||
func galleryContentWillDisappear() {
|
func galleryContentWillDisappear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func galleryShouldBeginInteractiveDismiss() -> Bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GalleryContentPresentationAnimation {
|
public enum GalleryContentPresentationAnimation {
|
||||||
|
@ -106,12 +106,8 @@ extension GalleryDismissInteraction: UIGestureRecognizerDelegate {
|
|||||||
let itemVC = viewController.currentItemViewController
|
let itemVC = viewController.currentItemViewController
|
||||||
if viewController.galleryDataSource.galleryContentTransitionSourceView(forItemAt: itemVC.itemIndex) == nil {
|
if viewController.galleryDataSource.galleryContentTransitionSourceView(forItemAt: itemVC.itemIndex) == nil {
|
||||||
return false
|
return false
|
||||||
} else if itemVC.scrollView.zoomScale > itemVC.scrollView.minimumZoomScale {
|
|
||||||
return false
|
|
||||||
} else if !itemVC.scrollAndZoomEnabled {
|
|
||||||
return false
|
|
||||||
} else {
|
} else {
|
||||||
return true
|
return itemVC.shouldBeginInteractiveDismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -528,6 +528,16 @@ class GalleryItemViewController: UIViewController {
|
|||||||
present(activityVC, animated: true)
|
present(activityVC, animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shouldBeginInteractiveDismiss() -> Bool {
|
||||||
|
if scrollView.zoomScale > scrollView.minimumZoomScale {
|
||||||
|
false
|
||||||
|
} else if !scrollAndZoomEnabled {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
content.galleryShouldBeginInteractiveDismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension GalleryItemViewController: GalleryContentViewControllerContainer {
|
extension GalleryItemViewController: GalleryContentViewControllerContainer {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user