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
@@ -20,51 +22,57 @@ You can choose to display the default Rye alert type or go fully custom and disp
20
22
21
23
## 📝 Requirements
22
24
23
-
iOS 11.4
25
+
iOS 11.4
24
26
Swift 5
25
27
26
28
## 📦 Installation
27
29
30
+
### Swift Package Manager
31
+
Copy this repository URL, and add the repo into your Package Dependencies:
32
+
```
33
+
https://github.com/nodes-ios/Rye.git
34
+
```
35
+
28
36
### Carthage
29
-
~~~bash
37
+
```bash
30
38
github "nodes-ios/Rye"
31
-
~~~
39
+
```
32
40
33
41
### Cocoapods
34
-
~~~bash
42
+
```bash
35
43
pod 'Rye'
36
-
~~~
44
+
```
37
45
38
46
## 💻 Usage
39
47
40
48
### Principles
41
49
42
50
To display a Rye alert you declare a new `RyeViewController` and then call:
43
51
44
-
-`show`: to show the alert
45
-
-`dismiss`: to dismiss the alert
52
+
-`show()`: to show the alert
53
+
-`dismiss()`: to dismiss the alert
46
54
47
55
**Note:** Depending on which `dismissMode` you have selected, you may not need to dismiss the alert yourself, see the section about [`displayModes`](#display-modes) below for more information.
48
56
49
57
At the very minimum you need to consider:
50
58
51
59
- which text to show
52
60
- whether to show a standard alert or bring your own custom view to the party
53
-
- where to show the text (`top` or `bottom`)
61
+
- where to show the alert (`top` or `bottom`)
54
62
55
63
#### Show Text
56
64
57
-
To show a text using a Rye alert you need to create a `RyeConfiguration`. This is a dictionary allowing you to configure various UI related aspects of your Rye alert. For more information on available keys, please refer to the section: [Possible Rye Configuration Values](#possible-rye-configuration-values)below.
65
+
To show a text using a Rye alert you need to create a `RyeConfiguration`. This is a dictionary allowing you to configure various UI related aspects of your Rye alert. For more information on available keys, please refer to the [Possible Rye Configuration Values](#possible-rye-configuration-values)section.
58
66
59
67
One of the values you can add to a `RyeConfiguration` is a text to show in your alert.
60
68
61
69
```swift
62
-
let ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text:"Message for the user"]
70
+
let ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text:"Message for the user"]
63
71
```
64
72
65
73
#### Alert Type
66
74
67
-
You can use the default Rye alert or you can create your own view and use that instead. To determine which to use, you use the `Rye.ViewType` enum defined like so:
75
+
You can use the default Rye alert or you can create your own UIView and use that instead. To determine which to use, you use the `Rye.ViewType` enum defined like so:
68
76
69
77
```swift
70
78
publicenumViewType {
@@ -75,9 +83,9 @@ public enum ViewType {
75
83
76
84
As you can see, both the `standard` and the `custom` ViewType takes an optional `RyeConfiguration` as a parameter. This means that you don't _have_ to provide a `RyeConfiguration` in which case default values will be used for all parameters including the text (but you probably don't want an alert showing the text "Add a message", do you?).
77
85
78
-
Additionally, the `custom` ViewType takes the view you would like to use.
86
+
Additionally, the `custom` ViewType takes your custom UIView that you would like to use.
79
87
80
-
Note that some of the `RyeConfiguration` keys are not relevant when using a custom view. More specificaly, theses are the keys not used when you decide to use a `custom` view for your message:
88
+
Note that some of the `RyeConfiguration` keys are not relevant when using a custom view. More specificaly, these are the keys not used when you decide to use a `custom` view for your message:
81
89
82
90
- backgroundColor
83
91
- textColor
@@ -90,7 +98,7 @@ As you can see, both the `standard` and the `custom` ViewType takes an optional
90
98
91
99
#### Where To Show the Alert?
92
100
93
-
Where to show a Rye alert is determined by a`Rye.Position`enum which is defined like so:
101
+
Where to show a Rye alert is determined by the`Rye.Position`and `Rye.Alignment` enums which are defined like so:
94
102
95
103
```swift
96
104
publicenumPosition {
@@ -99,7 +107,17 @@ public enum Position {
99
107
}
100
108
```
101
109
102
-
For more on the `Rye.Position` please refer to the section [Position](#position) below.
110
+
```swift
111
+
publicenumAlignment {
112
+
caseleading(inset: CGFloat)
113
+
casecenter
114
+
casetrailing(inset: CGFloat)
115
+
}
116
+
```
117
+
118
+
If the alignment is not specified at init time, it will default to `.center` alignment.
119
+
120
+
For more on `Rye.Position` and `Rye.Alignment`, please refer to the section [Position & Alignment](#position-and-alignment) below.
103
121
104
122
### Display a Default Rye
105
123
@@ -109,12 +127,14 @@ Following these principles, we are now ready to show our first Rye alert.
109
127
importRye
110
128
...
111
129
let ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text:"Message for the user"]
112
-
let rye = RyeViewController.init(viewType: .standard(configuration: ryeConfiguration),
This will result in a Rye alert with the text "Message for the user" appearing at the bottom at the screen and then disappearing automatically after 2.5 seconds.
137
+
This will result in a Rye alert with the text "Message for the user" appearing at the bottom of the screen, and then disappearing automatically after 2.5 seconds.
118
138
119
139
### Control the Dismiss Type
120
140
@@ -124,17 +144,19 @@ If you would like the Rye alert to disappear in a different way, you can pass a
124
144
importRye
125
145
...
126
146
let ryeConfiguration: RyeConfiguration = [Rye.Configuration.Key.text:"Message for the user"]
127
-
let rye = RyeViewController.init(dismissMode: .gesture,
@@ -212,12 +241,14 @@ Rye supports three different `displayMode` values which can be passed when creat
212
241
213
242
If you do not pass this value when creating a new `RyeViewController`, a default value of `automatic` with a default interval of 2.5 seconds is used (the default interval is defined in `Rye.defaultDismissInterval`)
214
243
215
-
#### Position
244
+
#### Position and Alignment
216
245
217
-
With Rye, you can specify the position where the Rye alert will be displayed on the screenvia the `position` parameter, which takes an associated value that allows you to specify the inset.
246
+
You can specify if the Rye alert should be shown at the top or bottom of the screen. This is specified via the `position` parameter at init time. The `position` parameter takes an associated value, that allows you to define an inset.
218
247
219
248
By default Rye will calculate the safe area insets for you, so be sure to specify only the extra desired inset.
220
249
250
+
Similarly, you can set the alignment of the Rye via the `aligned` parameter. The `.leading` and `.trailing` alignments also take an associated value, that allows you to define an inset.
251
+
If the `aligned` parameter is not specified at init time, it will default to `.center`
221
252
222
253
#### Animation Type
223
254
@@ -255,7 +286,7 @@ If configuration is set to nil, a default configuration will be used. Any option
255
286
256
287
## ⚠️ Gotchas
257
288
258
-
In order to display a Rye message a `parentView` is needed to determine _in relation to what_ the Rye message is positioned.
289
+
In order to display a Rye message, a `parentView` is needed to determine _in relation to what_ the Rye message is positioned.
259
290
260
291
If you try to display a Rye message before a `parentView` can be obtained, you will see this warning in the console of your IDE.
0 commit comments