@@ -28,8 +28,6 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
2828 fileprivate var presentDismissDuration : TimeInterval = 0.2
2929 fileprivate var presentDismissScale : CGFloat = 0.8
3030
31- open var completion : ( ( ) -> Void ) ? = nil
32-
3331 private lazy var backgroundView : UIView = {
3432 #if os(visionOS)
3533 let swiftUIView = VisionGlassBackgroundView ( cornerRadius: 12 )
@@ -126,8 +124,7 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
126124 fatalError ( " init(coder:) has not been implemented " )
127125 }
128126
129- open func present( on view: UIView , completion: @escaping ( ) -> Void = { } ) {
130- self . completion = completion
127+ open func present( on view: UIView , completion: ( ( ) -> Void ) ? = nil ) {
131128 self . viewForPresent = view
132129 viewForPresent? . addSubview ( self )
133130 guard let viewForPresent = viewForPresent else { return }
@@ -164,19 +161,22 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
164161
165162 if self . dismissInTime {
166163 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+ }
168168 }
169169 }
170170 } )
171171 }
172172
173- @objc open func dismiss( ) {
173+ @objc open func dismiss( completion : ( ( ) -> Void ) ? = nil ) {
174174 UIView . animate ( withDuration: presentDismissDuration, animations: {
175175 self . alpha = 0
176176 self . transform = self . transform. scaledBy ( x: self . presentDismissScale, y: self . presentDismissScale)
177177 } , completion: { [ weak self] finished in
178178 self ? . removeFromSuperview ( )
179- self ? . completion ? ( )
179+ completion ? ( )
180180 } )
181181 }
182182
0 commit comments