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
32 changes: 2 additions & 30 deletions src/components/WidgetContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,29 @@ import type {StyleProp, ViewStyle} from 'react-native';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import type IconAsset from '@src/types/utils/IconAsset';
import Icon from './Icon';
import Text from './Text';
Comment thread
adamgrzybowski marked this conversation as resolved.

type WidgetContainerProps = {
/** The icon to display along with the title */
icon?: IconAsset;

/** The text to display in the title of the widget */
title?: string;

/** Custom color for the title text */
titleColor?: string;

/** The width of the icon. */
iconWidth?: number;

/** The height of the icon. */
iconHeight?: number;

/** The fill color of the icon */
iconFill?: string;

/** The content to display inside the widget container */
children: ReactNode;

/** Additional styles to pass to the container */
containerStyles?: StyleProp<ViewStyle>;
};

function WidgetContainer({children, icon, title, titleColor, iconWidth = variables.iconSizeNormal, iconHeight = variables.iconSizeNormal, iconFill, containerStyles}: WidgetContainerProps) {
function WidgetContainer({children, title, containerStyles}: WidgetContainerProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {shouldUseNarrowLayout} = useResponsiveLayout();

return (
<View style={[styles.widgetContainer, containerStyles]}>
<View style={styles.getWidgetContainerHeaderStyle(shouldUseNarrowLayout)}>
{!!icon && (
<View style={styles.widgetContainerIconWrapper}>
<Icon
src={icon}
width={iconWidth}
height={iconHeight}
fill={iconFill}
/>
</View>
)}
<View style={[styles.flexShrink1, styles.flexGrow1, styles.flexRow, styles.alignItemsCenter, styles.gap2]}>
{!!title && <Text style={styles.getWidgetContainerTitleStyle(titleColor ?? theme.text)}>{title}</Text>}
{!!title && <Text style={styles.getWidgetContainerTitleStyle(theme.text)}>{title}</Text>}
</View>
</View>
{children}
Expand Down
14 changes: 1 addition & 13 deletions src/pages/home/TimeSensitiveSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import type {OnyxCollection} from 'react-native-onyx';
import WidgetContainer from '@components/WidgetContainer';
import useCardFeedErrors from '@hooks/useCardFeedErrors';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
Comment thread
adamgrzybowski marked this conversation as resolved.
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {hasSynchronizationErrorMessage, isConnectionInProgress} from '@libs/actions/connections';
import variables from '@styles/variables';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Policy} from '@src/types/onyx';
import type {ConnectionName, PolicyConnectionName} from '@src/types/onyx/Policy';
Expand Down Expand Up @@ -43,9 +40,7 @@ type BrokenCompanyCardConnection = {

function TimeSensitiveSection() {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
const icons = useMemoizedLazyExpensifyIcons(['Stopwatch']);
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {login} = useCurrentUserPersonalDetails();

Expand Down Expand Up @@ -124,14 +119,7 @@ function TimeSensitiveSection() {
// 5. Expensify card shipping
// 6. Expensify card activation
return (
<WidgetContainer
icon={icons.Stopwatch}
iconWidth={variables.iconSizeNormal}
iconHeight={variables.iconSizeNormal}
iconFill={theme.danger}
title={translate('homePage.timeSensitiveSection.title')}
titleColor={theme.danger}
>
<WidgetContainer title={translate('homePage.timeSensitiveSection.title')}>
<View style={styles.getForYouSectionContainerStyle(shouldUseNarrowLayout)}>
{/* Priority 2: Broken company card connections */}
{brokenCompanyCardConnections.map((connection) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function FixAccountingConnection({connectionName, policyID}: FixAccountingConnec
<BaseWidgetItem
icon={icons.Connect}
iconBackgroundColor={colors.tangerine100}
iconFill={colors.tangerine700}
iconFill={colors.tangerine500}
title={translate('homePage.timeSensitiveSection.fixAccountingConnection.title', {integrationName})}
subtitle={translate('homePage.timeSensitiveSection.fixAccountingConnection.subtitle')}
ctaText={translate('homePage.timeSensitiveSection.ctaFix')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function FixCompanyCardConnection({card, policyID}: FixCompanyCardConnectionProp
<BaseWidgetItem
icon={icons.Connect}
iconBackgroundColor={colors.tangerine100}
iconFill={colors.tangerine700}
iconFill={colors.tangerine500}
title={translate('homePage.timeSensitiveSection.fixCompanyCardConnection.title', {feedName})}
subtitle={translate('homePage.timeSensitiveSection.fixCompanyCardConnection.subtitle')}
ctaText={translate('homePage.timeSensitiveSection.ctaFix')}
Expand Down
6 changes: 0 additions & 6 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6317,12 +6317,6 @@ const plainStyles = (theme: ThemeColors) =>
marginTop: shouldUseNarrowLayout ? 20 : 32,
}) satisfies ViewStyle,

widgetContainerIconWrapper: {
flexGrow: 0,
flexShrink: 0,
marginRight: 11,
},

getWidgetItemIconContainerStyle: (backgroundColor: string) =>
({
alignItems: 'center',
Expand Down
Loading