@@ -2,7 +2,7 @@ import UIKit
2
2
import SwiftUI
3
3
4
4
@available ( iOS 13 , visionOS 1 , * )
5
- public class AlertAppleMusic17View : UIView , AlertViewProtocol {
5
+ public class AlertAppleMusic17View : UIView , AlertViewProtocol , AlertViewInternalDismissProtocol {
6
6
7
7
open var dismissByTap : Bool = true
8
8
open var dismissInTime : Bool = true
@@ -28,6 +28,8 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
28
28
fileprivate var presentDismissDuration : TimeInterval = 0.2
29
29
fileprivate var presentDismissScale : CGFloat = 0.8
30
30
31
+ fileprivate var completion : ( ( ) -> Void ) ? = nil
32
+
31
33
private lazy var backgroundView : UIView = {
32
34
#if os(visionOS)
33
35
let swiftUIView = VisionGlassBackgroundView ( cornerRadius: 12 )
@@ -126,6 +128,7 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
126
128
127
129
open func present( on view: UIView , completion: ( ( ) -> Void ) ? = nil ) {
128
130
self . viewForPresent = view
131
+ self . completion = completion
129
132
viewForPresent? . addSubview ( self )
130
133
guard let viewForPresent = viewForPresent else { return }
131
134
@@ -163,20 +166,24 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
163
166
DispatchQueue . main. asyncAfter ( deadline: DispatchTime . now ( ) + self . duration) {
164
167
// If dismiss manually no need call original completion.
165
168
if self . alpha != 0 {
166
- self . dismiss ( completion : completion )
169
+ self . dismiss ( )
167
170
}
168
171
}
169
172
}
170
173
} )
171
174
}
172
175
173
- @objc open func dismiss( completion: ( ( ) -> Void ) ? = nil ) {
176
+ @objc open func dismiss( ) {
177
+ self . dismiss ( customCompletion: self . completion)
178
+ }
179
+
180
+ func dismiss( customCompletion: ( ( ) -> Void ) ? = nil ) {
174
181
UIView . animate ( withDuration: presentDismissDuration, animations: {
175
182
self . alpha = 0
176
183
self . transform = self . transform. scaledBy ( x: self . presentDismissScale, y: self . presentDismissScale)
177
184
} , completion: { [ weak self] finished in
178
185
self ? . removeFromSuperview ( )
179
- completion ? ( )
186
+ customCompletion ? ( )
180
187
} )
181
188
}
182
189
0 commit comments