File tree Expand file tree Collapse file tree 5 files changed +32
-10
lines changed Expand file tree Collapse file tree 5 files changed +32
-10
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
All notable changes to this project will be documented in this file.
3
3
4
+ ## 9.0.6
5
+
6
+ ### Features
7
+
8
+ * Add ` UIView ` associated type to ` Event ` , e.g. ` willShow(UIView) ` so that event listeners can inspect the view.
9
+ * Add ` Event.id: String? ` property so that event listeners can reason about the view's ID.
10
+
4
11
## 9.0.5
5
12
6
13
### Fixes
Original file line number Diff line number Diff line change @@ -156,7 +156,9 @@ config.preferredStatusBarStyle = .lightContent
156
156
157
157
// Specify one or more event listeners to respond to show and hide events.
158
158
config.eventListeners .append () { event in
159
- if case .didHide = event { print (" yep" ) }
159
+ if case .didHide = event {
160
+ print (" yep id=\( String (describing : event.id )" )
161
+ }
160
162
}
161
163
162
164
SwiftMessages.show(config: config, view: view)
Original file line number Diff line number Diff line change 1
1
Pod ::Spec . new do |spec |
2
2
spec . name = 'SwiftMessages'
3
- spec . version = '9.0.5 '
3
+ spec . version = '9.0.6 '
4
4
spec . license = { :type => 'MIT' }
5
5
spec . homepage = 'https://github.com/SwiftKickMobile/SwiftMessages'
6
6
spec . authors = { 'Timothy Moose' => 'tim@swiftkick.it' }
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ class Presenter: NSObject {
119
119
func show( completion: @escaping AnimationCompletion ) throws {
120
120
try presentationContext = getPresentationContext ( )
121
121
install ( )
122
- self . config. eventListeners. forEach { $0 ( . willShow) }
122
+ self . config. eventListeners. forEach { $0 ( . willShow( self . view ) ) }
123
123
showAnimation ( ) { completed in
124
124
completion ( completed)
125
125
if completed {
@@ -128,7 +128,7 @@ class Presenter: NSObject {
128
128
} else {
129
129
self . showAccessibilityAnnouncement ( )
130
130
}
131
- self . config. eventListeners. forEach { $0 ( . didShow) }
131
+ self . config. eventListeners. forEach { $0 ( . didShow( self . view ) ) }
132
132
}
133
133
}
134
134
}
@@ -181,15 +181,15 @@ class Presenter: NSObject {
181
181
182
182
func hide( animated: Bool , completion: @escaping AnimationCompletion ) {
183
183
isHiding = true
184
- self . config. eventListeners. forEach { $0 ( . willHide) }
184
+ self . config. eventListeners. forEach { $0 ( . willHide( self . view ) ) }
185
185
let context = animationContext ( )
186
186
let action = {
187
187
if let viewController = self . presentationContext. viewControllerValue ( ) as? WindowViewController {
188
188
viewController. uninstall ( )
189
189
}
190
190
self . maskingView. removeFromSuperview ( )
191
191
completion ( true )
192
- self . config. eventListeners. forEach { $0 ( . didHide) }
192
+ self . config. eventListeners. forEach { $0 ( . didHide( self . view ) ) }
193
193
}
194
194
guard animated else {
195
195
action ( )
Original file line number Diff line number Diff line change @@ -219,10 +219,23 @@ open class SwiftMessages {
219
219
Specifies events in the message lifecycle.
220
220
*/
221
221
public enum Event {
222
- case willShow
223
- case didShow
224
- case willHide
225
- case didHide
222
+ case willShow( UIView )
223
+ case didShow( UIView )
224
+ case willHide( UIView )
225
+ case didHide( UIView )
226
+
227
+ public var view : UIView {
228
+ switch self {
229
+ case . willShow( let view) : return view
230
+ case . didShow( let view) : return view
231
+ case . willHide( let view) : return view
232
+ case . didHide( let view) : return view
233
+ }
234
+ }
235
+
236
+ public var id : String ? {
237
+ return ( view as? Identifiable ) ? . id
238
+ }
226
239
}
227
240
228
241
/**
You can’t perform that action at this time.
0 commit comments