diff --git a/native/chat/message-reactions-modal.react.js b/native/chat/message-reactions-modal.react.js --- a/native/chat/message-reactions-modal.react.js +++ b/native/chat/message-reactions-modal.react.js @@ -15,6 +15,7 @@ import type { RootNavigationProp } from '../navigation/root-navigator.react.js'; import type { NavigationRoute } from '../navigation/route-names.js'; import { useColors, useStyles } from '../themes/colors.js'; +import { useShouldRenderAvatars } from '../utils/avatar-utils.js'; export type MessageReactionsModalParams = { +reactions: ReactionInfo, @@ -38,6 +39,14 @@ const reactionsListData = useMessageReactionsList(reactions); + const shouldRenderAvatars = useShouldRenderAvatars(); + const marginLeftStyle = React.useMemo( + () => ({ + marginLeft: shouldRenderAvatars ? 8 : 0, + }), + [shouldRenderAvatars], + ); + const renderItem = React.useCallback( ({ item }) => { const avatarInfo = getAvatarForUser(item); @@ -46,7 +55,7 @@ - + {item.username} @@ -55,6 +64,7 @@ ); }, [ + marginLeftStyle, styles.reactionsListReactionText, styles.reactionsListRowContainer, styles.reactionsListUserInfoContainer, @@ -136,7 +146,6 @@ reactionsListUsernameText: { color: 'modalForegroundLabel', fontSize: 18, - marginLeft: 8, }, reactionsListReactionText: { fontSize: 18, diff --git a/native/chat/settings/thread-settings-member.react.js b/native/chat/settings/thread-settings-member.react.js --- a/native/chat/settings/thread-settings-member.react.js +++ b/native/chat/settings/thread-settings-member.react.js @@ -45,6 +45,7 @@ import { useSelector } from '../../redux/redux-utils.js'; import { type Colors, useColors, useStyles } from '../../themes/colors.js'; import type { VerticalBounds } from '../../types/layout-types.js'; +import { useShouldRenderAvatars } from '../../utils/avatar-utils.js'; type BaseProps = { +memberInfo: RelativeMemberInfo, @@ -67,6 +68,7 @@ +keyboardState: ?KeyboardState, // withOverlayContext +overlayContext: ?OverlayContextType, + +shouldRenderAvatars: boolean, }; class ThreadSettingsMember extends React.PureComponent { editButton: ?React.ElementRef; @@ -74,15 +76,26 @@ render() { const userText = stringForUser(this.props.memberInfo); const avatarInfo = getAvatarForUser(this.props.memberInfo); + + const marginLeftStyle = { + marginLeft: this.props.shouldRenderAvatars ? 8 : 0, + }; + let usernameInfo = null; if (this.props.memberInfo.username) { usernameInfo = ( - {userText} + + {userText} + ); } else { usernameInfo = ( {userText} @@ -257,7 +270,6 @@ flex: 1, fontSize: 16, lineHeight: 20, - marginLeft: 8, }, }; @@ -285,6 +297,8 @@ const styles = useStyles(unboundStyles); const keyboardState = React.useContext(KeyboardContext); const overlayContext = React.useContext(OverlayContext); + const shouldRenderAvatars = useShouldRenderAvatars(); + return ( ); }); diff --git a/native/chat/typeahead-tooltip.react.js b/native/chat/typeahead-tooltip.react.js --- a/native/chat/typeahead-tooltip.react.js +++ b/native/chat/typeahead-tooltip.react.js @@ -15,6 +15,7 @@ import Avatar from '../components/avatar.react.js'; import Button from '../components/button.react.js'; import { useStyles } from '../themes/colors.js'; +import { useShouldRenderAvatars } from '../utils/avatar-utils.js'; export type TypeaheadTooltipProps = { +text: string, @@ -31,10 +32,19 @@ focusAndUpdateTextAndSelection, } = props; + const shouldRenderAvatars = useShouldRenderAvatars(); + const { textBeforeAtSymbol, usernamePrefix } = matchedStrings; const styles = useStyles(unboundStyles); + const marginLeftStyle = React.useMemo( + () => ({ + marginLeft: shouldRenderAvatars ? 8 : 0, + }), + [shouldRenderAvatars], + ); + const renderTypeaheadButton = React.useCallback( ({ item }: { item: RelativeMemberInfo, ... }) => { const onPress = () => { @@ -56,19 +66,20 @@ return ( ); }, [ - focusAndUpdateTextAndSelection, styles.button, styles.buttonLabel, - text, + marginLeftStyle, textBeforeAtSymbol, + text, usernamePrefix, + focusAndUpdateTextAndSelection, ], ); @@ -148,7 +159,6 @@ color: 'white', fontSize: 16, fontWeight: '400', - marginLeft: 8, }, }; diff --git a/native/components/avatar.react.js b/native/components/avatar.react.js --- a/native/components/avatar.react.js +++ b/native/components/avatar.react.js @@ -5,6 +5,8 @@ import type { ClientAvatar } from 'lib/types/avatar-types.js'; +import { useShouldRenderAvatars } from '../utils/avatar-utils.js'; + type Props = { +avatarInfo: ClientAvatar, +size?: 'large' | 'small' | 'profile' | 'micro', @@ -13,6 +15,8 @@ function Avatar(props: Props): React.Node { const { avatarInfo, size } = props; + const shouldRenderAvatars = useShouldRenderAvatars(); + const containerSizeStyle = React.useMemo(() => { if (size === 'profile') { return styles.profile; @@ -45,6 +49,10 @@ return styles.emojiLarge; }, [size]); + if (!shouldRenderAvatars) { + return null; + } + return ( {avatarInfo.emoji} diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js --- a/native/profile/profile-screen.react.js +++ b/native/profile/profile-screen.react.js @@ -39,6 +39,7 @@ } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; import { type Colors, useColors, useStyles } from '../themes/colors.js'; +import { useShouldRenderAvatars } from '../utils/avatar-utils.js'; import { useStaffCanSee } from '../utils/staff-utils.js'; type ProfileRowProps = { @@ -73,6 +74,7 @@ +staffCanSee: boolean, +stringForUser: ?string, +isAccountWithPassword: boolean, + +shouldRenderAvatars: boolean, }; class ProfileScreen extends React.PureComponent { @@ -128,14 +130,23 @@ ); + let avatarSection; + if (this.props.shouldRenderAvatars) { + avatarSection = ( + <> + USER AVATAR + {avatar} + + ); + } + return ( - USER AVATAR - {avatar} + {avatarSection} ACCOUNT @@ -395,6 +406,7 @@ const isAccountWithPassword = useSelector(state => accountHasPassword(state.currentUserInfo), ); + const shouldRenderAvatars = useShouldRenderAvatars(); return ( ); }); diff --git a/native/profile/relationship-list-item.react.js b/native/profile/relationship-list-item.react.js --- a/native/profile/relationship-list-item.react.js +++ b/native/profile/relationship-list-item.react.js @@ -55,6 +55,7 @@ import { useSelector } from '../redux/redux-utils.js'; import { type Colors, useColors, useStyles } from '../themes/colors.js'; import type { VerticalBounds } from '../types/layout-types.js'; +import { useShouldRenderAvatars } from '../utils/avatar-utils.js'; type BaseProps = { +userInfo: AccountUserInfo, @@ -80,6 +81,7 @@ +overlayContext: ?OverlayContextType, // withKeyboardState +keyboardState: ?KeyboardState, + +shouldRenderAvatars: boolean, }; class RelationshipListItem extends React.PureComponent { editButton = React.createRef>(); @@ -171,13 +173,17 @@ ); } + const marginLeftStyle = { + marginLeft: this.props.shouldRenderAvatars ? 8 : 0, + }; + const avatarInfo = getAvatarForUser(this.props.userInfo); return ( - + {this.props.userInfo.username} {editButton} @@ -334,6 +340,8 @@ const boundUpdateRelationships = useServerCall(updateRelationships); const overlayContext = React.useContext(OverlayContext); const keyboardState = React.useContext(KeyboardContext); + const shouldRenderAvatars = useShouldRenderAvatars(); + return ( ); }); diff --git a/native/utils/avatar-utils.js b/native/utils/avatar-utils.js new file mode 100644 --- /dev/null +++ b/native/utils/avatar-utils.js @@ -0,0 +1,14 @@ +// @flow + +import * as React from 'react'; + +import { FeatureFlagsContext } from '../components/feature-flags-provider.react.js'; + +function useShouldRenderAvatars(): boolean { + const { configuration: featureFlagConfig } = + React.useContext(FeatureFlagsContext); + + return !!featureFlagConfig['AVATARS_DISPLAY']; +} + +export { useShouldRenderAvatars };