Skip to content

Commit

Permalink
Find the page view controller's scroll view recursively.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Feb 7, 2025
1 parent d7e39f1 commit f7e9e60
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TimelineMediaPreviewController: QLPreviewController {

private var navigationBar: UINavigationBar? { view.subviews.first?.subviews.first { $0 is UINavigationBar } as? UINavigationBar }
private var toolbar: UIToolbar? { view.subviews.first?.subviews.last { $0 is UIToolbar } as? UIToolbar }
private var pageScrollView: UIScrollView? { view.subviews.first?.subviews.first?.subviews.first?.subviews.first?.subviews.first?.subviews.first as? UIScrollView }
private var pageScrollView: UIScrollView? { view.firstScrollView() }
private var captionView: UIView { captionHostingController.view }

override var overrideUserInterfaceStyle: UIUserInterfaceStyle {
Expand Down Expand Up @@ -344,6 +344,17 @@ private struct DownloadIndicatorView: View {
}
}

// MARK: - Helpers

private extension UIView {
func firstScrollView() -> UIScrollView? {
for view in subviews {
return view as? UIScrollView ?? view.firstScrollView()
}
return nil
}
}

private extension UISheetPresentationController.Detent {
static func height(_ height: CGFloat) -> UISheetPresentationController.Detent {
.custom { _ in height }
Expand Down

0 comments on commit f7e9e60

Please sign in to comment.