aboutsummaryrefslogtreecommitdiff
path: root/src/screens/chat/ChatScreen.tsx
blob: 386feb03fbef3ae6ec20892b6d93264ec83f72b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {useBottomTabBarHeight} from '@react-navigation/bottom-tabs';
import {StackNavigationProp} from '@react-navigation/stack';
import React, {useContext} from 'react';
import {StyleSheet} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import {
  Channel,
  Chat,
  MessageInput,
  MessageList,
} from 'stream-chat-react-native';
import {ChatContext} from '../../App';
import ChatHeader from '../../components/messages/ChatHeader';
import {MainStackParams} from '../../routes';
import {isIPhoneX} from '../../utils';

type ChatScreenNavigationProp = StackNavigationProp<MainStackParams, 'Chat'>;
interface ChatScreenProps {
  navigation: ChatScreenNavigationProp;
}
/*
 * Screen that displays all of the user's active conversations.
 */
const ChatScreen: React.FC<ChatScreenProps> = () => {
  const {channel, chatClient} = useContext(ChatContext);
  const tabbarHeight = useBottomTabBarHeight();

  return (
    <SafeAreaView
      style={[
        styles.container,
        {paddingBottom: isIPhoneX() ? tabbarHeight + 20 : tabbarHeight + 50},
      ]}>
      <ChatHeader />
      <Chat client={chatClient}>
        <Channel channel={channel} keyboardVerticalOffset={0}>
          <MessageList onThreadSelect={() => {}} />
          <MessageInput />
        </Channel>
      </Chat>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    backgroundColor: 'white',
    flex: 1,
  },
});

export default ChatScreen;