2018-07-20 19:54:46 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { View, Text, StyleSheet } from 'react-native';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import moment from 'moment';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import Markdown from '../message/Markdown';
|
2019-03-01 16:49:11 +00:00
|
|
|
import { CustomIcon } from '../../lib/Icons';
|
2018-07-20 19:54:46 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
2018-09-11 16:32:52 +00:00
|
|
|
flexDirection: 'row',
|
|
|
|
marginTop: 10,
|
|
|
|
backgroundColor: '#fff'
|
2018-07-20 19:54:46 +00:00
|
|
|
},
|
|
|
|
messageContainer: {
|
|
|
|
flex: 1,
|
2018-09-11 16:32:52 +00:00
|
|
|
marginHorizontal: 10,
|
2018-07-20 19:54:46 +00:00
|
|
|
backgroundColor: '#F3F4F5',
|
|
|
|
paddingHorizontal: 15,
|
|
|
|
paddingVertical: 10,
|
2018-09-11 16:32:52 +00:00
|
|
|
borderRadius: 4
|
2018-07-20 19:54:46 +00:00
|
|
|
},
|
|
|
|
header: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
alignItems: 'center'
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
color: '#1D74F5',
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: '500'
|
|
|
|
},
|
|
|
|
time: {
|
|
|
|
color: '#9EA2A8',
|
|
|
|
fontSize: 12,
|
|
|
|
lineHeight: 16,
|
|
|
|
marginLeft: 5
|
|
|
|
},
|
|
|
|
close: {
|
2018-09-11 16:32:52 +00:00
|
|
|
marginRight: 10
|
2018-07-20 19:54:46 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
@connect(state => ({
|
2018-09-11 16:32:52 +00:00
|
|
|
Message_TimeFormat: state.settings.Message_TimeFormat,
|
|
|
|
customEmojis: state.customEmojis,
|
|
|
|
baseUrl: state.settings.Site_Url || state.server ? state.server.server : ''
|
2018-07-20 19:54:46 +00:00
|
|
|
}))
|
|
|
|
export default class ReplyPreview extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
message: PropTypes.object.isRequired,
|
|
|
|
Message_TimeFormat: PropTypes.string.isRequired,
|
2018-09-11 16:32:52 +00:00
|
|
|
close: PropTypes.func.isRequired,
|
|
|
|
customEmojis: PropTypes.object.isRequired,
|
|
|
|
baseUrl: PropTypes.string.isRequired,
|
|
|
|
username: PropTypes.string.isRequired
|
2018-07-20 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 10:55:35 +00:00
|
|
|
shouldComponentUpdate() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-20 19:54:46 +00:00
|
|
|
close = () => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { close } = this.props;
|
|
|
|
close();
|
2018-07-20 19:54:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-09-11 16:32:52 +00:00
|
|
|
const {
|
|
|
|
message, Message_TimeFormat, customEmojis, baseUrl, username
|
|
|
|
} = this.props;
|
2018-07-20 19:54:46 +00:00
|
|
|
const time = moment(message.ts).format(Message_TimeFormat);
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<View style={styles.messageContainer}>
|
|
|
|
<View style={styles.header}>
|
|
|
|
<Text style={styles.username}>{message.u.username}</Text>
|
|
|
|
<Text style={styles.time}>{time}</Text>
|
|
|
|
</View>
|
2018-09-11 16:32:52 +00:00
|
|
|
<Markdown msg={message.msg} customEmojis={customEmojis} baseUrl={baseUrl} username={username} />
|
2018-07-20 19:54:46 +00:00
|
|
|
</View>
|
2019-03-01 16:49:11 +00:00
|
|
|
<CustomIcon name='cross' color='#9ea2a8' size={20} style={styles.close} onPress={this.close} />
|
2018-07-20 19:54:46 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|