@@ -41,6 +41,8 @@ public struct ChatChannelSwipeableListItem<Factory: ViewFactory, ChannelListItem
4141 private var trailingRightButtonTapped : ( ChatChannel ) -> Void
4242 private var trailingLeftButtonTapped : ( ChatChannel ) -> Void
4343 private var leadingButtonTapped : ( ChatChannel ) -> Void
44+
45+ @State private var verticalScrolling = false
4446
4547 public init (
4648 factory: Factory ,
@@ -76,7 +78,7 @@ public struct ChatChannelSwipeableListItem<Factory: ViewFactory, ChannelListItem
7678 . offset ( x: self . offsetX)
7779 . simultaneousGesture (
7880 DragGesture (
79- minimumDistance: 10 ,
81+ minimumDistance: 20 ,
8082 coordinateSpace: . local
8183 )
8284 . updating ( $offset) { ( value, gestureState, _) in
@@ -85,7 +87,11 @@ public struct ChatChannelSwipeableListItem<Factory: ViewFactory, ChannelListItem
8587 width: value. location. x - value. startLocation. x,
8688 height: value. location. y - value. startLocation. y
8789 )
88-
90+
91+ if abs ( value. translation. height) > abs ( value. translation. width) && !verticalScrolling {
92+ verticalScrolling = true
93+ }
94+
8995 if diff == . zero {
9096 gestureState = . zero
9197 } else {
@@ -98,7 +104,8 @@ public struct ChatChannelSwipeableListItem<Factory: ViewFactory, ChannelListItem
98104 if offset == . zero {
99105 // gesture ended or cancelled
100106 dragEnded ( )
101- } else {
107+ verticalScrolling = false
108+ } else if !verticalScrolling {
102109 dragChanged ( to: offset. width)
103110 }
104111 } )
@@ -122,7 +129,19 @@ public struct ChatChannelSwipeableListItem<Factory: ViewFactory, ChannelListItem
122129 }
123130
124131 private var showTrailingSwipeActions : Bool {
125- !( trailingSwipeActions is EmptyView )
132+ #if DEBUG
133+ let view = factory. makeTrailingSwipeActionsView (
134+ channel: channel,
135+ offsetX: offsetX,
136+ buttonWidth: buttonWidth,
137+ swipedChannelId: $swipedChannelId,
138+ leftButtonTapped: trailingLeftButtonTapped,
139+ rightButtonTapped: trailingRightButtonTapped
140+ )
141+ return !( view is EmptyView )
142+ #else
143+ return !( trailingSwipeActions is EmptyView )
144+ #endif
126145 }
127146
128147 private var leadingSwipeActions : some View {
@@ -136,7 +155,18 @@ public struct ChatChannelSwipeableListItem<Factory: ViewFactory, ChannelListItem
136155 }
137156
138157 private var showLeadingSwipeActions : Bool {
139- !( leadingSwipeActions is EmptyView )
158+ #if DEBUG
159+ let view = factory. makeLeadingSwipeActionsView (
160+ channel: channel,
161+ offsetX: offsetX,
162+ buttonWidth: buttonWidth,
163+ swipedChannelId: $swipedChannelId,
164+ buttonTapped: leadingButtonTapped
165+ )
166+ return !( view is EmptyView )
167+ #else
168+ return !( leadingSwipeActions is EmptyView )
169+ #endif
140170 }
141171
142172 private func dragChanged( to value: CGFloat ) {
0 commit comments