Compare commits
No commits in common. "86e1403230fc12272038389add577c19ba968902" and "da4787946da1841a5d2011e9fa574b17a78f2bb0" have entirely different histories.
86e1403230
...
da4787946d
@ -60,7 +60,7 @@ struct AttachmentsGalleryDataSource: GalleryDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
return AttachmentWrapperGalleryContentViewController(draftAttachment: attachment, wrapped: content)
|
||||
return EditAttachmentWrapperGalleryContentViewController(draftAttachment: attachment, wrapped: content)
|
||||
}
|
||||
|
||||
func galleryContentTransitionSourceView(forItemAt index: Int) -> UIView? {
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// AttachmentWrapperGalleryContentViewController.swift
|
||||
// EditAttachmentWrapperGalleryContentViewController.swift
|
||||
// ComposeUI
|
||||
//
|
||||
// Created by Shadowfacts on 11/22/24.
|
||||
@ -8,7 +8,7 @@
|
||||
import UIKit
|
||||
import GalleryVC
|
||||
|
||||
class AttachmentWrapperGalleryContentViewController: UIViewController, GalleryContentViewController {
|
||||
class EditAttachmentWrapperGalleryContentViewController: UIViewController, GalleryContentViewController {
|
||||
let draftAttachment: DraftAttachment
|
||||
let wrapped: any GalleryContentViewController
|
||||
|
||||
@ -76,16 +76,6 @@ class AttachmentWrapperGalleryContentViewController: UIViewController, GalleryCo
|
||||
if !visible {
|
||||
editDescriptionViewController.textView?.resignFirstResponder()
|
||||
}
|
||||
if #available(iOS 16.0, macCatalyst 17.0, *),
|
||||
let wrapped = wrapped as? ImageGalleryContentViewController,
|
||||
let interaction = wrapped.analysisInteraction {
|
||||
if visible {
|
||||
let bottom = editDescriptionViewController.view.bounds.height - editDescriptionViewController.view.keyboardLayoutGuide.layoutFrame.height
|
||||
interaction.supplementaryInterfaceContentInsets = UIEdgeInsets(top: 0, left: 0, bottom: bottom, right: 0)
|
||||
} else {
|
||||
interaction.supplementaryInterfaceContentInsets = .zero
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func galleryContentDidAppear() {
|
||||
@ -104,15 +94,6 @@ class AttachmentWrapperGalleryContentViewController: UIViewController, GalleryCo
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func galleryShouldBeginInteractiveDismiss() -> Bool {
|
||||
if editDescriptionViewController.textView.isFirstResponder {
|
||||
editDescriptionViewController.textView.resignFirstResponder()
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class EditAttachmentDescriptionViewController: UIViewController {
|
@ -25,7 +25,7 @@ open class ImageGalleryContentViewController: UIViewController, GalleryContentVi
|
||||
private static let analyzer = ImageAnalyzer()
|
||||
private var _analysisInteraction: AnyObject?
|
||||
@available(iOS 16.0, macCatalyst 17.0, *)
|
||||
public var analysisInteraction: ImageAnalysisInteraction? { _analysisInteraction as? ImageAnalysisInteraction }
|
||||
private var analysisInteraction: ImageAnalysisInteraction? { _analysisInteraction as? ImageAnalysisInteraction }
|
||||
|
||||
public init(image: UIImage, caption: String?, gifController: GIFController?) {
|
||||
self.caption = caption
|
||||
|
@ -23,7 +23,6 @@ public protocol GalleryContentViewController: UIViewController {
|
||||
func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool)
|
||||
func galleryContentDidAppear()
|
||||
func galleryContentWillDisappear()
|
||||
func galleryShouldBeginInteractiveDismiss() -> Bool
|
||||
}
|
||||
|
||||
public extension GalleryContentViewController {
|
||||
@ -59,10 +58,6 @@ public extension GalleryContentViewController {
|
||||
|
||||
func galleryContentWillDisappear() {
|
||||
}
|
||||
|
||||
func galleryShouldBeginInteractiveDismiss() -> Bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
public enum GalleryContentPresentationAnimation {
|
||||
|
@ -106,8 +106,12 @@ 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 itemVC.shouldBeginInteractiveDismiss()
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -228,10 +228,6 @@ class GalleryItemViewController: UIViewController {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillUpdate), name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillUpdate), name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillUpdate), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
|
||||
|
||||
if #available(iOS 17.0, *) {
|
||||
view.keyboardLayoutGuide.usesBottomSafeArea = false
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func keyboardWillUpdate() {
|
||||
@ -358,17 +354,7 @@ class GalleryItemViewController: UIViewController {
|
||||
return
|
||||
}
|
||||
|
||||
// Post-iOS 17, we can ask the keyboard layout guide to ignore the bottom safe area.
|
||||
// Pre, we have to do that ourselves.
|
||||
let keyboardHeight: CGFloat
|
||||
if #available(iOS 17.0, *) {
|
||||
keyboardHeight = view.keyboardLayoutGuide.layoutFrame.height
|
||||
} else {
|
||||
let bottomSafeArea = view.bounds.height - view.safeAreaLayoutGuide.layoutFrame.maxY
|
||||
let rawKeyboardHeight = view.keyboardLayoutGuide.layoutFrame.height
|
||||
keyboardHeight = abs(rawKeyboardHeight - bottomSafeArea) < 1 ? 0 : rawKeyboardHeight
|
||||
}
|
||||
let heightScale = (view.bounds.height - keyboardHeight) / content.contentSize.height
|
||||
let heightScale = (view.bounds.height - view.keyboardLayoutGuide.layoutFrame.height) / content.contentSize.height
|
||||
let widthScale = view.bounds.width / content.contentSize.width
|
||||
let minScale = min(widthScale, heightScale)
|
||||
let maxScale = minScale >= 1 ? minScale + 2 : 2
|
||||
@ -528,16 +514,6 @@ 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