SwiftMessages icon indicating copy to clipboard operation
SwiftMessages copied to clipboard

Status bar does not reappear after messageView disappears.

Open JMchou opened this issue 3 years ago • 8 comments

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.

JMchou avatar Dec 20 '20 07:12 JMchou

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

wtmoose avatar Dec 20 '20 17:12 wtmoose

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

JMchou avatar Dec 21 '20 01:12 JMchou

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

RSickenberg avatar Jan 30 '21 18:01 RSickenberg

This issue also exists with 9.0.4

Any ideas on a future fix?

sbrioux avatar Oct 06 '21 13:10 sbrioux

Also on 9.0.5 😢

RSickenberg avatar Oct 26 '21 07:10 RSickenberg

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).

dtroupe18 avatar Dec 30 '21 14:12 dtroupe18

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.

RSickenberg avatar Apr 07 '22 09:04 RSickenberg

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()
    }
}

fredpi avatar May 27 '22 10:05 fredpi