-
Notifications
You must be signed in to change notification settings - Fork 4k
Display status emojis in the LHN (including the user's own status) #24414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b7b890d
8e2e717
cdeb9c2
2550706
329ef93
276bfbf
112d340
33ca589
9942d91
1095ae4
0b640c7
8eb30c0
3719c5d
d875895
049fdf1
eb0e965
62274c7
127bebb
2303985
f86e1db
acd581c
17a9c88
ca3fcc1
924bf6e
0cbe2b3
5361750
8c1546a
416ce3d
2216ec6
9126f58
5088e86
a866499
4aea8a5
77dd8b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* eslint-disable rulesdir/onyx-props-must-have-default */ | ||
| import React, {useCallback} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import PropTypes from 'prop-types'; | ||
| import PressableWithoutFeedback from '../../../components/Pressable/PressableWithoutFeedback'; | ||
| import Text from '../../../components/Text'; | ||
| import PressableAvatarWithIndicator from './PressableAvatarWithIndicator'; | ||
| import Navigation from '../../../libs/Navigation/Navigation'; | ||
| import useLocalize from '../../../hooks/useLocalize'; | ||
| import styles from '../../../styles/styles'; | ||
| import ROUTES from '../../../ROUTES'; | ||
| import CONST from '../../../CONST'; | ||
|
|
||
| const propTypes = { | ||
| /** Whether the create menu is open or not */ | ||
| isCreateMenuOpen: PropTypes.bool, | ||
|
|
||
| /** Emoji status */ | ||
| emojiStatus: PropTypes.string, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| isCreateMenuOpen: false, | ||
| emojiStatus: '', | ||
| }; | ||
|
|
||
| function AvatarWithOptionalStatus({emojiStatus, isCreateMenuOpen}) { | ||
| const {translate} = useLocalize(); | ||
|
|
||
| const showStatusPage = useCallback(() => { | ||
| if (isCreateMenuOpen) { | ||
| // Prevent opening Settings page when click profile avatar quickly after clicking FAB icon | ||
| return; | ||
| } | ||
|
|
||
| Navigation.setShouldPopAllStateOnUP(); | ||
| Navigation.navigate(ROUTES.SETTINGS_STATUS); | ||
| }, [isCreateMenuOpen]); | ||
|
|
||
| return ( | ||
| <View style={styles.sidebarStatusAvatarContainer}> | ||
| <PressableWithoutFeedback | ||
| accessibilityLabel={translate('sidebarScreen.buttonMySettings')} | ||
| accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} | ||
| onPress={showStatusPage} | ||
| style={styles.flex1} | ||
| > | ||
| <View style={styles.sidebarStatusAvatar}> | ||
| <Text | ||
| style={styles.emojiStatusLHN} | ||
| numberOfLines={1} | ||
| > | ||
| {emojiStatus} | ||
| </Text> | ||
| </View> | ||
| </PressableWithoutFeedback> | ||
| <PressableAvatarWithIndicator isCreateMenuOpen={isCreateMenuOpen} /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| AvatarWithOptionalStatus.propTypes = propTypes; | ||
| AvatarWithOptionalStatus.defaultProps = defaultProps; | ||
| AvatarWithOptionalStatus.displayName = 'AvatarWithOptionalStatus'; | ||
| export default AvatarWithOptionalStatus; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* eslint-disable rulesdir/onyx-props-must-have-default */ | ||
| import lodashGet from 'lodash/get'; | ||
| import React, {useCallback} from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import withCurrentUserPersonalDetails from '../../../components/withCurrentUserPersonalDetails'; | ||
| import PressableWithoutFeedback from '../../../components/Pressable/PressableWithoutFeedback'; | ||
| import AvatarWithIndicator from '../../../components/AvatarWithIndicator'; | ||
| import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; | ||
| import Navigation from '../../../libs/Navigation/Navigation'; | ||
| import * as UserUtils from '../../../libs/UserUtils'; | ||
| import useLocalize from '../../../hooks/useLocalize'; | ||
| import ROUTES from '../../../ROUTES'; | ||
| import CONST from '../../../CONST'; | ||
| import personalDetailsPropType from '../../personalDetailsPropType'; | ||
|
|
||
| const propTypes = { | ||
| /** Whether the create menu is open or not */ | ||
| isCreateMenuOpen: PropTypes.bool, | ||
|
|
||
| /** The personal details of the person who is logged in */ | ||
| currentUserPersonalDetails: personalDetailsPropType, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| isCreateMenuOpen: false, | ||
| currentUserPersonalDetails: { | ||
| pendingFields: {avatar: ''}, | ||
| accountID: '', | ||
| avatar: '', | ||
| }, | ||
| }; | ||
|
|
||
| function PressableAvatarWithIndicator({isCreateMenuOpen, currentUserPersonalDetails}) { | ||
| const {translate} = useLocalize(); | ||
|
|
||
| const showSettingsPage = useCallback(() => { | ||
| if (isCreateMenuOpen) { | ||
| // Prevent opening Settings page when click profile avatar quickly after clicking FAB icon | ||
| return; | ||
| } | ||
|
|
||
| Navigation.navigate(ROUTES.SETTINGS); | ||
| }, [isCreateMenuOpen]); | ||
|
|
||
| return ( | ||
| <PressableWithoutFeedback | ||
| accessibilityLabel={translate('sidebarScreen.buttonMySettings')} | ||
| accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} | ||
| onPress={showSettingsPage} | ||
| > | ||
| <OfflineWithFeedback pendingAction={lodashGet(currentUserPersonalDetails, 'pendingFields.avatar', null)}> | ||
| <AvatarWithIndicator | ||
| source={UserUtils.getAvatar(currentUserPersonalDetails.avatar, currentUserPersonalDetails.accountID)} | ||
| tooltipText={translate('common.settings')} | ||
| /> | ||
| </OfflineWithFeedback> | ||
| </PressableWithoutFeedback> | ||
| ); | ||
| } | ||
|
|
||
| PressableAvatarWithIndicator.propTypes = propTypes; | ||
| PressableAvatarWithIndicator.defaultProps = defaultProps; | ||
|
perunt marked this conversation as resolved.
|
||
| PressableAvatarWithIndicator.displayName = 'PressableAvatarWithIndicator'; | ||
| export default withCurrentUserPersonalDetails(PressableAvatarWithIndicator); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,31 +14,26 @@ import Navigation from '../../../libs/Navigation/Navigation'; | |
| import ROUTES from '../../../ROUTES'; | ||
| import Icon from '../../../components/Icon'; | ||
| import * as Expensicons from '../../../components/Icon/Expensicons'; | ||
| import AvatarWithIndicator from '../../../components/AvatarWithIndicator'; | ||
| import Tooltip from '../../../components/Tooltip'; | ||
| import CONST from '../../../CONST'; | ||
| import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; | ||
| import * as App from '../../../libs/actions/App'; | ||
| import withCurrentUserPersonalDetails from '../../../components/withCurrentUserPersonalDetails'; | ||
| import withWindowDimensions from '../../../components/withWindowDimensions'; | ||
| import LHNOptionsList from '../../../components/LHNOptionsList/LHNOptionsList'; | ||
| import SidebarUtils from '../../../libs/SidebarUtils'; | ||
| import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; | ||
| import Header from '../../../components/Header'; | ||
| import defaultTheme from '../../../styles/themes/default'; | ||
| import OptionsListSkeletonView from '../../../components/OptionsListSkeletonView'; | ||
| import variables from '../../../styles/variables'; | ||
| import LogoComponent from '../../../../assets/images/expensify-wordmark.svg'; | ||
| import PressableWithoutFeedback from '../../../components/Pressable/PressableWithoutFeedback'; | ||
| import * as Session from '../../../libs/actions/Session'; | ||
| import Button from '../../../components/Button'; | ||
| import * as UserUtils from '../../../libs/UserUtils'; | ||
| import KeyboardShortcut from '../../../libs/KeyboardShortcut'; | ||
| import onyxSubscribe from '../../../libs/onyxSubscribe'; | ||
| import personalDetailsPropType from '../../personalDetailsPropType'; | ||
| import * as ReportActionContextMenu from '../report/ContextMenu/ReportActionContextMenu'; | ||
| import withCurrentReportID from '../../../components/withCurrentReportID'; | ||
| import OptionRowLHNData from '../../../components/LHNOptionsList/OptionRowLHNData'; | ||
| import SignInOrAvatarWithOptionalStatus from './SignInOrAvatarWithOptionalStatus'; | ||
|
|
||
| const basePropTypes = { | ||
| /** Toggles the navigation menu open and closed */ | ||
|
|
@@ -58,8 +53,6 @@ const propTypes = { | |
|
|
||
| isLoading: PropTypes.bool.isRequired, | ||
|
|
||
| currentUserPersonalDetails: personalDetailsPropType, | ||
|
|
||
| priorityMode: PropTypes.oneOf(_.values(CONST.PRIORITY_MODE)), | ||
|
|
||
| /** The top most report id */ | ||
|
|
@@ -75,9 +68,6 @@ const propTypes = { | |
| }; | ||
|
|
||
| const defaultProps = { | ||
| currentUserPersonalDetails: { | ||
| avatar: '', | ||
| }, | ||
| priorityMode: CONST.PRIORITY_MODE.DEFAULT, | ||
| currentReportID: '', | ||
| report: {}, | ||
|
|
@@ -88,7 +78,6 @@ class SidebarLinks extends React.PureComponent { | |
| super(props); | ||
|
|
||
| this.showSearchPage = this.showSearchPage.bind(this); | ||
| this.showSettingsPage = this.showSettingsPage.bind(this); | ||
| this.showReportPage = this.showReportPage.bind(this); | ||
|
|
||
| if (this.props.isSmallScreenWidth) { | ||
|
|
@@ -147,15 +136,6 @@ class SidebarLinks extends React.PureComponent { | |
| Navigation.navigate(ROUTES.SEARCH); | ||
| } | ||
|
|
||
| showSettingsPage() { | ||
| if (this.props.isCreateMenuOpen) { | ||
| // Prevent opening Settings page when click profile avatar quickly after clicking FAB icon | ||
| return; | ||
| } | ||
|
|
||
| Navigation.navigate(ROUTES.SETTINGS); | ||
| } | ||
|
|
||
| /** | ||
| * Show Report page with selected report id | ||
| * | ||
|
|
@@ -204,29 +184,7 @@ class SidebarLinks extends React.PureComponent { | |
| <Icon src={Expensicons.MagnifyingGlass} /> | ||
| </PressableWithoutFeedback> | ||
| </Tooltip> | ||
| <PressableWithoutFeedback | ||
| accessibilityLabel={this.props.translate('sidebarScreen.buttonMySettings')} | ||
| accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} | ||
| onPress={Session.checkIfActionIsAllowed(this.showSettingsPage)} | ||
| > | ||
| {Session.isAnonymousUser() ? ( | ||
| <View style={styles.signInButtonAvatar}> | ||
| <Button | ||
| medium | ||
| success | ||
| text={this.props.translate('common.signIn')} | ||
| onPress={() => Session.signOutAndRedirectToSignIn()} | ||
| /> | ||
| </View> | ||
| ) : ( | ||
| <OfflineWithFeedback pendingAction={lodashGet(this.props.currentUserPersonalDetails, 'pendingFields.avatar', null)}> | ||
| <AvatarWithIndicator | ||
| source={UserUtils.getAvatar(this.props.currentUserPersonalDetails.avatar, this.props.currentUserPersonalDetails.accountID)} | ||
| tooltipText={this.props.translate('common.settings')} | ||
| /> | ||
| </OfflineWithFeedback> | ||
| )} | ||
| </PressableWithoutFeedback> | ||
| <SignInOrAvatarWithOptionalStatus isCreateMenuOpen={this.props.isCreateMenuOpen} /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @perunt could you elaborate where does
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok thanks for the input. |
||
| </View> | ||
| {this.props.isLoading ? ( | ||
| <> | ||
|
|
@@ -258,7 +216,6 @@ SidebarLinks.propTypes = propTypes; | |
| SidebarLinks.defaultProps = defaultProps; | ||
| export default compose( | ||
| withLocalize, | ||
| withCurrentUserPersonalDetails, | ||
| withWindowDimensions, | ||
| withCurrentReportID, | ||
| withOnyx({ | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.