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
2 changes: 0 additions & 2 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ const CONST = {
ANIMATED_HIGHLIGHT_ENTRY_DURATION: 300,
ANIMATED_HIGHLIGHT_START_DELAY: 10,
ANIMATED_HIGHLIGHT_START_DURATION: 300,
ANIMATED_HIGHLIGHT_WORKSPACE_FEATURE_ITEM_END_DELAY: 7000,
ANIMATED_HIGHLIGHT_WORKSPACE_FEATURE_ITEM_END_DURATION: 3000,
ANIMATED_HIGHLIGHT_END_DELAY: 800,
ANIMATED_HIGHLIGHT_END_DURATION: 2000,
ANIMATED_TRANSITION: 300,
Expand Down
6 changes: 0 additions & 6 deletions src/components/HighlightableMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import React, {forwardRef} from 'react';
import type {View} from 'react-native';
import {StyleSheet} from 'react-native';
import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import MenuItem from './MenuItem';
import type {MenuItemProps} from './MenuItem';

Expand All @@ -16,16 +14,12 @@ type Props = MenuItemProps & {

function HighlightableMenuItem({wrapperStyle, highlighted, ...restOfProps}: Props, ref: ForwardedRef<View>) {
const styles = useThemeStyles();
const theme = useTheme();

const flattenedWrapperStyles = StyleSheet.flatten(wrapperStyle);
const animatedHighlightStyle = useAnimatedHighlightStyle({
shouldHighlight: highlighted ?? false,
height: flattenedWrapperStyles?.height ? Number(flattenedWrapperStyles.height) : styles.sectionMenuItem.height,
borderRadius: flattenedWrapperStyles?.borderRadius ? Number(flattenedWrapperStyles.borderRadius) : styles.sectionMenuItem.borderRadius,
highlightColor: theme.messageHighlightBG,
highlightEndDelay: CONST.ANIMATED_HIGHLIGHT_WORKSPACE_FEATURE_ITEM_END_DELAY,
highlightEndDuration: CONST.ANIMATED_HIGHLIGHT_WORKSPACE_FEATURE_ITEM_END_DURATION,
});

return (
Expand Down
124 changes: 20 additions & 104 deletions src/pages/workspace/WorkspaceMoreFeaturesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {useCallback, useEffect, useState} from 'react';
import {View} from 'react-native';
import ConfirmModal from '@components/ConfirmModal';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Hoverable from '@components/Hoverable';
import * as Illustrations from '@components/Icon/Illustrations';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
Expand Down Expand Up @@ -68,7 +67,6 @@ type Item = {
pendingAction: PendingAction | undefined;
errors?: Errors;
onCloseError?: () => void;
onPress?: () => void;
};

type SectionObject = {
Expand Down Expand Up @@ -149,12 +147,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
enablePolicyDistanceRates(policyID, isEnabled, distanceRateCustomUnit);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_DISTANCE_RATES.getRoute(policyID));
},
},
{
icon: illustrations.HandCard,
Expand All @@ -172,12 +164,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
disabledAction: () => {
setIsDisableExpensifyCardWarningModalOpen(true);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_EXPENSIFY_CARD.getRoute(policyID));
},
},
];

Expand All @@ -197,12 +183,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
disabledAction: () => {
setIsDisableCompanyCardsWarningModalOpen(true);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policyID));
},
});

spendItems.push({
Expand All @@ -221,12 +201,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
enablePerDiem(policyID, isEnabled, perDiemCustomUnit?.customUnitID, true, quickAction);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_PER_DIEM.getRoute(policyID));
},
});

const manageItems: Item[] = [
Expand All @@ -244,12 +218,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
},
disabled: isSmartLimitEnabled,
disabledAction: onDisabledWorkflowPress,
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID));
},
},
{
icon: illustrations.Rules,
Expand All @@ -268,12 +236,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
enablePolicyRules(policyID, isEnabled);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_RULES.getRoute(policyID));
},
},
];

Expand All @@ -290,12 +252,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
enablePolicyInvoicing(policyID, isEnabled);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID));
},
},
];

Expand All @@ -314,12 +270,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
enablePolicyCategories(policyID, isEnabled, policyTagLists, policyCategories, allTransactionViolations, true);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES.getRoute(policyID));
},
},
{
icon: illustrations.Tag,
Expand All @@ -335,12 +285,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
enablePolicyTags({policyID, enabled: isEnabled, policyTags: policyTagLists});
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_TAGS.getRoute(policyID));
},
},
{
icon: illustrations.Coins,
Expand All @@ -356,12 +300,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
enablePolicyTaxes(policyID, isEnabled);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_TAXES.getRoute(policyID));
},
},
];

Expand Down Expand Up @@ -392,12 +330,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
clearPolicyErrorField(policyID, CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.POLICY_ACCOUNTING.getRoute(policyID));
},
},
];

Expand Down Expand Up @@ -428,12 +360,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro
}
clearPolicyErrorField(policyID, CONST.POLICY.MORE_FEATURES.ARE_RECEIPT_PARTNERS_ENABLED);
},
onPress: () => {
if (!policyID) {
return;
}
Navigation.navigate(ROUTES.WORKSPACE_RECEIPT_PARTNERS.getRoute(policyID));
},
});
}

Expand Down Expand Up @@ -467,36 +393,26 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro

const renderItem = useCallback(
(item: Item) => (
<Hoverable>
{(hovered) => (
<View
key={item.titleTranslationKey}
style={[
styles.workspaceSectionMoreFeaturesItem,
shouldUseNarrowLayout && styles.flexBasis100,
shouldUseNarrowLayout && StyleUtils.getMinimumWidth(0),
hovered && item.isActive && !!item.onPress && styles.hoveredComponentBG,
]}
>
<ToggleSettingOptionRow
icon={item.icon}
disabled={item.disabled}
disabledAction={item.disabledAction}
title={translate(item.titleTranslationKey)}
titleStyle={styles.textStrong}
subtitle={translate(item.subtitleTranslationKey)}
switchAccessibilityLabel={translate(item.subtitleTranslationKey)}
isActive={item.isActive}
pendingAction={item.pendingAction}
onToggle={item.action}
showLockIcon={item.disabled}
errors={item.errors}
onCloseError={item.onCloseError}
onPress={item.onPress}
/>
</View>
)}
</Hoverable>
<View
key={item.titleTranslationKey}
style={[styles.workspaceSectionMoreFeaturesItem, shouldUseNarrowLayout && styles.flexBasis100, shouldUseNarrowLayout && StyleUtils.getMinimumWidth(0)]}
>
<ToggleSettingOptionRow
icon={item.icon}
disabled={item.disabled}
disabledAction={item.disabledAction}
title={translate(item.titleTranslationKey)}
titleStyle={styles.textStrong}
subtitle={translate(item.subtitleTranslationKey)}
switchAccessibilityLabel={translate(item.subtitleTranslationKey)}
isActive={item.isActive}
pendingAction={item.pendingAction}
onToggle={item.action}
showLockIcon={item.disabled}
errors={item.errors}
onCloseError={item.onCloseError}
/>
</View>
),
[styles, StyleUtils, shouldUseNarrowLayout, translate],
);
Expand Down
55 changes: 16 additions & 39 deletions src/pages/workspace/workflows/ToggleSettingsOptionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
import Accordion from '@components/Accordion';
import Icon from '@components/Icon';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import RenderHTML from '@components/RenderHTML';
import Switch from '@components/Switch';
import Text from '@components/Text';
Expand Down Expand Up @@ -78,9 +77,6 @@ type ToggleSettingOptionRowProps = {

/** Callback to fire when the switch is toggled in disabled state */
disabledAction?: () => void;

/** Callback to fire when the content area is pressed (only works when isActive is true) */
onPress?: () => void;
};
const ICON_SIZE = 48;

Expand All @@ -106,7 +102,6 @@ function ToggleSettingOptionRow({
onCloseError,
disabled = false,
showLockIcon = false,
onPress,
}: ToggleSettingOptionRowProps) {
const styles = useThemeStyles();
const {isAccordionExpanded, shouldAnimateAccordionSection} = useAccordionAnimation(isActive);
Expand Down Expand Up @@ -158,27 +153,6 @@ function ToggleSettingOptionRow({
processedSubtitle,
]);

const contentArea = (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}>
{!!icon && (
<Icon
src={icon}
height={ICON_SIZE}
width={ICON_SIZE}
additionalStyles={[styles.mr3]}
/>
)}
{customTitle ?? (
<View style={[styles.flexColumn, styles.flex1]}>
<Text style={[styles.textNormal, styles.lh20, titleStyle]}>{title}</Text>
{!shouldPlaceSubtitleBelowSwitch && subtitle && subTitleView}
</View>
)}
</View>
);

const shouldMakeContentPressable = isActive && onPress;

return (
<OfflineWithFeedback
pendingAction={pendingAction}
Expand All @@ -189,19 +163,22 @@ function ToggleSettingOptionRow({
>
<View style={styles.pRelative}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.justifyContentBetween, shouldPlaceSubtitleBelowSwitch && styles.h10]}>
{shouldMakeContentPressable ? (
<PressableWithoutFeedback
style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}
onPress={onPress}
accessibilityLabel={title}
role="button"
accessible={false}
>
{contentArea}
</PressableWithoutFeedback>
) : (
contentArea
)}
<View style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]}>
{!!icon && (
<Icon
src={icon}
height={ICON_SIZE}
width={ICON_SIZE}
additionalStyles={[styles.mr3]}
/>
)}
{customTitle ?? (
<View style={[styles.flexColumn, styles.flex1]}>
<Text style={[styles.textNormal, styles.lh20, titleStyle]}>{title}</Text>
{!shouldPlaceSubtitleBelowSwitch && subtitle && subTitleView}
</View>
)}
</View>
<Switch
disabledAction={disabledAction}
accessibilityLabel={switchAccessibilityLabel}
Expand Down
Loading