2017-09-01 19:17:53 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { View, Text, StyleSheet } from 'react-native';
|
|
|
|
import moment from 'moment';
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
2019-03-01 16:49:11 +00:00
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center',
|
|
|
|
marginBottom: 2
|
|
|
|
},
|
2017-09-01 19:17:53 +00:00
|
|
|
username: {
|
2018-09-11 16:32:52 +00:00
|
|
|
color: '#0C0D0F',
|
|
|
|
fontWeight: '600',
|
|
|
|
fontSize: 16,
|
|
|
|
lineHeight: 22
|
2017-09-01 19:17:53 +00:00
|
|
|
},
|
2019-03-01 16:49:11 +00:00
|
|
|
titleContainer: {
|
|
|
|
flex: 1,
|
2017-09-01 19:17:53 +00:00
|
|
|
flexDirection: 'row',
|
2019-03-01 16:49:11 +00:00
|
|
|
alignItems: 'center'
|
2017-09-01 19:17:53 +00:00
|
|
|
},
|
|
|
|
alias: {
|
2018-09-11 16:32:52 +00:00
|
|
|
fontSize: 14,
|
|
|
|
color: '#9EA2A8',
|
|
|
|
paddingLeft: 6,
|
|
|
|
lineHeight: 16
|
2017-09-01 19:17:53 +00:00
|
|
|
},
|
|
|
|
time: {
|
2019-03-01 16:49:11 +00:00
|
|
|
fontSize: 12,
|
2018-09-11 16:32:52 +00:00
|
|
|
color: '#9EA2A8',
|
|
|
|
paddingLeft: 10,
|
|
|
|
fontWeight: '300',
|
|
|
|
lineHeight: 16
|
2017-09-01 19:17:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-11-24 20:44:52 +00:00
|
|
|
export default class User extends React.PureComponent {
|
2017-09-01 19:17:53 +00:00
|
|
|
static propTypes = {
|
2018-09-11 16:32:52 +00:00
|
|
|
timeFormat: PropTypes.string.isRequired,
|
|
|
|
username: PropTypes.string,
|
|
|
|
alias: PropTypes.string,
|
2018-12-12 15:15:10 +00:00
|
|
|
ts: PropTypes.oneOfType([
|
|
|
|
PropTypes.instanceOf(Date),
|
|
|
|
PropTypes.string
|
|
|
|
]),
|
2018-09-19 14:18:32 +00:00
|
|
|
temp: PropTypes.bool
|
2017-11-21 14:55:50 +00:00
|
|
|
}
|
|
|
|
|
2017-09-01 19:17:53 +00:00
|
|
|
render() {
|
2018-09-11 16:32:52 +00:00
|
|
|
const {
|
2018-09-25 19:28:42 +00:00
|
|
|
username, alias, ts, temp, timeFormat
|
2018-09-11 16:32:52 +00:00
|
|
|
} = this.props;
|
2017-09-01 19:17:53 +00:00
|
|
|
|
|
|
|
const extraStyle = {};
|
2018-09-11 16:32:52 +00:00
|
|
|
if (temp) {
|
2017-09-01 19:17:53 +00:00
|
|
|
extraStyle.opacity = 0.3;
|
|
|
|
}
|
|
|
|
|
2018-09-11 16:32:52 +00:00
|
|
|
const aliasUsername = alias ? (<Text style={styles.alias}>@{username}</Text>) : null;
|
2018-09-25 19:28:42 +00:00
|
|
|
const time = moment(ts).format(timeFormat);
|
2017-09-01 19:17:53 +00:00
|
|
|
|
|
|
|
return (
|
2019-03-01 16:49:11 +00:00
|
|
|
<View style={styles.container}>
|
|
|
|
<View style={styles.titleContainer}>
|
|
|
|
<Text style={styles.username}>
|
|
|
|
{alias || username}
|
|
|
|
</Text>
|
|
|
|
{aliasUsername}
|
|
|
|
</View>
|
2017-11-21 14:55:50 +00:00
|
|
|
<Text style={styles.time}>{time}</Text>
|
2017-09-01 19:17:53 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|