SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.24k stars 742 forks source link

Status bar does not reappear after messageView disappears. #445

Open JMchou opened 3 years ago

JMchou commented 3 years ago

To cover the status bar I set preferStatusBarHidden to true on the config object. However I found that the Status bar remain hidden even after the message view is retracted. I'm not sure if this is an unintended behavior or I'm not using the framework correctly.

wtmoose commented 3 years ago

Can you try 8.0.5? I think this may be the same underlying problem as #446.

JMchou commented 3 years ago

I updated the pod to version 8.0.5, but the problem still persists.

RSickenberg commented 3 years ago

Same issue and 8.0.5 didn't fixed it but 8.0.3 did.

sbrioux commented 2 years ago

This issue also exists with 9.0.4

Any ideas on a future fix?

RSickenberg commented 2 years ago

Also on 9.0.5 😢

dtroupe18 commented 2 years ago

While not ideal you could tap into the eventListeners to reset the statusBar

var config: SwiftMessages.Config = .init()
config.prefersStatusBarHidden = true // hide status bar during message
config.presentationContext = .window(windowLevel: .statusBar)

config.eventListeners.append { [weak self] event in

    if case .didHide = event {

        // Unhide the status bar

        // This will cause the status bars hidden status to be set by the current viewController.
        self?.setNeedsStatusBarAppearanceUpdate()
    }
}

If you wrap your calls to SwiftMessages.show() in another class you could append this event listener to every message (if needed).

RSickenberg commented 2 years ago

If you wrap your calls to SwiftMessages.show() in another class you could append this event listener to every message (if needed).

Or in my case, pass a reference of the underlying viewController and call the method on it.

fredpi commented 2 years ago

Building upon the code posted by @dtroupe18, the following code doesn't require a reference to a specific view controller (self), but still accomplishes the same result:

config.eventListeners.append { event in
    if case .didHide = event {
        UIApplication.shared.windows.first { $0.isKeyWindow }?.rootViewController?.setNeedsStatusBarAppearanceUpdate()
    }
}