aboutsummaryrefslogtreecommitdiff
path: root/src/components/messages/MessagesHeader.tsx
blob: 2b20f48c25c5fef23e5df4cfaa03f6833f9e4989 (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
53
54
55
import React, {useContext} from 'react';
import {StyleSheet, View} from 'react-native';
import {Text} from 'react-native-animatable';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {normalize} from '../../utils';
import ComposeIcon from '../../assets/icons/compose.svg';
import {ChatContext} from '../../App';

type MessagesHeaderProps = {
  createChannel: () => void;
};

const MessagesHeader: React.FC<MessagesHeaderProps> = ({createChannel}) => {
  const {chatClient} = useContext(ChatContext);
  const unread = chatClient.user?.total_unread_count as number;
  return (
    <View style={styles.header}>
      <Text style={styles.headerText}>Messages</Text>
      {unread && unread !== 0 && (
        <Text style={styles.unreadText}>{unread} unread</Text>
      )}
      <View style={styles.flex} />
      <TouchableOpacity style={styles.compose} onPress={createChannel}>
        <ComposeIcon width={normalize(20)} height={normalize(20)} />
      </TouchableOpacity>
    </View>
  );
};

const styles = StyleSheet.create({
  flex: {
    flex: 1,
  },
  header: {
    marginHorizontal: '8%',
    marginTop: '5%',
    alignItems: 'center',
    flexDirection: 'row',
  },
  headerText: {
    fontWeight: '700',
    fontSize: normalize(18),
    lineHeight: normalize(21),
  },
  unreadText: {
    color: '#8F01FF',
    marginLeft: 10,
    fontWeight: '700',
    lineHeight: normalize(17),
    fontSize: normalize(14),
  },
  compose: {},
});

export default MessagesHeader;