@@ -65,7 +65,7 @@ struct InteractiveDismissContainer<T: View>: UIViewControllerRepresentable {
6565
6666class InteractiveDismissViewController < Content: View > : UIHostingController < Content > {
6767
68- var coordinator : InteractiveDismissCoordinator
68+ private var coordinator : InteractiveDismissCoordinator
6969 private var frameObservation : NSKeyValueObservation ?
7070
7171 init ( rootView: Content , coordinator: InteractiveDismissCoordinator ) {
@@ -83,7 +83,7 @@ class InteractiveDismissViewController<Content: View>: UIHostingController<Conte
8383 frameObservation = view. observe ( \. frame) { [ weak self] theView, _ in
8484 guard let self = self else { return }
8585 self . additionalSafeAreaInsets = UIEdgeInsets (
86- top: theView. overlappingTopInset,
86+ top: coordinator . isUpdating ? theView. overlappingTopInset : 0 ,
8787 left: 0 ,
8888 bottom: 0 ,
8989 right: 0
@@ -144,6 +144,9 @@ class InteractiveDismissCoordinator: NSObject, ObservableObject, UIGestureRecogn
144144 private var panGestureRecognizer : UIPanGestureRecognizer !
145145 private var edgeGestureRecognizer : UIScreenEdgePanGestureRecognizer !
146146
147+ /// Bool that tracks active dragging to be used to track tool bar position for overlappingTopInset
148+ @Published var isUpdating : Bool = false
149+
147150 private var isPastThreshold : Bool = false
148151 private var impactGenerator : UIImpactFeedbackGenerator
149152
@@ -197,7 +200,6 @@ class InteractiveDismissCoordinator: NSObject, ObservableObject, UIGestureRecogn
197200 private func edgeGestureUpdated( recognizer: UIScreenEdgePanGestureRecognizer ) {
198201 guard let view = recognizer. view else { return }
199202 let offset = recognizer. translation ( in: view)
200-
201203 update ( offset: offset, isEdge: true , hasEnded: recognizer. state == . ended)
202204 }
203205
@@ -210,6 +212,7 @@ class InteractiveDismissCoordinator: NSObject, ObservableObject, UIGestureRecogn
210212 }
211213
212214 private func update( offset: CGPoint , isEdge: Bool , hasEnded: Bool ) {
215+ isUpdating = true
213216 onPan ( offset)
214217
215218 let shouldDismiss = offset. y > threshold || ( offset. x > threshold && isEdge)
@@ -224,8 +227,9 @@ class InteractiveDismissCoordinator: NSObject, ObservableObject, UIGestureRecogn
224227 isEnabled = false
225228 onDismiss ( )
226229 isPastThreshold = false
230+ } else {
231+ isUpdating = false
227232 }
228-
229233 onEnded ( shouldDismiss)
230234 }
231235 }
0 commit comments