You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: SwiftMessages/SwiftMessagesSegue.swift
+9-2
Original file line number
Diff line number
Diff line change
@@ -34,11 +34,18 @@ import UIKit
34
34
35
35
dismiss(animated: true, completion: nil)
36
36
37
-
To display the view controller in a new window, supply an instance of `WindowViewController` as the `source`.
38
-
39
37
It is not necessary to retain `segue` because it retains itself until dismissal. However, you can
40
38
retain it if you plan to `perform()` more than once.
41
39
40
+
#### Present the controller on top of all controllers
41
+
42
+
If you don't know the presenter or you don't want to pass it as a source, like when you
43
+
have a completely separated message controller, you can pass a `WindowViewController`
44
+
as the `source` argument of the segue's initializer.
45
+
46
+
By default, the window will be shown in the current window scene at `.normal` window level.
47
+
However, these parameters can be customized by initializing the view controller with a `SwiftMessages.Config` that has the `SwiftMessages.Config.presentationContext` set to either `.window` or `.windowScene`:
48
+
42
49
+ note: Some additional details:
43
50
1. Your view controller's view will be embedded in a `SwiftMessages.BaseView` in order to
44
51
utilize some SwiftMessages features. This view can be accessed and configured via the
To dismiss, call the UIKit API on the presenting view controller:
27
+
28
+
````swift
29
+
dismiss(animated: true, completion: nil)
30
+
````
31
+
32
+
It is not necessary to retain `segue` because it retains itself until dismissal. However, you can retain it if you plan to `perform()` more than once.
33
+
26
34
#### Present the controller on top of all controllers
27
35
28
-
If you don't know the presenter or you don't want to pass it as a source like when you have a completely separated message controller, you can pass a `WindowViewController` as the **source** argument of the segue. Also, You can set the `windowLevel` and other configurations by passing a config: `SwiftMessages.Config` instance as the argument of the `WindowViewController`:
36
+
If you don't know the presenter or you don't want to pass it as a source, like when you
37
+
have a completely separated message controller, you can pass a `WindowViewController`
38
+
as the `source` argument of the segue's initializer.
39
+
40
+
By default, the window will be shown in the current window scene at `.normal` window level.
41
+
However, these parameters can be customized by initializing the view controller with a `SwiftMessages.Config` that has the `SwiftMessages.Config.presentationContext` set to either `.window` or `.windowScene`:
29
42
30
43
```swift
31
44
let destinationVC =...// make a reference to a destination view controller
32
-
let sourceVC =WindowViewController(config: SwiftMessages.defaultConfig) // The `config` can be any custom `SwiftMessages.Config` instance
45
+
var config = SwiftMessages.defaultConfig
46
+
config.presentationContext= .windowScene(...) // specify the window properties
47
+
let sourceVC =WindowViewController(config: config)
33
48
let segue =SwiftMessagesSegue(identifier: nil, source: self, destination: destinationVC)
34
-
...// do any configuration here
35
49
segue.perform()
36
50
```
37
51
38
-
To dismiss, call the UIKit API on the presenting view controller:
39
-
40
-
````swift
41
-
dismiss(animated: true, completion: nil)
42
-
````
43
-
44
-
It is not necessary to retain `segue` because it retains itself until dismissal. However, you can retain it if you plan to `perform()` more than once.
45
-
46
52
### Configuration
47
53
48
54
`SwiftMessagesSegue` generally requires configuration to achieve specific layouts and optional behaviors. There are a few good ways to do this:
0 commit comments