From ec2512821a438775368b978cca845eec449efcab Mon Sep 17 00:00:00 2001 From: OnestarLee Date: Wed, 21 May 2025 18:28:00 +0900 Subject: [PATCH 1/2] chore: add support for custom FlatList component in message list --- .../src/components/ChannelMessageList/index.tsx | 3 +++ .../src/components/ChatFlatList/index.tsx | 7 +++++-- .../uikit-react-native/src/domain/groupChannel/types.ts | 2 ++ .../src/fragments/createGroupChannelFragment.tsx | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx b/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx index 49989dd4a..9bcc8477e 100644 --- a/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx +++ b/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx @@ -90,6 +90,7 @@ export type ChannelMessageListProps void; newMessages: SendbirdMessage[] }) => React.ReactElement | null); renderScrollToBottomButton: null | ((props: { visible: boolean; onPress: () => void }) => React.ReactElement | null); + flatListComponent?: React.ComponentType>; flatListProps?: Omit, 'data' | 'renderItem'>; } & { ref?: Ref> | undefined; @@ -118,6 +119,7 @@ const ChannelMessageList = )} , 'onEndReached'> & { onBottomReached: () => void; onTopReached: () => void; onScrolledAwayFromBottom: (value: boolean) => void; + flatListComponent?: React.ComponentType>; }; const ChatFlatList = forwardRef(function ChatFlatList( - { onTopReached, onBottomReached, onScrolledAwayFromBottom, onScroll, ...props }, + { onTopReached, onBottomReached, onScrolledAwayFromBottom, onScroll, flatListComponent, ...props }, ref, ) { const { select } = useUIKitTheme(); @@ -60,8 +61,10 @@ const ChatFlatList = forwardRef(function ChatFlatList( ); } + const FlatList = flatListComponent ?? FlatListInternal; + return ( - ): G channel, keyboardAvoidOffset, sortComparator = messageComparator, + flatListComponent, flatListProps, messageListQueryParams, collectionCreator, @@ -267,6 +268,7 @@ const createGroupChannelFragment = (initModule?: Partial): G onResendFailedMessage={resendMessage} onDeleteMessage={deleteMessage} onPressMediaMessage={_onPressMediaMessage} + flatListComponent={flatListComponent} flatListProps={memoizedFlatListProps} /> Date: Wed, 21 May 2025 18:28:00 +0900 Subject: [PATCH 2/2] feat: add flatListComponent to GroupChannelFragment to support custom FlatList in message list --- .../src/components/ChannelMessageList/index.tsx | 3 +++ .../src/components/ChatFlatList/index.tsx | 7 +++++-- .../uikit-react-native/src/domain/groupChannel/types.ts | 2 ++ .../src/fragments/createGroupChannelFragment.tsx | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx b/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx index 49989dd4a..9bcc8477e 100644 --- a/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx +++ b/packages/uikit-react-native/src/components/ChannelMessageList/index.tsx @@ -90,6 +90,7 @@ export type ChannelMessageListProps void; newMessages: SendbirdMessage[] }) => React.ReactElement | null); renderScrollToBottomButton: null | ((props: { visible: boolean; onPress: () => void }) => React.ReactElement | null); + flatListComponent?: React.ComponentType>; flatListProps?: Omit, 'data' | 'renderItem'>; } & { ref?: Ref> | undefined; @@ -118,6 +119,7 @@ const ChannelMessageList = )} , 'onEndReached'> & { onBottomReached: () => void; onTopReached: () => void; onScrolledAwayFromBottom: (value: boolean) => void; + flatListComponent?: React.ComponentType>; }; const ChatFlatList = forwardRef(function ChatFlatList( - { onTopReached, onBottomReached, onScrolledAwayFromBottom, onScroll, ...props }, + { onTopReached, onBottomReached, onScrolledAwayFromBottom, onScroll, flatListComponent, ...props }, ref, ) { const { select } = useUIKitTheme(); @@ -60,8 +61,10 @@ const ChatFlatList = forwardRef(function ChatFlatList( ); } + const FlatList = flatListComponent ?? FlatListInternal; + return ( - ): G channel, keyboardAvoidOffset, sortComparator = messageComparator, + flatListComponent, flatListProps, messageListQueryParams, collectionCreator, @@ -267,6 +268,7 @@ const createGroupChannelFragment = (initModule?: Partial): G onResendFailedMessage={resendMessage} onDeleteMessage={deleteMessage} onPressMediaMessage={_onPressMediaMessage} + flatListComponent={flatListComponent} flatListProps={memoizedFlatListProps} />