SwiftKickMobile / SwiftMessages

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

Present SwiftMessages on top VC when using automatic presentationContext #363

Closed devjmitchell closed 4 years ago

devjmitchell commented 4 years ago

Changes to modals in iOS 13 caused .automatic presentationContext to not display SwiftMessages on top of modals. This change will allow SwiftMessages to present on top of a modal, while still working correctly from a view controller's nav bar (using .automatic presentationContext).

allaire commented 4 years ago

Works for us, thanks!

Mathbl commented 4 years ago

Messages were not displayed anymore for us on iOS 13 when using the new modal presentation style (that is enabled by default).

This seems to fix the issue. Thanks and hopefully it's merged soon!

wtmoose commented 4 years ago

Hi, somehow I overlooked this PR. Sorry.

Thanks for bringing this up. Your fix isn't quite correct – there is already logic for this in UIViewController+Utils.swift that needed to be updated for the new modal presentation style. The fix looks like this:

private let fullScreenStyles: [UIModalPresentationStyle] = {
    if #available(iOS 13.0, *) {
        return [.fullScreen, .overFullScreen, .automatic]
    } else {
        return [.fullScreen, .overFullScreen]
    }
}()

Please try it out on the head of master and let me know if it works for you.

devjmitchell commented 4 years ago

I may be doing something wrong, but it appears your fix doesn't solve the problem for me. Please see screenshots where I show the message (works fine), but when I'm using a modal, it doesn't present on top - it's still presenting from the nav bar of the VC behind the modal.

Simulator Screen Shot - iPhone 11 - 2019-12-10 at 13 52 09 Simulator Screen Shot - iPhone 11 - 2019-12-10 at 13 52 18 Simulator Screen Shot - iPhone 11 - 2019-12-10 at 13 52 22

wtmoose commented 4 years ago

My fault, I was checking for automatic style but it was actually defaulting to pageSheet. I went in a bit of a different direction with the fix, though. Now messages are always displayed above presented view controllers regardless of modalPresentationStyle. Please try out the latest on master.

devjmitchell commented 4 years ago

This fix works in my test project - thanks for the update!