Skip to content

Commit e5d0944

Browse files
committed
Adjust documentation
1 parent 9f98dc6 commit e5d0944

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

SwiftMessages/SwiftMessagesSegue.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,18 @@ import UIKit
3434

3535
dismiss(animated: true, completion: nil)
3636

37-
To display the view controller in a new window, supply an instance of `WindowViewController` as the `source`.
38-
3937
It is not necessary to retain `segue` because it retains itself until dismissal. However, you can
4038
retain it if you plan to `perform()` more than once.
4139

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+
4249
+ note: Some additional details:
4350
1. Your view controller's view will be embedded in a `SwiftMessages.BaseView` in order to
4451
utilize some SwiftMessages features. This view can be accessed and configured via the

ViewControllers.md

+17-11
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,32 @@ let segue = SwiftMessagesSegue(identifier: nil, source: self, destination: desti
2323
segue.perform()
2424
````
2525

26+
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+
2634
#### Present the controller on top of all controllers
2735

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`:
2942

3043
```swift
3144
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)
3348
let segue = SwiftMessagesSegue(identifier: nil, source: self, destination: destinationVC)
34-
... // do any configuration here
3549
segue.perform()
3650
```
3751

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-
4652
### Configuration
4753

4854
`SwiftMessagesSegue` generally requires configuration to achieve specific layouts and optional behaviors. There are a few good ways to do this:

0 commit comments

Comments
 (0)