Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions src/CONST/SENTRY_LABEL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const SENTRY_LABEL = {
WORKSPACES: 'NavigationTabBar-Workspaces',
ACCOUNT: 'NavigationTabBar-Account',
HOME: 'NavigationTabBar-Home',
COLLAPSE: 'NavigationTabBar-Collapse',
FLOATING_ACTION_BUTTON: 'NavigationTabBar-FloatingActionButton',
FLOATING_RECEIPT_BUTTON: 'NavigationTabBar-FloatingReceiptButton',
FLOATING_GPS_BUTTON: 'NavigationTabBar-FloatingGpsButton',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Hoverable from '@components/Hoverable';
import {getCollapseFadeStyle} from '@components/Navigation/SearchSidebarCollapseStore';
import Text from '@components/Text';
import Tooltip from '@components/Tooltip';

Expand All @@ -16,13 +17,18 @@ import CONST from '@src/CONST';

import React from 'react';
import {View} from 'react-native';
import Animated from 'react-native-reanimated';

type FlatNavAccountStatusProps = {
isCollapsed?: boolean;
};

/**
* The signed-in user's emoji status on the right of the flat navigation bar's Account row, with the status text in a
* tooltip. In the expanded bar the status sits here instead of as a badge on the avatar, which would crowd the avatar's
* ring and indicator dot.
*/
function FlatNavAccountStatus() {
function FlatNavAccountStatus({isCollapsed = false}: FlatNavAccountStatusProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate, dateFnsLocale} = useLocalize();
Expand All @@ -33,35 +39,39 @@ function FlatNavAccountStatus() {
return null;
}

const collapseFadeStyle = getCollapseFadeStyle(isCollapsed);

const timezone = currentUserPersonalDetails.timezone?.selected ?? CONST.DEFAULT_TIME_ZONE.selected;
const formattedClearAfterDate = DateUtils.getStatusUntilDate(translate, dateFnsLocale, currentUserPersonalDetails.status?.clearAfter ?? '', timezone, timezone);
const tooltipText = getStatusTooltipText(currentUserPersonalDetails.status?.text ?? '', formattedClearAfterDate);

return (
<Tooltip
text={tooltipText}
shiftVertical={-4}
>
{/* Tooltip shows on mouse handlers it injects into its child, which Hoverable does not forward, so its target is a plain View */}
<View>
<Hoverable>
{(isHovered) => (
<View
testID="FlatNavAccountStatus"
style={[
styles.alignItemsCenter,
styles.justifyContentCenter,
StyleUtils.getWidthAndHeightStyle(variables.componentSizeSmall),
styles.borderRadiusCircle,
isHovered ? styles.buttonHoveredBG : styles.buttonDefaultBG,
]}
>
<Text numberOfLines={1}>{emojiCode}</Text>
</View>
)}
</Hoverable>
</View>
</Tooltip>
<Animated.View style={collapseFadeStyle}>
<Tooltip
text={tooltipText}
shiftVertical={-4}
>
{/* Tooltip shows on mouse handlers it injects into its child, which Hoverable does not forward, so its target is a plain View */}
<View>
<Hoverable>
{(isHovered) => (
<View
testID="FlatNavAccountStatus"
style={[
styles.alignItemsCenter,
styles.justifyContentCenter,
StyleUtils.getWidthAndHeightStyle(variables.componentSizeSmall),
styles.borderRadiusCircle,
isHovered ? styles.buttonHoveredBG : styles.buttonDefaultBG,
]}
>
<Text numberOfLines={1}>{emojiCode}</Text>
</View>
)}
</Hoverable>
</View>
</Tooltip>
</Animated.View>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/** The flat navigation bar's toggle for collapsing it into an icon rail and expanding it back. */
import SidebarLeftIcon from '@assets/images/sidebar-left.svg';
import SidebarRightIcon from '@assets/images/sidebar-right.svg';

import Icon from '@components/Icon';
import {PressableWithFeedback} from '@components/Pressable';
import Tooltip from '@components/Tooltip';

import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';

import variables from '@styles/variables';

import CONST from '@src/CONST';

import React from 'react';

type FlatNavCollapseToggleProps = {
isCollapsed: boolean;

onPress: () => void;
};

function FlatNavCollapseToggle({isCollapsed, onPress}: FlatNavCollapseToggleProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const theme = useTheme();
const {translate} = useLocalize();

const label = translate(isCollapsed ? 'reportActionCompose.expand' : 'reportActionCompose.collapse');

return (
<Tooltip text={label}>
<PressableWithFeedback
Comment thread
jmgraa marked this conversation as resolved.
Resolved
testID="FlatNavCollapseToggle"
role={CONST.ROLE.BUTTON}
accessibilityLabel={label}
accessibilityState={{expanded: !isCollapsed}}
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.COLLAPSE}
onPress={onPress}
style={[StyleUtils.getWidthAndHeightStyle(variables.iconSizeNormal), styles.alignItemsCenter, styles.justifyContentCenter]}
shouldUseAutoHitSlop
>
<Icon
src={isCollapsed ? SidebarRightIcon : SidebarLeftIcon}
fill={theme.icon}
width={variables.iconSizeNormal}
height={variables.iconSizeNormal}
/>
</PressableWithFeedback>
</Tooltip>
);
}

export default FlatNavCollapseToggle;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import usePopoverPosition from '@hooks/usePopoverPosition';
import useThemeStyles from '@hooks/useThemeStyles';

import CreateMenuPopover from '@pages/inbox/sidebar/FABPopoverContent/CreateMenuPopover';
import useCreateMenuVisibility from '@pages/inbox/sidebar/FABPopoverContent/useCreateMenuVisibility';

import CONST from '@src/CONST';
import type {AnchorPosition} from '@src/styles';
Expand All @@ -16,20 +15,36 @@ import type AnchorAlignment from '@src/types/utils/AnchorAlignment';
import type {ComponentRef} from 'react';
import type {View} from 'react-native';

import React, {useRef, useState} from 'react';
import {useRef, useState} from 'react';

const CREATE_MENU_ANCHOR_ALIGNMENT: AnchorAlignment = {
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
};

type FlatNavCreateButtonProps = {
/** Shrinks the button to a round icon-only "+", for the collapsed bar */
isCompact?: boolean;

isCreateMenuActive: boolean;

isCreateMenuVisible: boolean;

showCreateMenu: () => void;

hideCreateMenu: () => void;

/** Called once the create menu has fully closed and its modal is gone from the screen */
onCreateMenuHidden?: () => void;
};

/** Opens the same create menu as the floating action button. */
function FlatNavCreateButton() {
function FlatNavCreateButton({isCompact = false, isCreateMenuActive, isCreateMenuVisible, showCreateMenu, hideCreateMenu, onCreateMenuHidden}: FlatNavCreateButtonProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const icons = useMemoizedLazyExpensifyIcons(['Plus']);
const {calculatePopoverPosition} = usePopoverPosition();
const {isCreateMenuActive, isCreateMenuVisible, showCreateMenu, hideCreateMenu} = useCreateMenuVisibility();

const buttonRef = useRef<ComponentRef<typeof View>>(null);
const isOpeningRef = useRef(false);
const [anchorPosition, setAnchorPosition] = useState<AnchorPosition>();
Expand Down Expand Up @@ -60,6 +75,7 @@ function FlatNavCreateButton() {
anchorRef={buttonRef}
anchorPosition={anchorPosition}
anchorAlignment={CREATE_MENU_ANCHOR_ALIGNMENT}
onModalHide={onCreateMenuHidden}
/>
<Button
ref={buttonRef}
Expand All @@ -70,13 +86,13 @@ function FlatNavCreateButton() {
variant={CONST.BUTTON_VARIANT.SUCCESS}
size={CONST.BUTTON_SIZE.SMALL}
style={styles.w100}
innerStyles={styles.flatNavigationBarCreateButton}
innerStyles={[styles.flatNavigationBarCreateButton, isCompact && styles.flatNavigationBarCreateButtonCompact]}
onPress={toggleCreateMenu}
// Same action as the floating action button it replaces, so it keeps that button's Sentry and FullStory identifier.
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.FLOATING_ACTION_BUTTON}
>
<Button.Icon src={icons.Plus} />
<Button.Text>{translate('common.create')}</Button.Text>
{!isCompact && <Button.Text>{translate('common.create')}</Button.Text>}
</Button>
</>
);
Expand Down
26 changes: 18 additions & 8 deletions src/components/Navigation/FlatNavigationBar/FlatNavItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Icon from '@components/Icon';
import getTabIconFill from '@components/Navigation/NavigationTabBar/getTabIconFill';
import {getCollapseFadeStyle} from '@components/Navigation/SearchSidebarCollapseStore';
import {PressableWithFeedback} from '@components/Pressable';
import Text from '@components/Text';

Expand All @@ -17,6 +18,7 @@ import type {ColorValue} from 'react-native';

import React from 'react';
import {View} from 'react-native';
import Animated from 'react-native-reanimated';

type FlatNavItemProps = {
/** Translated row label */
Expand All @@ -32,6 +34,9 @@ type FlatNavItemProps = {

isSelected: boolean;

/** Whether the row keeps only its icon, so the bar can narrow to an icon rail */
isCollapsed?: boolean;

/** Draws the row taller than the destination rows, as the Account row is */
isTall?: boolean;

Expand Down Expand Up @@ -59,6 +64,7 @@ function FlatNavItem({
renderLeftElement,
rightElement,
isSelected,
isCollapsed = false,
isTall = false,
statusIndicatorColor,
accessibilityLabel,
Expand All @@ -78,6 +84,9 @@ function FlatNavItem({
return isHovered ? styles.highlightBG : undefined;
};

// The label stays mounted and fades, rather than disappearing the moment the bar starts narrowing.
const collapseFadeStyle = getCollapseFadeStyle(isCollapsed);

return (
<PressableWithFeedback
onPress={onPress}
Expand Down Expand Up @@ -115,14 +124,15 @@ function FlatNavItem({
</View>
)}
{renderLeftElement?.({backgroundColor: rowBackgroundColor})}
<Text
variant={isSelected ? 'textStrong' : 'text'}
color={isSelected || hovered ? theme.text : theme.textSupporting}
numberOfLines={1}
style={styles.flex1}
>
{label}
</Text>
<Animated.View style={[styles.flex1, collapseFadeStyle]}>
<Text
variant={isSelected ? 'textStrong' : 'text'}
color={isSelected || hovered ? theme.text : theme.textSupporting}
numberOfLines={1}
>
{label}
</Text>
</Animated.View>
{rightElement}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import React from 'react';

type FlatNavLogoProps = {
onPress: () => void;

/** Whether the navigation bar is visually collapsed, so the logo fades out and stops accepting interaction. */
isCollapsed?: boolean;
};

/** Expensify wordmark at the top of the flat navigation bar, which leads Home like the logo in the icon bar. */
function FlatNavLogo({onPress}: FlatNavLogoProps) {
function FlatNavLogo({onPress, isCollapsed = false}: FlatNavLogoProps) {
const theme = useTheme();
const {translate} = useLocalize();
const icons = useMemoizedLazyExpensifyIcons(['ExpensifyWordmark']);
Expand All @@ -28,6 +31,9 @@ function FlatNavLogo({onPress}: FlatNavLogoProps) {
testID="ExpensifyLogoButton"
onPress={onPress}
sentryLabel={CONST.SENTRY_LABEL.NAVIGATION_TAB_BAR.EXPENSIFY_LOGO}
aria-hidden={isCollapsed}
tabIndex={isCollapsed ? -1 : 0}
disabled={isCollapsed}
>
<Icon
src={icons.ExpensifyWordmark}
Expand Down
Loading
Loading