Skip to content

Commit c87edb2

Browse files
committed
feat: add flatListComponent to GroupChannelFragment to support custom FlatList in message list
1 parent 16e793c commit c87edb2

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

packages/uikit-react-native/src/components/ChannelMessageList/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export type ChannelMessageListProps<T extends SendbirdGroupChannel | SendbirdOpe
9090
| null
9191
| ((props: { visible: boolean; onPress: () => void; newMessages: SendbirdMessage[] }) => React.ReactElement | null);
9292
renderScrollToBottomButton: null | ((props: { visible: boolean; onPress: () => void }) => React.ReactElement | null);
93+
flatListComponent?: React.ComponentType<FlatListProps<SendbirdMessage>>;
9394
flatListProps?: Omit<FlatListProps<SendbirdMessage>, 'data' | 'renderItem'>;
9495
} & {
9596
ref?: Ref<FlatList<SendbirdMessage>> | undefined;
@@ -118,6 +119,7 @@ const ChannelMessageList = <T extends SendbirdGroupChannel | SendbirdOpenChannel
118119
scrolledAwayFromBottom,
119120
onBottomReached,
120121
onTopReached,
122+
flatListComponent,
121123
flatListProps,
122124
onPressNewMessagesButton,
123125
onPressScrollToBottomButton,
@@ -165,6 +167,7 @@ const ChannelMessageList = <T extends SendbirdGroupChannel | SendbirdOpenChannel
165167
<ChannelFrozenBanner style={styles.frozenBanner} text={STRINGS.LABELS.CHANNEL_MESSAGE_LIST_FROZEN} />
166168
)}
167169
<ChatFlatList
170+
flatListComponent={flatListComponent}
168171
{...flatListProps}
169172
onTopReached={onTopReached}
170173
onBottomReached={onBottomReached}

packages/uikit-react-native/src/components/ChatFlatList/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ type Props = Omit<FlatListProps<SendbirdMessage>, 'onEndReached'> & {
2525
onBottomReached: () => void;
2626
onTopReached: () => void;
2727
onScrolledAwayFromBottom: (value: boolean) => void;
28+
flatListComponent?: React.ComponentType<FlatListProps<SendbirdMessage>>;
2829
};
2930
const ChatFlatList = forwardRef<RNFlatList, Props>(function ChatFlatList(
30-
{ onTopReached, onBottomReached, onScrolledAwayFromBottom, onScroll, ...props },
31+
{ onTopReached, onBottomReached, onScrolledAwayFromBottom, onScroll, flatListComponent, ...props },
3132
ref,
3233
) {
3334
const { select } = useUIKitTheme();
@@ -60,8 +61,10 @@ const ChatFlatList = forwardRef<RNFlatList, Props>(function ChatFlatList(
6061
);
6162
}
6263

64+
const FlatList = flatListComponent ?? FlatListInternal;
65+
6366
return (
64-
<FlatListInternal
67+
<FlatList
6568
bounces={false}
6669
removeClippedSubviews
6770
keyboardDismissMode={'on-drag'}

packages/uikit-react-native/src/domain/groupChannel/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface GroupChannelProps {
4646
enableMessageGrouping?: GroupChannelProps['MessageList']['enableMessageGrouping'];
4747

4848
keyboardAvoidOffset?: GroupChannelProps['Provider']['keyboardAvoidOffset'];
49+
flatListComponent?: GroupChannelProps['MessageList']['flatListComponent'];
4950
flatListProps?: GroupChannelProps['MessageList']['flatListProps'];
5051
sortComparator?: UseGroupChannelMessagesOptions['sortComparator'];
5152

@@ -84,6 +85,7 @@ export interface GroupChannelProps {
8485
| 'renderMessage'
8586
| 'renderNewMessagesButton'
8687
| 'renderScrollToBottomButton'
88+
| 'flatListComponent'
8789
| 'flatListProps'
8890
| 'hasNext'
8991
| 'searchItem'

packages/uikit-react-native/src/fragments/createGroupChannelFragment.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
6060
channel,
6161
keyboardAvoidOffset,
6262
sortComparator = messageComparator,
63+
flatListComponent,
6364
flatListProps,
6465
messageListQueryParams,
6566
collectionCreator,
@@ -267,6 +268,7 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
267268
onResendFailedMessage={resendMessage}
268269
onDeleteMessage={deleteMessage}
269270
onPressMediaMessage={_onPressMediaMessage}
271+
flatListComponent={flatListComponent}
270272
flatListProps={memoizedFlatListProps}
271273
/>
272274
<GroupChannelModule.Input

0 commit comments

Comments
 (0)