Skip to content

Instantly share code, notes, and snippets.

@vishalnarkhede
Created April 7, 2020 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishalnarkhede/4d30732665c7fd85dc4e884d48247a5f to your computer and use it in GitHub Desktop.
Save vishalnarkhede/4d30732665c7fd85dc4e884d48247a5f to your computer and use it in GitHub Desktop.
import React from 'react';
import {View, Text, StyleSheet} from 'react-native';
import Moment from 'moment';
export const MessageHeader = props => {
return (
<View style={styles.column}>
{props.message.attachments.length > 0 && (
<View style={styles.header}>
<MessageUserBar {...props} />
</View>
)}
</View>
);
};
export const MessageUserBar = ({groupStyles, message}) => {
if (groupStyles[0] === 'single' || groupStyles[0] === 'top') {
return (
<View style={styles.userBar}>
<Text style={styles.messageUserName}>{message.user.name}</Text>
<Text style={styles.messageDate}>
{Moment(message.created_at).format('hh:ss A')}
</Text>
</View>
);
}
return null;
};
const styles = StyleSheet.create({
column: {
flexDirection: 'column',
},
header: {
paddingLeft: 8,
},
userBar: {
flexDirection: 'row',
alignItems: 'center',
marginBottom: 5,
},
messageUserName: {
fontWeight: '900',
color: 'black',
fontSize: 15,
fontFamily: 'Lato-Bold',
},
messageDate: {
color: 'grey',
marginLeft: 6,
fontSize: 10,
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment