Fix status bar not hiding
This commit is contained in:
parent
73ab213631
commit
07f8d8e89e
|
@ -2,6 +2,8 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<true/>
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER).activity.activate-account</string>
|
||||
|
|
|
@ -12,6 +12,14 @@ class AppNavigationController: UINavigationController, UINavigationControllerDel
|
|||
private var statusBarBlockingView: UIView!
|
||||
|
||||
static let panRecognizerName = "AppNavPanRecognizer"
|
||||
|
||||
override var childForStatusBarHidden: UIViewController? {
|
||||
topViewController
|
||||
}
|
||||
|
||||
override var childForStatusBarStyle: UIViewController? {
|
||||
topViewController
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
@ -44,7 +52,12 @@ class AppNavigationController: UINavigationController, UINavigationControllerDel
|
|||
}
|
||||
|
||||
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
|
||||
statusBarBlockingView.isHidden = viewController.prefersStatusBarHidden
|
||||
statusBarBlockingView.layer.opacity = viewController.prefersStatusBarHidden ? 0 : 1
|
||||
}
|
||||
|
||||
override func setNeedsStatusBarAppearanceUpdate() {
|
||||
super.setNeedsStatusBarAppearanceUpdate()
|
||||
statusBarBlockingView?.layer.opacity = childForStatusBarHidden!.prefersStatusBarHidden ? 0 : 1
|
||||
}
|
||||
|
||||
private var poppingViewController: UIViewController?
|
||||
|
|
|
@ -17,6 +17,14 @@ class AppSplitViewController: UISplitViewController {
|
|||
|
||||
private var secondaryNav: UINavigationController!
|
||||
|
||||
override var childForStatusBarHidden: UIViewController? {
|
||||
if traitCollection.horizontalSizeClass == .compact {
|
||||
return viewController(for: .compact)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
init(fervorController: FervorController) {
|
||||
self.fervorController = fervorController
|
||||
|
||||
|
|
|
@ -30,12 +30,14 @@ class ReadViewController: UIViewController {
|
|||
|
||||
private var webView: WKWebView!
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
private var itemReadObservation: NSKeyValueObservation?
|
||||
#endif
|
||||
|
||||
override var prefersStatusBarHidden: Bool {
|
||||
navigationController?.isNavigationBarHidden ?? false
|
||||
if navigationController?.isNavigationBarHidden == true,
|
||||
let webView,
|
||||
webView.scrollView.contentOffset.y > -webView.scrollView.safeAreaInsets.top {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
|
||||
|
@ -98,6 +100,18 @@ class ReadViewController: UIViewController {
|
|||
activityItemsConfiguration = UIActivityItemsConfiguration(objects: [url as NSURL])
|
||||
}
|
||||
|
||||
webView.scrollView.publisher(for: \.contentOffset)
|
||||
.map { [unowned self] _ in
|
||||
self.prefersStatusBarHidden
|
||||
}
|
||||
.removeDuplicates()
|
||||
.sink { [unowned self] _ in
|
||||
UIView.animate(withDuration: 0.2, delay: 0) {
|
||||
self.setNeedsStatusBarAppearanceUpdate()
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
scrollPositionChangedSubject
|
||||
.debounce(for: .milliseconds(500), scheduler: RunLoop.main)
|
||||
.sink { [unowned self] in
|
||||
|
@ -106,9 +120,11 @@ class ReadViewController: UIViewController {
|
|||
.store(in: &cancellables)
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
itemReadObservation = item.observe(\.read) { [unowned self] _, _ in
|
||||
self.updateToggleReadToolbarImage()
|
||||
}
|
||||
item.publisher(for: \.read)
|
||||
.sink { [unowned self] _ in
|
||||
self.updateToggleReadToolbarImage()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue