SwiftMessages icon indicating copy to clipboard operation
SwiftMessages copied to clipboard

.pageSheet modalPresentationStyle and WindowViewController preferredStatusBarStyle

Open giofid opened this issue 5 years ago • 1 comments

Hi @wtmoose, I'm experiencing a problem with statusBar style when I present a centered swiftMessage in a view controller presented with .pageSheet modalPresentationStyle. I attach a screen below to better explain the problem

I slightly modified the demo project to obtain it. I attach it too.

SwiftMessages-master.zip

Practically, the status bar is black on a black background. To solve the problem I have to pass config.preferredStatusBarStyle = UIApplication.shared.delegate?.window??.windowScene?.statusBarManager?.statusBarStyle during swiftmessage configuration.

I'm wondering if it's better changing the preferredStatusBarStyle overriding implementation of WindowViewController to something like

override open var preferredStatusBarStyle: UIStatusBarStyle {
      if #available(iOS 13.0, *) {
          return config.preferredStatusBarStyle ?? UIApplication.shared.delegate?.window??.windowScene?.statusBarManager?.statusBarStyle ?? super.preferredStatusBarStyle
      } else {
          return config.preferredStatusBarStyle ?? UIApplication.shared.statusBarStyle
          // OR
          // return config.preferredStatusBarStyle ?? super.preferredStatusBarStyle
     }
 }

I'd really like your opinion about this. Is this an iOS bug?

giofid avatar Oct 27 '20 13:10 giofid

Not sure if it's an iOS bug or if the new modal style revealed the issue with SwiftMessages.

I need to look at the solution a bit. SwiftMessages determines the window scene in Presenter.swift using the following logic:

@available (iOS 13.0, *)
private var windowScene: UIWindowScene? {
    switch config.presentationContext {
    case .windowScene(let scene, _): return scene
    default: return UIApplication.shared.keyWindow?.windowScene
    }
}

So it may be a bit different than what you proposed.

wtmoose avatar Oct 27 '20 15:10 wtmoose