diff options
author | Ivan Chen <ivan@tagg.id> | 2021-04-09 17:15:29 -0400 |
---|---|---|
committer | Ivan Chen <ivan@tagg.id> | 2021-04-09 17:15:29 -0400 |
commit | 347e9e450268e4897b8dd241721b84945d9e2ec9 (patch) | |
tree | 58334be3724398c886365e99901e4442f5657172 /src/components/messages/MessagesHeader.tsx | |
parent | 097b515066f1a0c38cb7fb69cf78b16b945594e5 (diff) | |
parent | 3ec56863bfdd47b2ee8d0f0fe5a45be779508660 (diff) |
Merge branch 'master' into tma756-bugfix-onpress-tagg-on-sp
# Conflicts:
# src/components/taggs/TaggsBar.tsx
Diffstat (limited to 'src/components/messages/MessagesHeader.tsx')
-rw-r--r-- | src/components/messages/MessagesHeader.tsx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/components/messages/MessagesHeader.tsx b/src/components/messages/MessagesHeader.tsx new file mode 100644 index 00000000..660da97d --- /dev/null +++ b/src/components/messages/MessagesHeader.tsx @@ -0,0 +1,59 @@ +import React, {Fragment, 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 > 99 ? '99+' : unread} unread + </Text> + ) : ( + <Fragment /> + )} + <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; |