@@ -2,7 +2,7 @@ import UIKit
22import SwiftUI
33
44@available ( iOS 13 , visionOS 1 , * )
5- public class AlertAppleMusic17View : UIView , AlertViewProtocol {
5+ public class AlertAppleMusic17View : UIView , AlertViewProtocol , AlertViewInternalDismissProtocol {
66
77 open var dismissByTap : Bool = true
88 open var dismissInTime : Bool = true
@@ -28,6 +28,8 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
2828 fileprivate var presentDismissDuration : TimeInterval = 0.2
2929 fileprivate var presentDismissScale : CGFloat = 0.8
3030
31+ fileprivate var completion : ( ( ) -> Void ) ? = nil
32+
3133 private lazy var backgroundView : UIView = {
3234 #if os(visionOS)
3335 let swiftUIView = VisionGlassBackgroundView ( cornerRadius: 12 )
@@ -126,6 +128,7 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
126128
127129 open func present( on view: UIView , completion: ( ( ) -> Void ) ? = nil ) {
128130 self . viewForPresent = view
131+ self . completion = completion
129132 viewForPresent? . addSubview ( self )
130133 guard let viewForPresent = viewForPresent else { return }
131134
@@ -163,20 +166,24 @@ public class AlertAppleMusic17View: UIView, AlertViewProtocol {
163166 DispatchQueue . main. asyncAfter ( deadline: DispatchTime . now ( ) + self . duration) {
164167 // If dismiss manually no need call original completion.
165168 if self . alpha != 0 {
166- self . dismiss ( completion : completion )
169+ self . dismiss ( )
167170 }
168171 }
169172 }
170173 } )
171174 }
172175
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 ) {
174181 UIView . animate ( withDuration: presentDismissDuration, animations: {
175182 self . alpha = 0
176183 self . transform = self . transform. scaledBy ( x: self . presentDismissScale, y: self . presentDismissScale)
177184 } , completion: { [ weak self] finished in
178185 self ? . removeFromSuperview ( )
179- completion ? ( )
186+ customCompletion ? ( )
180187 } )
181188 }
182189
0 commit comments