import {useBottomTabBarHeight} from '@react-navigation/bottom-tabs'; import {StackNavigationProp} from '@react-navigation/stack'; import React, {useContext, useEffect} from 'react'; import {StyleSheet} from 'react-native'; import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context'; import { Channel, Chat, DeepPartial, MessageInput, MessageList, useAttachmentPickerContext, Theme, } from 'stream-chat-react-native'; import {ChatContext} from '../../App'; import { ChatHeader, ChatInput, MessageAvatar, TabsGradient, TypingIndicator, } from '../../components'; import {MainStackParams} from '../../routes'; import {ScreenType} from '../../types'; import {HeaderHeight, isIPhoneX, normalize, SCREEN_WIDTH} from '../../utils'; type ChatScreenNavigationProp = StackNavigationProp; interface ChatScreenProps { navigation: ChatScreenNavigationProp; } /* * Screen that displays all of the user's active conversations. */ const ChatScreen: React.FC = () => { const {channel, chatClient} = useContext(ChatContext); const tabbarHeight = useBottomTabBarHeight(); const {setTopInset} = useAttachmentPickerContext(); const insets = useSafeAreaInsets(); const chatTheme: DeepPartial = { messageList: { container: { backgroundColor: 'white', width: SCREEN_WIDTH * 0.95, alignSelf: 'center', }, }, messageInput: { container: { backgroundColor: '#f8f8f8', height: 70, }, }, avatar: { container: { borderRadius: 10, width: normalize(18), height: normalize(18), }, }, messageSimple: { avatarWrapper: { container: { width: normalize(20), zIndex: 1, bottom: 20, }, }, container: { paddingTop: 8, flexDirection: 'row', }, content: { metaContainer: { marginLeft: 5, }, container: {}, containerInner: { backgroundColor: '#E4F0F2', borderColor: 'transparent', borderBottomLeftRadius: 10, borderTopLeftRadius: 10, borderBottomRightRadius: 10, borderTopRightRadius: 10, }, }, status: { statusContainer: {}, }, }, }; const loggedInUsersMessageTheme = { messageSimple: { content: { containerInner: { backgroundColor: '#DEE6F4', }, container: { left: 0, }, }, }, }; useEffect(() => { setTopInset(insets.top + HeaderHeight); }); return ( null} messageActions={({copyMessage, deleteMessage}) => [ copyMessage, deleteMessage, ]} TypingIndicator={TypingIndicator} myMessageTheme={loggedInUsersMessageTheme} MessageAvatar={MessageAvatar}> {}} /> {/* */} ); }; const styles = StyleSheet.create({ container: { backgroundColor: 'white', flex: 1, }, }); export default ChatScreen;