From 553ff84e522113057eab5f19770d887ea2d987ff Mon Sep 17 00:00:00 2001 From: Manoj Malik Date: Sat, 10 Jul 2021 01:57:32 +0530 Subject: [PATCH] MM-36591 Custom Statuses: Add custom status to mention autocomplete (#5496) * Added custom status emoji in at mention autocomplete * Fixed the width of the displayname and username * Changed the max width for the full name and username in the autocomplete item * Review fixes Changed the behaviour of ellipses for long names * Fixed the username cutting off after truncating display name issue * Changed the styling for the shared channel icon --- .../at_mention_item/at_mention_item.tsx | 61 ++++++++++++------- .../autocomplete/at_mention_item/index.js | 2 + 2 files changed, 40 insertions(+), 23 deletions(-) diff --git a/app/components/autocomplete/at_mention_item/at_mention_item.tsx b/app/components/autocomplete/at_mention_item/at_mention_item.tsx index 3d8a11e22..891f9bb5a 100644 --- a/app/components/autocomplete/at_mention_item/at_mention_item.tsx +++ b/app/components/autocomplete/at_mention_item/at_mention_item.tsx @@ -6,6 +6,7 @@ import {Text, View} from 'react-native'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; import ChannelIcon from '@components/channel_icon'; +import CustomStatusEmoji from '@components/custom_status/custom_status_emoji'; import FormattedText from '@components/formatted_text'; import ProfilePicture from '@components/profile_picture'; import {BotTag, GuestTag} from '@components/tag'; @@ -29,6 +30,7 @@ interface AtMentionItemProps { theme: Theme; userId: string; username: string; + isCustomStatusEnabled: boolean; } const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => { @@ -50,7 +52,7 @@ const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => { }, rowInfo: { flexDirection: 'row', - flex: 1, + overflow: 'hidden', }, rowFullname: { fontSize: 15, @@ -58,16 +60,17 @@ const getStyleFromTheme = makeStyleSheetFromTheme((theme: Theme) => { paddingLeft: 4, }, rowUsername: { - color: theme.centerChannelColor, + color: changeOpacity(theme.centerChannelColor, 0.56), fontSize: 15, - opacity: 0.56, - flex: 1, + }, + icon: { + marginLeft: 4, }, }; }); const AtMentionItem = ({firstName = '', isBot, isCurrentUser, isGuest, isShared, lastName = '', nickname = '', - onPress, showFullName, testID, theme, userId, username}: AtMentionItemProps) => { + onPress, showFullName, testID, theme, userId, username, isCustomStatusEnabled}: AtMentionItemProps) => { const insets = useSafeAreaInsets(); const completeMention = () => { @@ -112,7 +115,9 @@ const AtMentionItem = ({firstName = '', isBot, isCurrentUser, isGuest, isShared, testID='at_mention_item.profile_picture' /> - + - {Boolean(name.length) && - {name} - - } - - {isCurrentUser && - } - {` @${username}`} + {Boolean(name.length) && ( + + {name} + + )} + + {isCurrentUser && ( + + )} + {` @${username}`} + + {isCustomStatusEnabled && !isBot && ( + + )} {isShared && ( )} diff --git a/app/components/autocomplete/at_mention_item/index.js b/app/components/autocomplete/at_mention_item/index.js index ce10b465c..0b2ef1465 100644 --- a/app/components/autocomplete/at_mention_item/index.js +++ b/app/components/autocomplete/at_mention_item/index.js @@ -7,6 +7,7 @@ import {getConfig} from '@mm-redux/selectors/entities/general'; import {getTheme} from '@mm-redux/selectors/entities/preferences'; import {getCurrentUserId, getUser} from '@mm-redux/selectors/entities/users'; import {isShared} from '@mm-redux/utils/user_utils'; +import {isCustomStatusEnabled} from '@selectors/custom_status'; import {isGuest} from '@utils/users'; import AtMentionItem from './at_mention_item'; @@ -25,6 +26,7 @@ function mapStateToProps(state, ownProps) { isShared: isShared(user), theme: getTheme(state), isCurrentUser: getCurrentUserId(state) === user.id, + isCustomStatusEnabled: isCustomStatusEnabled(state), }; }