diff --git a/app/views/RoomInfoView/components/RoomInfoViewTitle.tsx b/app/views/RoomInfoView/components/RoomInfoViewTitle.tsx index 70f0892c1..623fb0b85 100644 --- a/app/views/RoomInfoView/components/RoomInfoViewTitle.tsx +++ b/app/views/RoomInfoView/components/RoomInfoViewTitle.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { Text, View } from 'react-native'; +import Clipboard from '@react-native-clipboard/clipboard'; import { ISubscription, SubscriptionType } from '../../../definitions'; import styles from '../styles'; @@ -7,6 +8,9 @@ import { useTheme } from '../../../theme'; import RoomTypeIcon from '../../../containers/RoomTypeIcon'; import { getRoomTitle } from '../../../lib/methods/helpers'; import CollapsibleText from '../../../containers/CollapsibleText'; +import EventEmitter from '../../../lib/methods/helpers/events'; +import { LISTENER } from '../../../containers/Toast'; +import I18n from '../../../i18n'; interface IRoomInfoViewTitle { room?: ISubscription; @@ -18,14 +22,27 @@ interface IRoomInfoViewTitle { const RoomInfoViewTitle = ({ room, name, username, statusText, type }: IRoomInfoViewTitle): React.ReactElement => { const { colors } = useTheme(); + + const copyInfoToClipboard = (data: string) => { + Clipboard.setString(data); + EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') }); + }; + if (type === SubscriptionType.DIRECT) { return ( - - {name} - + {name && ( + copyInfoToClipboard(name)} + testID='room-info-view-name' + style={[styles.roomTitle, { color: colors.titleText }]} + > + {name} + + )} {username && ( copyInfoToClipboard(username)} testID='room-info-view-username' style={[styles.roomUsername, { color: colors.auxiliaryText }]} >{`@${username}`}