Skip to content

Commit 2df5b6f

Browse files
committed
feat: add render support for newMessagesBannerComponent
1 parent 303497f commit 2df5b6f

File tree

1 file changed

+53
-17
lines changed

1 file changed

+53
-17
lines changed

src/CuteChat.tsx

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import {
1414
Alert,
1515
FlatList,
1616
NativeScrollEvent,
17+
StyleProp,
1718
TouchableOpacity,
1819
View,
20+
ViewStyle,
1921
} from 'react-native';
2022
import type { IMessage } from 'react-native-gifted-chat';
2123
import { GiftedChat, GiftedChatProps } from 'react-native-gifted-chat';
@@ -29,6 +31,8 @@ interface CustomCuteChatProps {
2931
user: User;
3032
onSend?: (newMessages: IMessage[]) => void;
3133
setIsLoading?: (isLoading: boolean) => void;
34+
newMessagesBannerComponent?: () => React.ReactNode;
35+
newMessagesBannerStyles?: StyleProp<ViewStyle>;
3236
}
3337

3438
interface User {
@@ -306,23 +310,55 @@ export function CuteChat(props: CuteChatProps) {
306310
// - New messages banner
307311
renderChatFooter={() => (
308312
<>
309-
{!closeToTop && props.scrollToBottomComponent && (
310-
<TouchableOpacity
311-
onPress={scrollToBottom}
312-
style={
313-
props.scrollToBottomStyle ?? {
314-
position: 'absolute',
315-
bottom: 30,
316-
right: 20,
317-
backgroundColor: 'rgba(255, 255, 255, 0.8)',
318-
padding: 10,
319-
borderRadius: 100,
320-
}
321-
}
322-
>
323-
{props.scrollToBottomComponent()}
324-
</TouchableOpacity>
325-
)}
313+
<View
314+
style={{
315+
display: 'flex',
316+
position: 'absolute',
317+
flexDirection: 'row',
318+
justifyContent: 'flex-start',
319+
backgroundColor: 'rgba(255, 255, 255, 0.8)',
320+
width: '100%',
321+
height: 100,
322+
bottom: 0,
323+
left: 0,
324+
}}
325+
>
326+
<View style={{ display: 'flex', flex: 1 }}></View>
327+
<View style={{ display: 'flex', flex: 1 }}>
328+
{!closeToTop && props.newMessagesBannerComponent && (
329+
<TouchableOpacity
330+
onPress={scrollToBottom}
331+
style={
332+
props.newMessagesBannerStyles ?? {
333+
alignSelf: 'center',
334+
backgroundColor: 'rgba(255, 255, 255, 0.8)',
335+
padding: 10,
336+
borderRadius: 100,
337+
}
338+
}
339+
>
340+
{props.newMessagesBannerComponent()}
341+
</TouchableOpacity>
342+
)}
343+
</View>
344+
<View style={{ display: 'flex', flex: 1 }}>
345+
{!closeToTop && props.scrollToBottomComponent && (
346+
<TouchableOpacity
347+
onPress={scrollToBottom}
348+
style={
349+
props.scrollToBottomStyle ?? {
350+
alignSelf: 'flex-end',
351+
backgroundColor: 'rgba(255, 255, 255, 0.8)',
352+
padding: 10,
353+
borderRadius: 100,
354+
}
355+
}
356+
>
357+
{props.scrollToBottomComponent()}
358+
</TouchableOpacity>
359+
)}
360+
</View>
361+
</View>
326362
{props.renderChatFooter?.()}
327363
</>
328364
)}

0 commit comments

Comments
 (0)