Skip to content
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

Fix area around bottom tab avatar isn't clickable #38380

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps
</PressableWithFeedback>

<BottomTabBarFloatingActionButton />
<View style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter]}>
<BottomTabAvatar isSelected={currentTabName === SCREENS.SETTINGS.ROOT} />
</View>
<BottomTabAvatar isSelected={currentTabName === SCREENS.SETTINGS.ROOT} />
</View>
);
}
Expand Down
25 changes: 5 additions & 20 deletions src/pages/home/sidebar/AvatarWithOptionalStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,31 @@
import React from 'react';
import {View} from 'react-native';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import PressableAvatarWithIndicator from './PressableAvatarWithIndicator';
import ProfileAvatarWithIndicator from './ProfileAvatarWithIndicator';

type AvatarWithOptionalStatusProps = {
/** Emoji status */
emojiStatus?: string;

/** Whether the avatar is selected */
isSelected?: boolean;

/** Callback called when the avatar or status icon is pressed */
onPress?: () => void;
};

function AvatarWithOptionalStatus({emojiStatus = '', isSelected = false, onPress}: AvatarWithOptionalStatusProps) {
function AvatarWithOptionalStatus({emojiStatus = '', isSelected = false}: AvatarWithOptionalStatusProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();

return (
<View style={styles.sidebarStatusAvatarContainer}>
<PressableAvatarWithIndicator
isSelected={isSelected}
onPress={onPress}
/>
<PressableWithoutFeedback
accessibilityLabel={translate('sidebarScreen.buttonMySettings')}
role={CONST.ROLE.BUTTON}
onPress={onPress}
style={[styles.sidebarStatusAvatar]}
>
<ProfileAvatarWithIndicator isSelected={isSelected} />
<View style={[styles.sidebarStatusAvatar]}>
<Text
style={styles.emojiStatusLHN}
numberOfLines={1}
>
{emojiStatus}
</Text>
</PressableWithoutFeedback>
</View>
</View>
);
}
Expand Down
27 changes: 21 additions & 6 deletions src/pages/home/sidebar/BottomTabAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
/* eslint-disable rulesdir/onyx-props-must-have-default */
import React, {useCallback} from 'react';
import {PressableWithFeedback} from '@components/Pressable';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import AvatarWithOptionalStatus from './AvatarWithOptionalStatus';
import PressableAvatarWithIndicator from './PressableAvatarWithIndicator';
import ProfileAvatarWithIndicator from './ProfileAvatarWithIndicator';

type BottomTabAvatarProps = {
/** Whether the create menu is open or not */
Expand All @@ -16,6 +20,8 @@ type BottomTabAvatarProps = {
};

function BottomTabAvatar({isCreateMenuOpen = false, isSelected = false}: BottomTabAvatarProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const emojiStatus = currentUserPersonalDetails?.status?.emojiCode ?? '';

Expand All @@ -28,20 +34,29 @@ function BottomTabAvatar({isCreateMenuOpen = false, isSelected = false}: BottomT
interceptAnonymousUser(() => Navigation.navigate(ROUTES.SETTINGS));
}, [isCreateMenuOpen]);

let children;

if (emojiStatus) {
return (
children = (
<AvatarWithOptionalStatus
emojiStatus={emojiStatus}
isSelected={isSelected}
onPress={showSettingsPage}
/>
);
} else {
children = <ProfileAvatarWithIndicator isSelected={isSelected} />;
}

return (
<PressableAvatarWithIndicator
isSelected={isSelected}
<PressableWithFeedback
onPress={showSettingsPage}
/>
role={CONST.ROLE.BUTTON}
accessibilityLabel={translate('sidebarScreen.buttonMySettings')}
wrapperStyle={styles.flex1}
style={styles.bottomTabBarItem}
>
{children}
</PressableWithFeedback>
);
}

Expand Down
59 changes: 0 additions & 59 deletions src/pages/home/sidebar/PressableAvatarWithIndicator.tsx

This file was deleted.

48 changes: 48 additions & 0 deletions src/pages/home/sidebar/ProfileAvatarWithIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import AvatarWithIndicator from '@components/AvatarWithIndicator';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as UserUtils from '@libs/UserUtils';
import ONYXKEYS from '@src/ONYXKEYS';

type ProfileAvatarWithIndicatorOnyxProps = {
/** Indicates whether the app is loading initial data */
isLoading: OnyxEntry<boolean>;
};

type ProfileAvatarWithIndicatorProps = ProfileAvatarWithIndicatorOnyxProps & {
/** Whether the avatar is selected */
isSelected: boolean;
};

function ProfileAvatarWithIndicator({isLoading = true, isSelected = false}: ProfileAvatarWithIndicatorProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();

return (
<OfflineWithFeedback pendingAction={currentUserPersonalDetails.pendingFields?.avatar ?? null}>
<View style={[isSelected && styles.selectedAvatarBorder]}>
<AvatarWithIndicator
source={UserUtils.getAvatar(currentUserPersonalDetails.avatar, currentUserPersonalDetails.accountID)}
tooltipText={translate('profilePage.profile')}
fallbackIcon={currentUserPersonalDetails.fallbackIcon}
isLoading={!!isLoading && !currentUserPersonalDetails.avatar}
/>
</View>
</OfflineWithFeedback>
);
}

ProfileAvatarWithIndicator.displayName = 'PressableAvatarWithIndicator';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ProfileAvatarWithIndicator.displayName = 'PressableAvatarWithIndicator';
ProfileAvatarWithIndicator.displayName = 'ProfileAvatarWithIndicator';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


export default withOnyx<ProfileAvatarWithIndicatorProps, ProfileAvatarWithIndicatorOnyxProps>({
isLoading: {
key: ONYXKEYS.IS_LOADING_APP,
},
})(ProfileAvatarWithIndicator);
Loading