jiti-meet/react/features/chat/components/native/MessageRecipient.js

74 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-10-07 12:35:04 +00:00
// @flow
import React from 'react';
import { Text, TouchableHighlight, View } from 'react-native';
2019-10-15 14:08:23 +00:00
import { ColorSchemeRegistry } from '../../../base/color-scheme';
2019-10-07 12:35:04 +00:00
import { translate } from '../../../base/i18n';
import { Icon, IconCancelSelection } from '../../../base/icons';
import { connect } from '../../../base/redux';
2019-10-15 14:08:23 +00:00
import { type StyleType } from '../../../base/styles';
2019-10-07 12:35:04 +00:00
import AbstractMessageRecipient, {
_mapDispatchToProps,
2019-10-15 14:08:23 +00:00
_mapStateToProps as _abstractMapStateToProps,
type Props as AbstractProps
2019-10-07 12:35:04 +00:00
} from '../AbstractMessageRecipient';
2019-10-15 14:08:23 +00:00
type Props = AbstractProps & {
/**
* The color-schemed stylesheet of the feature.
*/
_styles: StyleType
};
2019-10-07 12:35:04 +00:00
/**
* Class to implement the displaying of the recipient of the next message.
*/
2019-10-15 14:08:23 +00:00
class MessageRecipient extends AbstractMessageRecipient<Props> {
2019-10-07 12:35:04 +00:00
/**
* Implements {@code PureComponent#render}.
*
* @inheritdoc
*/
render() {
2019-10-15 14:08:23 +00:00
const { _privateMessageRecipient, _styles } = this.props;
2019-10-07 12:35:04 +00:00
if (!_privateMessageRecipient) {
return null;
}
const { t } = this.props;
return (
2019-10-15 14:08:23 +00:00
<View style = { _styles.messageRecipientContainer }>
<Text style = { _styles.messageRecipientText }>
2019-10-07 12:35:04 +00:00
{ t('chat.messageTo', {
recipient: _privateMessageRecipient
}) }
</Text>
<TouchableHighlight onPress = { this.props._onRemovePrivateMessageRecipient }>
<Icon
src = { IconCancelSelection }
2019-10-15 14:08:23 +00:00
style = { _styles.messageRecipientCancelIcon } />
2019-10-07 12:35:04 +00:00
</TouchableHighlight>
</View>
);
}
}
2019-10-15 14:08:23 +00:00
/**
* Maps part of the redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @returns {Props}
*/
function _mapStateToProps(state) {
return {
..._abstractMapStateToProps(state),
_styles: ColorSchemeRegistry.get(state, 'Chat')
};
}
2019-10-07 12:35:04 +00:00
export default translate(connect(_mapStateToProps, _mapDispatchToProps)(MessageRecipient));