SwiftKickMobile/SwiftMessages

Use separated controller ('aka' segue) in a stand alone window instead of presenting it on a source controller.

Closed this issue · 3 comments

Hey, Since we should use segues to have a standalone view controller inside the swift message, we always need a source view controller to pass it as the source of this function:

        BottomCardSheetSegue(identifier: id, source: source, destination: controller).perform()

Imagine we have a controller that should be on top of the entire window (like the sheets that iOS is using)

68747470733a2f2f692e737461636b2e696d6775722e636f6d2f6d4b5a32502e6a7067

This kind of message should not be coupled with the source view controller underneath them.

So how can we present a controller in a separate window like the presentation of the basic views of the Swift messages? Is it possible now?

Hi. I hadn't thought of doing that before, but it was relatively straightforward. Could you install the head of master and try the following and let me know if it works for you?

let sourceVC = WindowViewController()
let segue = SwiftMessagesSegue(identifier: nil, source: windowVC, destination: destinationVC)
segue.perform()

You can optionally specify window level and window scene by providing an instance of SwiftMessages.Config to the window view controller's initializer where the desired values are specified in the SwiftMessages.Config.presentationContext property.

Works at the first look. This method should be mentioned in the documentation. I've done that in this PR

BUT! it will crash if you try to present another one while the previous is already presenting:

Thread 1: "Application tried to present modally a view controller <UIViewController: 0x7fb420c27300> that is already being presented by <SwiftMessages.WindowViewController: 0x7fb42105b000>."

Also, I don't know why but it shows nothing in another app and that is not expected.

9.0.0