@@ -51,6 +51,8 @@ public struct FullscreenPopup<Item: Equatable, PopupContent: View>: ViewModifier
51
51
/// Trigger popup showing/hiding animations and...
52
52
@State private var shouldShowContent = false
53
53
54
+ @State private var shouldClosePopup = false
55
+
54
56
/// ... once hiding animation is finished remove popup from the memory using this flag
55
57
@State private var showContent = false
56
58
@@ -110,6 +112,7 @@ public struct FullscreenPopup<Item: Equatable, PopupContent: View>: ViewModifier
110
112
if isBoolMode {
111
113
main ( content: content)
112
114
. onChange ( of: isPresented) { newValue in
115
+ shouldClosePopup = !newValue
113
116
// minimum time to represent
114
117
DispatchQueue . main. asyncAfter ( deadline: . now( ) + 0.03 ) {
115
118
appearAction ( sheetPresented: newValue)
@@ -205,9 +208,11 @@ public struct FullscreenPopup<Item: Equatable, PopupContent: View>: ViewModifier
205
208
shouldShowContent: shouldShowContent,
206
209
showContent: showContent,
207
210
positionIsCalculatedCallback: {
208
- shouldShowContent = true // this will cause currentOffset change thus triggering the sliding showing animation
209
- opacity = 1 // this will cause cross disolving animation for background color
210
- setupAutohide ( )
211
+ if !shouldClosePopup {
212
+ shouldShowContent = true // this will cause currentOffset change thus triggering the sliding showing animation
213
+ opacity = 1 // this will cause cross disolving animation for background color
214
+ setupAutohide ( )
215
+ }
211
216
} ,
212
217
animationCompletedCallback: onAnimationCompleted,
213
218
dismissCallback: { source in
@@ -225,6 +230,7 @@ public struct FullscreenPopup<Item: Equatable, PopupContent: View>: ViewModifier
225
230
showContent = true // immediately load popup body
226
231
// shouldShowContent is set after popup's frame is calculated, see positionIsCalculatedCallback
227
232
} else {
233
+ shouldClosePopup = true
228
234
dispatchWorkHolder. work? . cancel ( )
229
235
shouldShowContent = false // this will cause currentOffset change thus triggering the sliding hiding animation
230
236
opacity = 0
0 commit comments