File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
WooCommerce/Classes/POS/Presentation/Reusable Views Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 11import SwiftUI
2+ import Combine
23
34class POSModalManager : ObservableObject {
45 @Published private( set) var isPresented : Bool = false
56 @Published private( set) var allowsInteractiveDismissal : Bool = true
67 private var contentBuilder : ( ( ) -> AnyView ) ?
78 private var onDismiss : ( ( ) -> Void ) ?
9+ private var subscriptions = Set < AnyCancellable > ( )
810
911 func present< Content: View > ( onDismiss: @escaping ( ) -> Void , content: @escaping ( ) -> Content ) {
1012 contentBuilder = { AnyView ( content ( ) ) }
1113 self . onDismiss = onDismiss
1214 isPresented = true
15+
16+ $isPresented
17+ . sink { [ weak self] _ in
18+ guard let self else { return }
19+ if !isPresented {
20+ reset ( )
21+ }
22+ }
23+ . store ( in: & subscriptions)
1324 }
1425
1526 func dismiss( ) {
@@ -34,5 +45,6 @@ class POSModalManager: ObservableObject {
3445 onDismiss = nil
3546 allowsInteractiveDismissal = true
3647 contentBuilder = nil
48+ subscriptions = Set ( )
3749 }
3850}
You can’t perform that action at this time.
0 commit comments