Rocket.Chat.ReactNative/app/containers/message/Broadcast.tsx

42 lines
1.3 KiB
TypeScript
Raw Normal View History

import React, { useContext } from 'react';
import { Text, View } from 'react-native';
import Touchable from './Touchable';
import { CustomIcon } from '../../lib/Icons';
import styles from './styles';
import { BUTTON_HIT_SLOP } from './utils';
import I18n from '../../i18n';
import { themes } from '../../lib/constants';
import MessageContext from './Context';
import { IMessageBroadcast } from './interfaces';
import { useTheme } from '../../theme';
const Broadcast = React.memo(({ author, broadcast }: IMessageBroadcast) => {
const { user, replyBroadcast } = useContext(MessageContext);
const { theme } = useTheme();
const isOwn = author?._id === user.id;
if (broadcast && !isOwn) {
return (
<View style={styles.buttonContainer}>
<Touchable
onPress={replyBroadcast}
2019-12-04 16:39:53 +00:00
background={Touchable.Ripple(themes[theme].bannerBackground)}
style={[styles.button, { backgroundColor: themes[theme].tintColor }]}
hitSlop={BUTTON_HIT_SLOP}
testID='message-broadcast-reply'>
<>
2020-07-27 19:53:33 +00:00
<CustomIcon name='arrow-back' size={20} style={styles.buttonIcon} color={themes[theme].buttonText} />
2019-12-04 16:39:53 +00:00
<Text style={[styles.buttonText, { color: themes[theme].buttonText }]}>{I18n.t('Reply')}</Text>
</>
</Touchable>
</View>
);
}
return null;
2019-12-04 16:39:53 +00:00
});
Broadcast.displayName = 'MessageBroadcast';
export default Broadcast;