Skip to content

Commit

Permalink
Merge pull request #47753 from Expensify/revert-47748-revert-47181-cm…
Browse files Browse the repository at this point in the history
…artins-createStatusBar

Create status bar v2
  • Loading branch information
deetergp authored Aug 27, 2024
2 parents fe0e4f3 + 7abc5cb commit 6b1d963
Show file tree
Hide file tree
Showing 22 changed files with 358 additions and 177 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 3 additions & 12 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5207,8 +5207,6 @@ const CONST = {
SEARCH: {
RESULTS_PAGE_SIZE: 50,
DATA_TYPES: {
TRANSACTION: 'transaction',
REPORT: 'report',
EXPENSE: 'expense',
INVOICE: 'invoice',
TRIP: 'trip',
Expand Down Expand Up @@ -5237,9 +5235,10 @@ const CONST = {
STATUS: {
EXPENSE: {
ALL: 'all',
SHARED: 'shared',
DRAFTS: 'drafts',
FINISHED: 'finished',
OUTSTANDING: 'outstanding',
APPROVED: 'approved',
PAID: 'paid',
},
INVOICE: {
ALL: 'all',
Expand All @@ -5254,14 +5253,6 @@ const CONST = {
PAID: 'paid',
},
},
TAB: {
EXPENSE: {
ALL: 'type:expense status:all',
SHARED: 'type:expense status:shared',
DRAFTS: 'type:expense status:drafts',
FINISHED: 'type:expense status:finished',
},
},
TABLE_COLUMNS: {
RECEIPT: 'receipt',
DATE: 'date',
Expand Down
22 changes: 19 additions & 3 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type ButtonProps = Partial<ChildrenProps> & {
/** The fill color to pass into the icon. */
iconFill?: string;

/** The fill color to pass into the icon when the button is hovered. */
iconHoverFill?: string;

/** Any additional styles to pass to the left icon container. */
iconStyles?: StyleProp<ViewStyle>;

Expand Down Expand Up @@ -80,9 +83,15 @@ type ButtonProps = Partial<ChildrenProps> & {
/** Additional text styles */
textStyles?: StyleProp<TextStyle>;

/** Additional text styles when the button is hovered */
textHoverStyles?: StyleProp<TextStyle>;

/** Whether we should use the default hover style */
shouldUseDefaultHover?: boolean;

/** Additional hover styles */
hoverStyles?: StyleProp<ViewStyle>;

/** Whether we should use the success theme color */
success?: boolean;

Expand Down Expand Up @@ -170,6 +179,7 @@ function Button(

iconRight = Expensicons.ArrowRight,
iconFill,
iconHoverFill,
icon = null,
iconStyles = [],
iconRightStyles = [],
Expand All @@ -194,8 +204,10 @@ function Button(
style = [],
innerStyles = [],
textStyles = [],
textHoverStyles = [],

shouldUseDefaultHover = true,
hoverStyles = undefined,
success = false,
danger = false,

Expand Down Expand Up @@ -238,6 +250,7 @@ function Button(
danger && styles.buttonDangerText,
!!icon && styles.textAlignLeft,
textStyles,
isHovered && textHoverStyles,
link && styles.link,
link && isHovered && StyleUtils.getColorStyle(theme.linkHover),
link && styles.fontWeightNormal,
Expand All @@ -249,6 +262,8 @@ function Button(
</Text>
);

const defaultFill = success || danger ? theme.textLight : theme.icon;

// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (icon || shouldShowRightIcon) {
return (
Expand All @@ -259,7 +274,7 @@ function Button(
<Icon
src={icon}
hasText={!!text}
fill={iconFill ?? (success || danger ? theme.textLight : theme.icon)}
fill={isHovered ? iconHoverFill ?? defaultFill : iconFill ?? defaultFill}
small={small}
medium={medium}
large={large}
Expand All @@ -273,14 +288,14 @@ function Button(
{!isSplitButton ? (
<Icon
src={iconRight}
fill={iconFill ?? (success || danger ? theme.textLight : theme.icon)}
fill={isHovered ? iconHoverFill ?? defaultFill : iconFill ?? defaultFill}
small={medium}
medium={large}
/>
) : (
<Icon
src={iconRight}
fill={iconFill ?? (success || danger ? theme.textLight : theme.icon)}
fill={isHovered ? iconHoverFill ?? defaultFill : iconFill ?? defaultFill}
small={small}
medium={medium}
large={large}
Expand Down Expand Up @@ -358,6 +373,7 @@ function Button(
shouldUseDefaultHover && !isDisabled ? styles.buttonDefaultHovered : undefined,
success && !isDisabled ? styles.buttonSuccessHovered : undefined,
danger && !isDisabled ? styles.buttonDangerHovered : undefined,
hoverStyles,
]}
id={id}
accessibilityLabel={accessibilityLabel}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Illustrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import CreditCardsNew from '@assets/images/simple-illustrations/simple-illustrat
import CreditCardEyes from '@assets/images/simple-illustrations/simple-illustration__creditcardeyes.svg';
import EmailAddress from '@assets/images/simple-illustrations/simple-illustration__email-address.svg';
import EmptyState from '@assets/images/simple-illustrations/simple-illustration__empty-state.svg';
import EnvelopeReceipt from '@assets/images/simple-illustrations/simple-illustration__envelopereceipt.svg';
import Filters from '@assets/images/simple-illustrations/simple-illustration__filters.svg';
import FolderOpen from '@assets/images/simple-illustrations/simple-illustration__folder-open.svg';
import Gears from '@assets/images/simple-illustrations/simple-illustration__gears.svg';
Expand Down Expand Up @@ -122,6 +123,7 @@ export {
EmailAddress,
EmptyCardState,
EmptyStateExpenses,
EnvelopeReceipt,
FolderOpen,
HandCard,
HotDogStand,
Expand Down
30 changes: 20 additions & 10 deletions src/components/Search/SearchPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {SearchReport} from '@src/types/onyx/SearchResults';
import type {SearchDataTypes, SearchReport} from '@src/types/onyx/SearchResults';
import type DeepValueOf from '@src/types/utils/DeepValueOf';
import type IconAsset from '@src/types/utils/IconAsset';
import {useSearchContext} from './SearchContext';
import type {SearchQueryJSON, SearchStatus} from './types';
import type {SearchQueryJSON} from './types';

type HeaderWrapperProps = Pick<HeaderWithBackButtonProps, 'title' | 'subtitle' | 'icon' | 'children'> & {
subtitleStyles?: StyleProp<TextStyle>;
Expand Down Expand Up @@ -101,13 +101,23 @@ type SearchPageHeaderProps = {

type SearchHeaderOptionValue = DeepValueOf<typeof CONST.SEARCH.BULK_ACTION_TYPES> | undefined;

const headerContent: {[key in SearchStatus]: {icon: IconAsset; titleText: TranslationPaths}} = {
all: {icon: Illustrations.MoneyReceipts, titleText: 'common.expenses'},
shared: {icon: Illustrations.SendMoney, titleText: 'common.shared'},
drafts: {icon: Illustrations.Pencil, titleText: 'common.drafts'},
finished: {icon: Illustrations.CheckmarkCircle, titleText: 'common.finished'},
type HeaderContent = {
icon: IconAsset;
titleText: TranslationPaths;
};

function getHeaderContent(type: SearchDataTypes): HeaderContent {
switch (type) {
case CONST.SEARCH.DATA_TYPES.INVOICE:
return {icon: Illustrations.EnvelopeReceipt, titleText: 'workspace.common.invoices'};
case CONST.SEARCH.DATA_TYPES.TRIP:
return {icon: Illustrations.Luggage, titleText: 'travel.trips'};
case CONST.SEARCH.DATA_TYPES.EXPENSE:
default:
return {icon: Illustrations.MoneyReceipts, titleText: 'common.expenses'};
}
}

function SearchPageHeader({queryJSON, hash, onSelectDeleteOption, setOfflineModalOpen, setDownloadErrorModalOpen, isCustomQuery, data}: SearchPageHeaderProps) {
const {translate} = useLocalize();
const theme = useTheme();
Expand All @@ -132,10 +142,10 @@ function SearchPageHeader({queryJSON, hash, onSelectDeleteOption, setOfflineModa
.map((item) => item.reportID),
[data, selectedTransactions],
);
const {status} = queryJSON;
const headerSubtitle = isCustomQuery ? SearchUtils.getSearchHeaderTitle(queryJSON) : translate(headerContent[status]?.titleText);
const {status, type} = queryJSON;
const headerSubtitle = isCustomQuery ? SearchUtils.getSearchHeaderTitle(queryJSON) : translate(getHeaderContent(type).titleText);
const headerTitle = isCustomQuery ? translate('search.filtersHeader') : '';
const headerIcon = isCustomQuery ? Illustrations.Filters : headerContent[status]?.icon;
const headerIcon = isCustomQuery ? Illustrations.Filters : getHeaderContent(type).icon;

const subtitleStyles = isCustomQuery ? {} : styles.textHeadlineH2;

Expand Down
Loading

0 comments on commit 6b1d963

Please sign in to comment.