-
Notifications
You must be signed in to change notification settings - Fork 373
Expand file tree
/
Copy pathChatScreenHeader.tsx
More file actions
70 lines (61 loc) · 2.23 KB
/
ChatScreenHeader.tsx
File metadata and controls
70 lines (61 loc) · 2.23 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import { Image, StyleSheet, TouchableOpacity } from 'react-native';
import { CompositeNavigationProp, useNavigation } from '@react-navigation/native';
import { useChatContext, useTheme } from 'stream-chat-react-native';
import { RoundButton } from './RoundButton';
import { ScreenHeader } from './ScreenHeader';
import { useAppContext } from '../context/AppContext';
import { NewDirectMessageIcon } from '../icons/NewDirectMessageIcon';
import type { DrawerNavigationProp } from '@react-navigation/drawer';
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
import type { DrawerNavigatorParamList, StackNavigatorParamList } from '../types';
import { NetworkDownIndicator } from './NetworkDownIndicator';
const styles = StyleSheet.create({
avatar: {
borderRadius: 20,
height: 40,
width: 40,
},
});
type ChatScreenHeaderNavigationProp = CompositeNavigationProp<
DrawerNavigationProp<DrawerNavigatorParamList>,
NativeStackNavigationProp<StackNavigatorParamList>
>;
export const ChatScreenHeader: React.FC<{ title?: string }> = ({ title = 'Stream Chat' }) => {
const {
theme: {
colors: { accent_blue },
},
} = useTheme();
const navigation = useNavigation<ChatScreenHeaderNavigationProp>();
const { chatClient } = useAppContext();
const { isOnline } = useChatContext();
return (
<ScreenHeader
// eslint-disable-next-line react/no-unstable-nested-components
LeftContent={() => (
<TouchableOpacity onPress={navigation.openDrawer}>
<Image
source={{
uri: chatClient?.user?.image,
}}
style={styles.avatar}
/>
</TouchableOpacity>
)}
// eslint-disable-next-line react/no-unstable-nested-components
RightContent={() => (
<RoundButton
onPress={() => {
navigation.navigate('NewDirectMessagingScreen');
}}
>
<NewDirectMessageIcon active color={accent_blue} height={25} width={25} />
</RoundButton>
)}
// eslint-disable-next-line react/no-unstable-nested-components
Title={isOnline ? undefined : () => <NetworkDownIndicator titleSize='large' />}
titleText={title}
/>
);
};