Prevent live text button from showing below gallery bottom controls

This commit is contained in:
Shadowfacts 2025-02-05 11:30:27 -05:00
parent 64c377c663
commit fabb5cd257
5 changed files with 42 additions and 0 deletions

View File

@ -82,6 +82,10 @@ class AttachmentWrapperGalleryContentViewController: UIViewController, GalleryCo
} }
} }
func setInsetForBottomControls(_ inset: CGFloat) {
wrapped.setInsetForBottomControls(inset)
}
func galleryContentDidAppear() { func galleryContentDidAppear() {
wrapped.galleryContentDidAppear() wrapped.galleryContentDidAppear()
} }

View File

@ -107,6 +107,13 @@ open class ImageGalleryContentViewController: UIViewController, GalleryContentVi
analysisInteraction.setSupplementaryInterfaceHidden(!visible, animated: animated) analysisInteraction.setSupplementaryInterfaceHidden(!visible, animated: animated)
} }
} }
public func setInsetForBottomControls(_ inset: CGFloat) {
if #available(iOS 16.0, macCatalyst 17.0, *),
let analysisInteraction {
analysisInteraction.supplementaryInterfaceContentInsets = UIEdgeInsets(top: 0, left: 0, bottom: inset, right: 0)
}
}
} }
@available(iOS 16.0, macCatalyst 17.0, *) @available(iOS 16.0, macCatalyst 17.0, *)

View File

@ -31,6 +31,14 @@ public class LoadingGalleryContentViewController: UIViewController, GalleryConte
wrapped?.presentationAnimation ?? .fade wrapped?.presentationAnimation ?? .fade
} }
public var hideControlsOnZoom: Bool {
wrapped?.hideControlsOnZoom ?? true
}
public var showBelowSafeArea: Bool {
wrapped?.showBelowSafeArea ?? true
}
public init(caption: String?, provider: @escaping () async -> (any GalleryContentViewController)?) { public init(caption: String?, provider: @escaping () async -> (any GalleryContentViewController)?) {
self.fallbackCaption = caption self.fallbackCaption = caption
self.provider = provider self.provider = provider
@ -105,6 +113,10 @@ public class LoadingGalleryContentViewController: UIViewController, GalleryConte
wrapped?.setControlsVisible(visible, animated: animated, dueToUserInteraction: dueToUserInteraction) wrapped?.setControlsVisible(visible, animated: animated, dueToUserInteraction: dueToUserInteraction)
} }
public func setInsetForBottomControls(_ inset: CGFloat) {
wrapped?.setInsetForBottomControls(inset)
}
public func galleryContentDidAppear() { public func galleryContentDidAppear() {
wrapped?.galleryContentDidAppear() wrapped?.galleryContentDidAppear()
} }
@ -113,4 +125,8 @@ public class LoadingGalleryContentViewController: UIViewController, GalleryConte
wrapped?.galleryContentWillDisappear() wrapped?.galleryContentWillDisappear()
} }
public func galleryShouldBeginInteractiveDismiss() -> Bool {
wrapped?.galleryShouldBeginInteractiveDismiss() ?? true
}
} }

View File

@ -22,6 +22,7 @@ public protocol GalleryContentViewController: UIViewController {
func shouldHideControls() -> Bool func shouldHideControls() -> Bool
func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool)
func setInsetForBottomControls(_ inset: CGFloat)
func galleryContentDidAppear() func galleryContentDidAppear()
func galleryContentWillDisappear() func galleryContentWillDisappear()
func galleryShouldBeginInteractiveDismiss() -> Bool func galleryShouldBeginInteractiveDismiss() -> Bool
@ -59,6 +60,9 @@ public extension GalleryContentViewController {
func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) { func setControlsVisible(_ visible: Bool, animated: Bool, dueToUserInteraction: Bool) {
} }
func setInsetForBottomControls(_ inset: CGFloat) {
}
func galleryContentDidAppear() { func galleryContentDidAppear() {
} }

View File

@ -391,6 +391,17 @@ class GalleryItemViewController: UIViewController {
scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: bottomInset, right: 0) scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: bottomInset, right: 0)
scrollView.verticalScrollIndicatorInsets = UIEdgeInsets(top: 0, left: 0, bottom: bottomIndicatorInset, right: 0) scrollView.verticalScrollIndicatorInsets = UIEdgeInsets(top: 0, left: 0, bottom: bottomIndicatorInset, right: 0)
let contentBottomControlsInset: CGFloat
if content.showBelowSafeArea,
controlsVisible,
let bottomControlsView {
let contentFrameInSelf = content.view.convert(content.view.bounds, to: view)
contentBottomControlsInset = max(0, contentFrameInSelf.maxY - bottomControlsView.frame.minY - view.safeAreaInsets.bottom)
} else {
contentBottomControlsInset = 0
}
content.setInsetForBottomControls(contentBottomControlsInset)
centerContent() centerContent()
} }