iOS client for Grain grain.social
ios photography atproto
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: disable drag-to-dismiss pan gesture while comment sheet is open

Framework signposts in the user's trace showed the comment sheet
opening fully (~840ms) then dismissing 3ms later — a programmatic
dismissal right after presentation completes. The _UIFormSheetPresentationController
was being torn down immediately after setup.

The DragToDismissInstaller installs a UIPanGestureRecognizer directly
on the hosting view controller's view via findViewController(). That
gesture recognizer remains active when a .sheet presents on top, and
its interaction with the sheet's own gesture system (the form sheet's
drag-to-dismiss) was tearing down the presentation.

Fix: add isEnabled: Bool to DragToDismissInstaller, wire it to
!showCommentSheet in StoryViewer. When the comment sheet is open, our
pan gesture is disabled so the sheet's own gestures can own touches
without interference.

+13 -5
+8
Grain/Views/Stories/DragToDismiss.swift
··· 45 45 var onHorizontalDragStart: ((Bool) -> Void)? // true = swiping left (forward) 46 46 var onSwipeDragging: ((CGFloat) -> Void)? // raw translation.x during drag 47 47 var onHorizontalDragCancel: (() -> Void)? 48 + /// When false, the pan gesture is disabled so another presented view (e.g. 49 + /// a comment sheet) can own touches without interference. 50 + var isEnabled: Bool = true 48 51 49 52 func makeUIView(context: Context) -> UIView { 50 53 let view = UIView(frame: .zero) ··· 66 69 context.coordinator.onHorizontalDragStart = onHorizontalDragStart 67 70 context.coordinator.onSwipeDragging = onSwipeDragging 68 71 context.coordinator.onHorizontalDragCancel = onHorizontalDragCancel 72 + context.coordinator.setEnabled(isEnabled) 69 73 handle.performDismiss = onDismiss 70 74 } 71 75 ··· 136 140 pan.delegate = self 137 141 target.addGestureRecognizer(pan) 138 142 panGesture = pan 143 + } 144 + 145 + func setEnabled(_ enabled: Bool) { 146 + panGesture?.isEnabled = enabled 139 147 } 140 148 141 149 /// Allow SwiftUI tap gestures to work simultaneously
+5 -5
Grain/Views/Stories/StoryViewer.swift
··· 181 181 onSwipeRight: { goToPreviousAuthor() }, 182 182 onHorizontalDragStart: { forward in beginSwipe(forward: forward) }, 183 183 onSwipeDragging: { tx in updateSwipeDrag(tx) }, 184 - onHorizontalDragCancel: { cancelSwipe() } 184 + onHorizontalDragCancel: { cancelSwipe() }, 185 + isEnabled: !showCommentSheet 185 186 ) 186 187 ) 187 188 .confirmationDialog("Delete this story?", isPresented: $showDeleteConfirm, titleVisibility: .visible) { ··· 1101 1102 .font(.subheadline) 1102 1103 .foregroundStyle(.white.opacity(0.6)) 1103 1104 .frame(maxWidth: .infinity, alignment: .leading) 1104 - .padding(.horizontal, 14) 1105 - .padding(.vertical, 10) 1106 - .background(.ultraThinMaterial, in: Capsule()) 1107 - .contentShape(Capsule()) 1105 + .padding(.horizontal, 18) 1106 + .padding(.vertical, 12) 1108 1107 } 1109 1108 .buttonStyle(.plain) 1109 + .glassEffect(.regular, in: .capsule) 1110 1110 1111 1111 // Heart — like/unlike 1112 1112 Button {