Skip to content

Commit 19e0289

Browse files
committed
fix: add left swipe for right aligned message
1 parent ba6636b commit 19e0289

File tree

1 file changed

+60
-29
lines changed

1 file changed

+60
-29
lines changed

package/src/components/Message/MessageSimple/MessageSimple.tsx

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ const MessageSimpleWithContext = <
190190

191191
const repliesCurveColor = isMessageReceivedOrErrorType ? grey_gainsboro : backgroundColor;
192192

193+
const renderMessageBubble = (
194+
<>
195+
<MessageContent
196+
backgroundColor={backgroundColor}
197+
noBorder={noBorder}
198+
setMessageContentWidth={setMessageContentWidth}
199+
/>
200+
{reactionListPosition === 'top' && ReactionListTop ? (
201+
<ReactionListTop messageContentWidth={messageContentWidth} />
202+
) : null}
203+
</>
204+
);
205+
193206
return (
194207
<View
195208
style={[
@@ -249,35 +262,53 @@ const MessageSimpleWithContext = <
249262
{message.pinned ? <MessagePinnedHeader /> : null}
250263
</View>
251264

252-
<Swipeable
253-
containerStyle={[styles.contentWrapper, contentWrapper]}
254-
friction={2}
255-
leftThreshold={enableSwipeToReply ? 100 : 0}
256-
onSwipeableWillOpen={() => {
257-
if (!swipeableRef.current) return;
258-
clearQuotedMessageState();
259-
setQuotedMessageState(message);
260-
triggerHaptic('impactLight');
261-
swipeableRef.current.close();
262-
}}
263-
ref={swipeableRef}
264-
renderLeftActions={() => {
265-
if (alignment === 'left' && enableSwipeToReply) {
266-
return MessageSwipeLeftContent ? <MessageSwipeLeftContent /> : null;
267-
} else {
268-
return null;
269-
}
270-
}}
271-
>
272-
<MessageContent
273-
backgroundColor={backgroundColor}
274-
noBorder={noBorder}
275-
setMessageContentWidth={setMessageContentWidth}
276-
/>
277-
{reactionListPosition === 'top' && ReactionListTop ? (
278-
<ReactionListTop messageContentWidth={messageContentWidth} />
279-
) : null}
280-
</Swipeable>
265+
{alignment === 'left' ? (
266+
<Swipeable
267+
containerStyle={[styles.contentWrapper, contentWrapper]}
268+
friction={2}
269+
leftThreshold={100}
270+
onSwipeableWillOpen={() => {
271+
if (!swipeableRef.current) return;
272+
clearQuotedMessageState();
273+
setQuotedMessageState(message);
274+
triggerHaptic('impactLight');
275+
swipeableRef.current.close();
276+
}}
277+
ref={swipeableRef}
278+
renderLeftActions={() => {
279+
if (enableSwipeToReply) {
280+
return MessageSwipeLeftContent ? <MessageSwipeLeftContent /> : null;
281+
} else {
282+
return null;
283+
}
284+
}}
285+
>
286+
{renderMessageBubble}
287+
</Swipeable>
288+
) : (
289+
<Swipeable
290+
containerStyle={[styles.contentWrapper, contentWrapper]}
291+
friction={2}
292+
rightThreshold={100}
293+
onSwipeableWillOpen={() => {
294+
if (!swipeableRef.current) return;
295+
clearQuotedMessageState();
296+
setQuotedMessageState(message);
297+
triggerHaptic('impactLight');
298+
swipeableRef.current.close();
299+
}}
300+
ref={swipeableRef}
301+
renderRightActions={() => {
302+
if (enableSwipeToReply) {
303+
return MessageSwipeLeftContent ? <MessageSwipeLeftContent /> : null;
304+
} else {
305+
return null;
306+
}
307+
}}
308+
>
309+
{renderMessageBubble}
310+
</Swipeable>
311+
)}
281312

282313
{reactionListPosition === 'bottom' && ReactionListBottom ? <ReactionListBottom /> : null}
283314
<MessageReplies noBorder={noBorder} repliesCurveColor={repliesCurveColor} />

0 commit comments

Comments
 (0)