From 9a0e85ce1d4f83baa80541399ac55ed9a288b2fd Mon Sep 17 00:00:00 2001 From: Martin Mitrevski Date: Wed, 11 Sep 2024 12:31:04 +0200 Subject: [PATCH] iOS 18 fixes for the swipeable channel list item (#601) --- .../MessageList/MessageListConfig.swift | 2 +- .../ChatChannelSwipeableListItem.swift | 40 ++++++++++++++++--- .../DefaultViewFactory.swift | 4 +- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift index d76096c4..d68bd92d 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListConfig.swift @@ -136,7 +136,7 @@ public struct MessageDisplayOptions { overlayDateLabelSize: CGFloat = 40, lastInGroupHeaderSize: CGFloat = 0, newMessagesSeparatorSize: CGFloat = 50, - minimumSwipeGestureDistance: CGFloat = 10, + minimumSwipeGestureDistance: CGFloat = 20, currentUserMessageTransition: AnyTransition = .identity, otherUserMessageTransition: AnyTransition = .identity, shouldAnimateReactions: Bool = true, diff --git a/Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelSwipeableListItem.swift b/Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelSwipeableListItem.swift index b02cca9a..ef70e947 100644 --- a/Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelSwipeableListItem.swift +++ b/Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelSwipeableListItem.swift @@ -41,6 +41,8 @@ public struct ChatChannelSwipeableListItem Void private var trailingLeftButtonTapped: (ChatChannel) -> Void private var leadingButtonTapped: (ChatChannel) -> Void + + @State private var verticalScrolling = false public init( factory: Factory, @@ -76,7 +78,7 @@ public struct ChatChannelSwipeableListItem abs(value.translation.width) && !verticalScrolling { + verticalScrolling = true + } + if diff == .zero { gestureState = .zero } else { @@ -98,7 +104,8 @@ public struct ChatChannelSwipeableListItem, leftButtonTapped: @escaping (ChatChannel) -> Void, rightButtonTapped: @escaping (ChatChannel) -> Void - ) -> some View { + ) -> TrailingSwipeActionsView { TrailingSwipeActionsView( channel: channel, offsetX: offsetX, @@ -127,7 +127,7 @@ extension ViewFactory { buttonWidth: CGFloat, swipedChannelId: Binding, buttonTapped: (ChatChannel) -> Void - ) -> some View { + ) -> EmptyView { EmptyView() }