From 35f6732ad924b9d56ceb2f253d31d164890882a4 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Mon, 14 Nov 2022 20:10:05 -0500 Subject: [PATCH 1/6] update generated files --- .../StringsConvertor/input/Base.lproj/app.json | 4 ++++ .../MastodonLocalization/Generated/Strings.swift | 12 ++++++------ .../Resources/Base.lproj/Localizable.strings | 2 ++ .../Resources/en.lproj/Localizable.strings | 4 +--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Localization/StringsConvertor/input/Base.lproj/app.json b/Localization/StringsConvertor/input/Base.lproj/app.json index c40c0a39e..30566d8d6 100644 --- a/Localization/StringsConvertor/input/Base.lproj/app.json +++ b/Localization/StringsConvertor/input/Base.lproj/app.json @@ -448,6 +448,10 @@ "placeholder": { "label": "Label", "content": "Content" + }, + "verified": { + "short": "Verified on %s", + "long": "Ownership of this link was checked on %s" } }, "segmented_control": { diff --git a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift index 65a97c615..1ad98b0ea 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift +++ b/MastodonSDK/Sources/MastodonLocalization/Generated/Strings.swift @@ -742,13 +742,13 @@ public enum L10n { public static let label = L10n.tr("Localizable", "Scene.Profile.Fields.Placeholder.Label", fallback: "Label") } public enum Verified { - /// Ownership of this link was checked on %s - public static func long(_ p1: UnsafePointer) -> String { - return L10n.tr("Localizable", "Scene.Profile.Fields.Verified.Long", p1) + /// Ownership of this link was checked on %@ + public static func long(_ p1: Any) -> String { + return L10n.tr("Localizable", "Scene.Profile.Fields.Verified.Long", String(describing: p1), fallback: "Ownership of this link was checked on %@") } - /// Verified at %s - public static func short(_ p1: UnsafePointer) -> String { - return L10n.tr("Localizable", "Scene.Profile.Fields.Verified.Short", p1) + /// Verified on %@ + public static func short(_ p1: Any) -> String { + return L10n.tr("Localizable", "Scene.Profile.Fields.Verified.Short", String(describing: p1), fallback: "Verified on %@") } } } diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings b/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings index a352b0526..73bc292cf 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/Base.lproj/Localizable.strings @@ -267,6 +267,8 @@ uploaded to Mastodon."; "Scene.Profile.Fields.AddRow" = "Add Row"; "Scene.Profile.Fields.Placeholder.Content" = "Content"; "Scene.Profile.Fields.Placeholder.Label" = "Label"; +"Scene.Profile.Fields.Verified.Long" = "Ownership of this link was checked on %@"; +"Scene.Profile.Fields.Verified.Short" = "Verified on %@"; "Scene.Profile.Header.FollowsYou" = "Follows You"; "Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Message" = "Confirm to block %@"; "Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Title" = "Block Account"; diff --git a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings index e269a45a7..07ccd2c1b 100644 --- a/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings +++ b/MastodonSDK/Sources/MastodonLocalization/Resources/en.lproj/Localizable.strings @@ -263,8 +263,6 @@ uploaded to Mastodon."; "Scene.Profile.Fields.AddRow" = "Add Row"; "Scene.Profile.Fields.Placeholder.Content" = "Content"; "Scene.Profile.Fields.Placeholder.Label" = "Label"; -"Scene.Profile.Fields.Verified.Short" = "Verified at %s"; -"Scene.Profile.Fields.Verified.Long" = "Ownership of this link was checked on %s"; "Scene.Profile.Header.FollowsYou" = "Follows You"; "Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Message" = "Confirm to block %@"; "Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Title" = "Block Account"; @@ -456,4 +454,4 @@ uploaded to Mastodon."; back in your hands."; "Scene.Wizard.AccessibilityHint" = "Double tap to dismiss this wizard"; "Scene.Wizard.MultipleAccountSwitchIntroDescription" = "Switch between multiple accounts by holding the profile button."; -"Scene.Wizard.NewInMastodon" = "New in Mastodon"; +"Scene.Wizard.NewInMastodon" = "New in Mastodon"; \ No newline at end of file From ac28c2ee4f4d24fcab5d0442f2ea0e4eed12e910 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Mon, 14 Nov 2022 20:44:47 -0500 Subject: [PATCH 2/6] Add Live Text support to MediaPreviewImageView --- .../Image/MediaPreviewImageView.swift | 45 +++++++++++++++++-- .../MediaPreviewImageViewController.swift | 42 ++++++++++++++++- .../MastodonExtension/ImageAnalyzer.swift | 13 ++++++ 3 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 MastodonSDK/Sources/MastodonExtension/ImageAnalyzer.swift diff --git a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift index 05f2ce70f..cc31a9639 100644 --- a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift +++ b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift @@ -9,6 +9,7 @@ import os.log import func AVFoundation.AVMakeRect import UIKit import FLAnimatedImage +import VisionKit final class MediaPreviewImageView: UIScrollView { @@ -28,9 +29,21 @@ final class MediaPreviewImageView: UIScrollView { tapGestureRecognizer.numberOfTapsRequired = 2 return tapGestureRecognizer }() - + private var containerFrame: CGRect? - + + private var _interaction: UIInteraction? = { + if #available(iOS 16.0, *) { + return ImageAnalysisInteraction() + } else { + return nil + } + }() + @available(iOS 16.0, *) + var liveTextInteraction: ImageAnalysisInteraction { + _interaction as! ImageAnalysisInteraction + } + override init(frame: CGRect) { super.init(frame: frame) _init() @@ -55,10 +68,14 @@ extension MediaPreviewImageView { maximumZoomScale = 4.0 addSubview(imageView) - + doubleTapGestureRecognizer.addTarget(self, action: #selector(MediaPreviewImageView.doubleTapGestureRecognizerHandler(_:))) imageView.addGestureRecognizer(doubleTapGestureRecognizer) - + if #available(iOS 16.0, *) { + liveTextInteraction.isSupplementaryInterfaceHidden = true + imageView.addInteraction(liveTextInteraction) + } + delegate = self } @@ -129,6 +146,26 @@ extension MediaPreviewImageView { centerScrollViewContents() contentOffset = CGPoint(x: -contentInset.left, y: -contentInset.top) + + if #available(iOS 16.0, *) { + Task.detached(priority: .userInitiated) { + do { + let analysis = try await ImageAnalyzer.shared.analyze(image, configuration: ImageAnalyzer.Configuration([.text, .machineReadableCode])) + await MainActor.run { + self.liveTextInteraction.analysis = analysis + self.liveTextInteraction.preferredInteractionTypes = .automatic + if self.liveTextInteraction.isSupplementaryInterfaceHidden { + self.liveTextInteraction.setSupplementaryInterfaceHidden(false, animated: true) + } + + } + } catch { + await MainActor.run { + self.liveTextInteraction.preferredInteractionTypes = [] + } + } + } + } os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: setup image for container %s", ((#file as NSString).lastPathComponent), #line, #function, container.frame.debugDescription) } diff --git a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift index 127c4c0c0..1c00b3907 100644 --- a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift +++ b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift @@ -11,6 +11,7 @@ import Combine import MastodonAsset import MastodonLocalization import FLAnimatedImage +import VisionKit protocol MediaPreviewImageViewControllerDelegate: AnyObject { func mediaPreviewImageViewController(_ viewController: MediaPreviewImageViewController, tapGestureRecognizerDidTrigger tapGestureRecognizer: UITapGestureRecognizer) @@ -31,7 +32,7 @@ final class MediaPreviewImageViewController: UIViewController { let tapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer let longPressGestureRecognizer = UILongPressGestureRecognizer() - + deinit { os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) previewImageView.imageView.af.cancelImageRequest() @@ -42,7 +43,10 @@ extension MediaPreviewImageViewController { override func viewDidLoad() { super.viewDidLoad() - + + if #available(iOS 16.0, *) { + previewImageView.liveTextInteraction.delegate = self + } previewImageView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(previewImageView) NSLayoutConstraint.activate([ @@ -53,7 +57,9 @@ extension MediaPreviewImageViewController { ]) tapGestureRecognizer.addTarget(self, action: #selector(MediaPreviewImageViewController.tapGestureRecognizerHandler(_:))) + tapGestureRecognizer.delegate = self longPressGestureRecognizer.addTarget(self, action: #selector(MediaPreviewImageViewController.longPressGestureRecognizerHandler(_:))) + longPressGestureRecognizer.delegate = self tapGestureRecognizer.require(toFail: previewImageView.doubleTapGestureRecognizer) tapGestureRecognizer.require(toFail: longPressGestureRecognizer) previewImageView.addGestureRecognizer(tapGestureRecognizer) @@ -105,10 +111,42 @@ extension MediaPreviewImageViewController { } +// MARK: - ImageAnalysisInteractionDelegate +@available(iOS 16.0, *) +extension MediaPreviewImageViewController: ImageAnalysisInteractionDelegate { + func contentView(for interaction: ImageAnalysisInteraction) -> UIView? { + view + } + + func presentingViewController(for interaction: ImageAnalysisInteraction) -> UIViewController? { + self + } +} + +// MARK: - UIGestureRecognizerDelegate +extension MediaPreviewImageViewController: UIGestureRecognizerDelegate { + func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { + if #available(iOS 16.0, *) { + let location = touch.location(in: previewImageView.imageView) + let hasItem = previewImageView.liveTextInteraction.hasInteractiveItem(at: location) + return !hasItem + } else { + return true + } + } +} + // MARK: - UIContextMenuInteractionDelegate extension MediaPreviewImageViewController: UIContextMenuInteractionDelegate { func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function) + + if #available(iOS 16.0, *) { + if previewImageView.liveTextInteraction.hasInteractiveItem(at: previewImageView.imageView.convert(location, from: previewImageView)) { + return nil + } + } + let previewProvider: UIContextMenuContentPreviewProvider = { () -> UIViewController? in return nil diff --git a/MastodonSDK/Sources/MastodonExtension/ImageAnalyzer.swift b/MastodonSDK/Sources/MastodonExtension/ImageAnalyzer.swift new file mode 100644 index 000000000..cf8a0f437 --- /dev/null +++ b/MastodonSDK/Sources/MastodonExtension/ImageAnalyzer.swift @@ -0,0 +1,13 @@ +// +// ImageAnalyzer.swift +// +// +// Created by Jed Fox on 2022-11-14. +// + +import VisionKit + +@available(iOS 16.0, *) +extension ImageAnalyzer { + public static let shared = ImageAnalyzer() +} From 5277ec191bb26b3e2ea87bf7cd28360e6ae1bc5f Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Mon, 14 Nov 2022 21:50:38 -0500 Subject: [PATCH 3/6] Drop attempt to fade in the supplementary interface sometimes it just stayed hidden? --- .../Scene/MediaPreview/Image/MediaPreviewImageView.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift index cc31a9639..8432ddade 100644 --- a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift +++ b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageView.swift @@ -72,7 +72,6 @@ extension MediaPreviewImageView { doubleTapGestureRecognizer.addTarget(self, action: #selector(MediaPreviewImageView.doubleTapGestureRecognizerHandler(_:))) imageView.addGestureRecognizer(doubleTapGestureRecognizer) if #available(iOS 16.0, *) { - liveTextInteraction.isSupplementaryInterfaceHidden = true imageView.addInteraction(liveTextInteraction) } @@ -154,10 +153,6 @@ extension MediaPreviewImageView { await MainActor.run { self.liveTextInteraction.analysis = analysis self.liveTextInteraction.preferredInteractionTypes = .automatic - if self.liveTextInteraction.isSupplementaryInterfaceHidden { - self.liveTextInteraction.setSupplementaryInterfaceHidden(false, animated: true) - } - } } catch { await MainActor.run { From 0687ef4f8eae50b3edc5647e9df522ba4875c8af Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Mon, 14 Nov 2022 21:52:16 -0500 Subject: [PATCH 4/6] Add support for tapping an image to hide all the chrome --- Mastodon/Coordinator/SceneCoordinator.swift | 2 +- .../MediaPreviewImageViewController.swift | 24 ++++++++++++----- .../MediaPreviewViewController.swift | 26 +++++++++++++++++-- .../MediaPreview/MediaPreviewViewModel.swift | 17 +++++++++++- .../MediaPreviewVideoViewController.swift | 6 +++++ 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/Mastodon/Coordinator/SceneCoordinator.swift b/Mastodon/Coordinator/SceneCoordinator.swift index 8a0825969..01fb744ce 100644 --- a/Mastodon/Coordinator/SceneCoordinator.swift +++ b/Mastodon/Coordinator/SceneCoordinator.swift @@ -339,7 +339,7 @@ extension SceneCoordinator { case .custom(let transitioningDelegate): viewController.modalPresentationStyle = .custom viewController.transitioningDelegate = transitioningDelegate - // viewController.modalPresentationCapturesStatusBarAppearance = true + viewController.modalPresentationCapturesStatusBarAppearance = true (splitViewController ?? presentingViewController)?.present(viewController, animated: true, completion: nil) case .customPush(let animated): diff --git a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift index 1c00b3907..513110d29 100644 --- a/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift +++ b/Mastodon/Scene/MediaPreview/Image/MediaPreviewImageViewController.swift @@ -111,13 +111,19 @@ extension MediaPreviewImageViewController { } +extension MediaPreviewImageViewController: MediaPreviewPage { + func setShowingChrome(_ showingChrome: Bool) { + if #available(iOS 16.0, *) { + UIView.animate(withDuration: 0.3) { + self.previewImageView.liveTextInteraction.setSupplementaryInterfaceHidden(!showingChrome, animated: true) + } + } + } +} + // MARK: - ImageAnalysisInteractionDelegate @available(iOS 16.0, *) extension MediaPreviewImageViewController: ImageAnalysisInteractionDelegate { - func contentView(for interaction: ImageAnalysisInteraction) -> UIView? { - view - } - func presentingViewController(for interaction: ImageAnalysisInteraction) -> UIViewController? { self } @@ -128,8 +134,14 @@ extension MediaPreviewImageViewController: UIGestureRecognizerDelegate { func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { if #available(iOS 16.0, *) { let location = touch.location(in: previewImageView.imageView) - let hasItem = previewImageView.liveTextInteraction.hasInteractiveItem(at: location) - return !hasItem + // for tap gestures, only items that can be tapped are relevant + if gestureRecognizer is UITapGestureRecognizer { + return !previewImageView.liveTextInteraction.hasSupplementaryInterface(at: location) + && !previewImageView.liveTextInteraction.hasDataDetector(at: location) + } else { + // for long press, block out everything + return !previewImageView.liveTextInteraction.hasInteractiveItem(at: location) + } } else { return true } diff --git a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift index c6552bcba..f3a59d0bb 100644 --- a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift +++ b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift @@ -137,6 +137,17 @@ extension MediaPreviewViewController { } } .store(in: &disposeBag) + + viewModel.$showingChrome + .receive(on: DispatchQueue.main) + .removeDuplicates() + .sink { [weak self] showingChrome in + UIView.animate(withDuration: 0.3) { + self?.setNeedsStatusBarAppearanceUpdate() + self?.closeButtonBackground.alpha = showingChrome ? 1 : 0 + } + } + .store(in: &disposeBag) // viewModel.$isPoping // .receive(on: DispatchQueue.main) @@ -153,6 +164,14 @@ extension MediaPreviewViewController { } +extension MediaPreviewViewController { + + override var prefersStatusBarHidden: Bool { + !viewModel.showingChrome + } + +} + extension MediaPreviewViewController { @objc private func closeButtonPressed(_ sender: UIButton) { @@ -239,8 +258,11 @@ extension MediaPreviewViewController: MediaPreviewImageViewControllerDelegate { let location = tapGestureRecognizer.location(in: viewController.previewImageView.imageView) let isContainsTap = viewController.previewImageView.imageView.frame.contains(location) - guard !isContainsTap else { return } - dismiss(animated: true, completion: nil) + if isContainsTap { + self.viewModel.showingChrome.toggle() + } else { + dismiss(animated: true, completion: nil) + } } func mediaPreviewImageViewController(_ viewController: MediaPreviewImageViewController, longPressGestureRecognizerDidTrigger longPressGestureRecognizer: UILongPressGestureRecognizer) { diff --git a/Mastodon/Scene/MediaPreview/MediaPreviewViewModel.swift b/Mastodon/Scene/MediaPreview/MediaPreviewViewModel.swift index c43d24945..3f60b19e5 100644 --- a/Mastodon/Scene/MediaPreview/MediaPreviewViewModel.swift +++ b/Mastodon/Scene/MediaPreview/MediaPreviewViewModel.swift @@ -12,6 +12,10 @@ import CoreDataStack import Pageboy import MastodonCore +protocol MediaPreviewPage: UIViewController { + func setShowingChrome(_ showingChrome: Bool) +} + final class MediaPreviewViewModel: NSObject { weak var mediaPreviewImageViewControllerDelegate: MediaPreviewImageViewControllerDelegate? @@ -22,9 +26,12 @@ final class MediaPreviewViewModel: NSObject { let transitionItem: MediaPreviewTransitionItem @Published var currentPage: Int + @Published var showingChrome = true // output let viewControllers: [UIViewController] + + private var disposeBag: Set = [] init( context: AppContext, @@ -34,7 +41,7 @@ final class MediaPreviewViewModel: NSObject { self.context = context self.item = item var currentPage = 0 - var viewControllers: [UIViewController] = [] + var viewControllers: [MediaPreviewPage] = [] switch item { case .attachment(let previewContext): currentPage = previewContext.initialIndex @@ -106,6 +113,14 @@ final class MediaPreviewViewModel: NSObject { self.currentPage = currentPage self.transitionItem = transitionItem super.init() + + for viewController in viewControllers { + self.$showingChrome + .sink { [weak viewController] showingChrome in + viewController?.setShowingChrome(showingChrome) + } + .store(in: &disposeBag) + } } } diff --git a/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift b/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift index 7bdbbfed2..792854248 100644 --- a/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift +++ b/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift @@ -111,6 +111,12 @@ extension MediaPreviewVideoViewController { // } //} +extension MediaPreviewVideoViewController: MediaPreviewPage { + func setShowingChrome(_ showingChrome: Bool) { + // TODO: does this do anything? + } +} + // MARK: - AVPlayerViewControllerDelegate extension MediaPreviewVideoViewController: AVPlayerViewControllerDelegate { From 60efe4f02320b5005554a8030e09f9d8759a0776 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Tue, 15 Nov 2022 13:13:22 -0500 Subject: [PATCH 5/6] Fix status bar when dismissing --- ...tToMediaPreviewViewControllerAnimatedTransitioning.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift b/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift index 5381feb0d..de2cec6bf 100644 --- a/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift +++ b/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift @@ -131,6 +131,12 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning { } return animator } + + if let toVC = transitionContext.viewController(forKey: .to) { + animator.addCompletion { _ in + toVC.setNeedsStatusBarAppearanceUpdate() + } + } // update close button UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) { From ff5a0876c8cee61b341f8a932330c5184bb22098 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Tue, 15 Nov 2022 13:35:33 -0500 Subject: [PATCH 6/6] Change childForStatusBarStyle --- .../AdaptiveStatusBarStyleNavigationController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mastodon/Scene/Share/NavigationController/AdaptiveStatusBarStyleNavigationController.swift b/Mastodon/Scene/Share/NavigationController/AdaptiveStatusBarStyleNavigationController.swift index 80df8938e..88441f9ad 100644 --- a/Mastodon/Scene/Share/NavigationController/AdaptiveStatusBarStyleNavigationController.swift +++ b/Mastodon/Scene/Share/NavigationController/AdaptiveStatusBarStyleNavigationController.swift @@ -14,7 +14,7 @@ class AdaptiveStatusBarStyleNavigationController: UINavigationController { // Make status bar style adaptive for child view controller // SeeAlso: `modalPresentationCapturesStatusBarAppearance` override var childForStatusBarStyle: UIViewController? { - visibleViewController + topViewController } }