@@ -28,8 +28,6 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
28
28
fileprivate var presentDismissDuration : TimeInterval = 0.2
29
29
fileprivate var presentDismissScale : CGFloat = 0.8
30
30
31
- open var completion : ( ( ) -> Void ) ? = nil
32
-
33
31
private lazy var backgroundView : UIView = {
34
32
#if os(visionOS)
35
33
let swiftUIView = VisionGlassBackgroundView ( cornerRadius: 12 )
@@ -126,8 +124,7 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
126
124
fatalError ( " init(coder:) has not been implemented " )
127
125
}
128
126
129
- open func present( on view: UIView , completion: @escaping ( ) -> Void = { } ) {
130
- self . completion = completion
127
+ open func present( on view: UIView , completion: ( ( ) -> Void ) ? = nil ) {
131
128
self . viewForPresent = view
132
129
viewForPresent? . addSubview ( self )
133
130
guard let viewForPresent = viewForPresent else { return }
@@ -164,19 +161,22 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
164
161
165
162
if self . dismissInTime {
166
163
DispatchQueue . main. asyncAfter ( deadline: DispatchTime . now ( ) + self . duration) {
167
- self . dismiss ( )
164
+ // If dismiss manually no need call original completion.
165
+ if self . alpha != 0 {
166
+ self . dismiss ( completion: completion)
167
+ }
168
168
}
169
169
}
170
170
} )
171
171
}
172
172
173
- @objc open func dismiss( ) {
173
+ @objc open func dismiss( completion : ( ( ) -> Void ) ? = nil ) {
174
174
UIView . animate ( withDuration: presentDismissDuration, animations: {
175
175
self . alpha = 0
176
176
self . transform = self . transform. scaledBy ( x: self . presentDismissScale, y: self . presentDismissScale)
177
177
} , completion: { [ weak self] finished in
178
178
self ? . removeFromSuperview ( )
179
- self ? . completion ? ( )
179
+ completion ? ( )
180
180
} )
181
181
}
182
182
0 commit comments