Skip to content

Commit

Permalink
Adjusted padding; max width; alignment left
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejSWM committed Jan 8, 2024
1 parent e20938a commit 7845e2a
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 54 deletions.
4 changes: 3 additions & 1 deletion src/components/Section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import MenuItemList from '@components/MenuItemList';
import menuItemPropTypes from '@components/menuItemPropTypes';
import Text from '@components/Text';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import IconSection from './IconSection';

const CARD_LAYOUT = {
Expand Down Expand Up @@ -77,10 +78,11 @@ const defaultProps = {

function Section({children, childrenStyles, containerStyles, icon, IconComponent, cardLayout, iconContainerStyles, menuItems, subtitle, subtitleStyles, subtitleMuted, title, titleStyles}) {
const styles = useThemeStyles();
const {isMobileScreenWidth} = useWindowDimensions();

return (
<>
<View style={[styles.pageWrapper, styles.cardSection, ...containerStyles]}>
<View style={[styles.pageWrapper, styles.cardSection, ...containerStyles, isMobileScreenWidth ? styles.p5 : styles.p8]}>
{cardLayout === CARD_LAYOUT.ICON_ON_TOP && (
<IconSection
icon={icon}
Expand Down
36 changes: 0 additions & 36 deletions src/components/WalletSection.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions src/hooks/useWindowDimensions/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function (): WindowDimensions {
const isSmallScreenWidth = true;
const isMediumScreenWidth = false;
const isLargeScreenWidth = false;
const isMobileScreenWidth = true;

return {
windowWidth,
Expand All @@ -20,5 +21,6 @@ export default function (): WindowDimensions {
isSmallScreenWidth,
isMediumScreenWidth,
isLargeScreenWidth,
isMobileScreenWidth,
};
}
2 changes: 2 additions & 0 deletions src/hooks/useWindowDimensions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function (): WindowDimensions {
const isSmallScreenWidth = windowWidth <= variables.mobileResponsiveWidthBreakpoint;
const isMediumScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint && windowWidth <= variables.tabletResponsiveWidthBreakpoint;
const isLargeScreenWidth = windowWidth > variables.tabletResponsiveWidthBreakpoint;
const isMobileScreenWidth = isExtraSmallScreenHeight || isSmallScreenWidth;

return {
windowWidth,
Expand All @@ -22,5 +23,6 @@ export default function (): WindowDimensions {
isSmallScreenWidth,
isMediumScreenWidth,
isLargeScreenWidth,
isMobileScreenWidth,
};
}
1 change: 1 addition & 0 deletions src/hooks/useWindowDimensions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type WindowDimensions = {
isSmallScreenWidth: boolean;
isMediumScreenWidth: boolean;
isLargeScreenWidth: boolean;
isMobileScreenWidth: boolean;
};

export default WindowDimensions;
18 changes: 9 additions & 9 deletions src/pages/settings/Wallet/WalletPage/WalletPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import {withNetwork} from '@components/OnyxProvider';
import Popover from '@components/Popover';
import ScreenWrapper from '@components/ScreenWrapper';
import Section from '@components/Section';
import Text from '@components/Text';
import WalletSection from '@components/WalletSection';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -41,7 +41,7 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isSmallScreenWidth, windowWidth} = useWindowDimensions();
const {isSmallScreenWidth, windowWidth, isMobileScreenWidth} = useWindowDimensions();
const [shouldShowAddPaymentMenu, setShouldShowAddPaymentMenu] = useState(false);
const [shouldShowDefaultDeleteMenu, setShouldShowDefaultDeleteMenu] = useState(false);
const [shouldShowLoadingSpinner, setShouldShowLoadingSpinner] = useState(false);
Expand Down Expand Up @@ -339,7 +339,7 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS.ROOT)}
shouldShowBackButton={isSmallScreenWidth}
/>
<View style={[styles.flex1, styles.mb4]}>
<View style={[styles.flex1, isMobileScreenWidth ? styles.workspaceSectionMobile : styles.workspaceSection]}>
<ScrollView>
<OfflineWithFeedback
style={styles.flex1}
Expand All @@ -349,7 +349,7 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
errorRowStyles={[styles.ph6]}
>
{hasWallet && (
<WalletSection
<Section
icon={Illustrations.MoneyIntoWallet}
subtitle={translate(`walletPage.${hasActivatedWallet ? 'sendAndReceiveMoney' : 'enableWalletToSendAndReceiveMoney'}`)}
title={translate('walletPage.expensifyWallet')}
Expand Down Expand Up @@ -448,10 +448,10 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
}}
</KYCWall>
</>
</WalletSection>
</Section>
)}
{hasAssignedCard ? (
<WalletSection
<Section
icon={Illustrations.CreditCardsNew}
subtitle={translate('walletPage.assignedCardsDescription')}
title={translate('walletPage.assignedCards')}
Expand All @@ -470,9 +470,9 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
buttonRef={addPaymentMethodAnchorRef}
onListContentSizeChange={shouldShowAddPaymentMenu || shouldShowDefaultDeleteMenu ? setMenuPosition : () => {}}
/>
</WalletSection>
</Section>
) : null}
<WalletSection
<Section
icon={Illustrations.BankArrow}
subtitle={translate('walletPage.addBankAccountToSendAndReceive')}
title={translate('walletPage.bankAccounts')}
Expand All @@ -489,7 +489,7 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
shouldEnableScroll={false}
style={styles.mt5}
/>
</WalletSection>
</Section>
</OfflineWithFeedback>
</ScrollView>
</View>
Expand Down
1 change: 0 additions & 1 deletion src/pages/workspace/bills/WorkspaceBillsNoVBAView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function WorkspaceBillsNoVBAView(props) {
<Section
title={props.translate('workspace.bills.unlockOnlineBillPayment')}
icon={Illustrations.LockOpen}
containerStyles={[styles.cardSection]}
>
<View style={[styles.mv3]}>
<Text>{props.translate('workspace.bills.unlockNoVBACopy')}</Text>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/bills/WorkspaceBillsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import {View} from 'react-native';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections';
import CONST from '@src/CONST';
import WorkspaceBillsNoVBAView from './WorkspaceBillsNoVBAView';
Expand All @@ -23,6 +24,8 @@ const propTypes = {

function WorkspaceBillsPage(props) {
const styles = useThemeStyles();
const {isMobileScreenWidth} = useWindowDimensions();

return (
<WorkspacePageWithSections
shouldUseScrollView
Expand All @@ -31,7 +34,7 @@ function WorkspaceBillsPage(props) {
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_BILLS}
>
{(hasVBA, policyID) => (
<View style={[styles.workspaceSection, styles.mt6]}>
<View style={[styles.mt6, isMobileScreenWidth ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{!hasVBA && <WorkspaceBillsNoVBAView policyID={policyID} />}
{hasVBA && <WorkspaceBillsVBAView policyID={policyID} />}
</View>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/card/WorkspaceCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import {View} from 'react-native';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections';
import CONST from '@src/CONST';
import WorkspaceCardNoVBAView from './WorkspaceCardNoVBAView';
Expand All @@ -24,6 +25,8 @@ const propTypes = {

function WorkspaceCardPage(props) {
const styles = useThemeStyles();
const {isMobileScreenWidth} = useWindowDimensions();

return (
<WorkspacePageWithSections
shouldUseScrollView
Expand All @@ -32,7 +35,7 @@ function WorkspaceCardPage(props) {
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_CARD}
>
{(hasVBA, policyID, isUsingECard) => (
<View style={[styles.workspaceSection, styles.mt6]}>
<View style={[styles.mt6, isMobileScreenWidth ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{!hasVBA && <WorkspaceCardNoVBAView policyID={policyID} />}

{hasVBA && !isUsingECard && <WorkspaceCardVBANoECardView />}
Expand Down
1 change: 0 additions & 1 deletion src/pages/workspace/invoices/WorkspaceInvoicesNoVBAView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function WorkspaceInvoicesNoVBAView(props) {
<Section
title={props.translate('workspace.invoices.unlockOnlineInvoiceCollection')}
icon={Illustrations.MoneyIntoWallet}
containerStyles={[styles.cardSection]}
>
<View style={[styles.mv3]}>
<Text>{props.translate('workspace.invoices.unlockNoVBACopy')}</Text>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/invoices/WorkspaceInvoicesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import {View} from 'react-native';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections';
import CONST from '@src/CONST';
import WorkspaceInvoicesNoVBAView from './WorkspaceInvoicesNoVBAView';
Expand All @@ -23,6 +24,8 @@ const propTypes = {

function WorkspaceInvoicesPage(props) {
const styles = useThemeStyles();
const {isMobileScreenWidth} = useWindowDimensions();

return (
<WorkspacePageWithSections
shouldUseScrollView
Expand All @@ -31,7 +34,7 @@ function WorkspaceInvoicesPage(props) {
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_INVOICES}
>
{(hasVBA, policyID) => (
<View style={[styles.workspaceSection, styles.mt6]}>
<View style={[styles.mt6, isMobileScreenWidth ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{!hasVBA && <WorkspaceInvoicesNoVBAView policyID={policyID} />}
{hasVBA && <WorkspaceInvoicesVBAView policyID={policyID} />}
</View>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/workspace/reimburse/WorkspaceReimburseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Section from '@components/Section';
import Text from '@components/Text';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
Expand Down Expand Up @@ -68,6 +69,7 @@ const defaultProps = {
function WorkspaceReimburseView(props) {
const styles = useThemeStyles();
const [currentRatePerUnit, setCurrentRatePerUnit] = useState('');
const {isMobileScreenWidth} = useWindowDimensions();
const viewAllReceiptsUrl = `expenses?policyIDList=${props.policy.id}&billableReimbursable=reimbursable&submitterEmail=%2B%2B`;
const distanceCustomUnit = _.find(lodashGet(props.policy, 'customUnits', {}), (unit) => unit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE);
const distanceCustomRate = _.find(lodashGet(distanceCustomUnit, 'rates', {}), (rate) => rate.name === CONST.CUSTOM_UNITS.DEFAULT_RATE);
Expand Down Expand Up @@ -103,7 +105,7 @@ function WorkspaceReimburseView(props) {
}, [props.policy.customUnits, getCurrentRatePerUnitLabel]);

return (
<View style={[styles.workspaceSection, styles.mt6]}>
<View style={[styles.mt6, isMobileScreenWidth ? styles.workspaceSectionMobile : styles.workspaceSection]}>
<Section
title={translate('workspace.reimburse.captureReceipts')}
icon={Illustrations.MoneyReceipts}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/travel/WorkspaceTravelPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react';
import {View} from 'react-native';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections';
import CONST from '@src/CONST';
import WorkspaceTravelNoVBAView from './WorkspaceTravelNoVBAView';
Expand All @@ -23,6 +24,8 @@ const propTypes = {

function WorkspaceTravelPage(props) {
const styles = useThemeStyles();
const {isMobileScreenWidth} = useWindowDimensions();

return (
<WorkspacePageWithSections
shouldUseScrollView
Expand All @@ -31,7 +34,7 @@ function WorkspaceTravelPage(props) {
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_TRAVEL}
>
{(hasVBA, policyID) => (
<View style={[styles.workspaceSection, styles.mt6]}>
<View style={[styles.mt6, isMobileScreenWidth ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{!hasVBA && <WorkspaceTravelNoVBAView policyID={policyID} />}
{hasVBA && <WorkspaceTravelVBAView />}
</View>
Expand Down
5 changes: 4 additions & 1 deletion src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3305,7 +3305,6 @@ const styles = (theme: ThemeColors) =>
borderRadius: variables.componentBorderRadiusCard,
marginBottom: 20,
marginHorizontal: 16,
padding: 20,
width: 'auto',
textAlign: 'left',
},
Expand Down Expand Up @@ -4196,6 +4195,10 @@ const styles = (theme: ThemeColors) =>

workspaceSection: {
maxWidth: variables.workspaceSectionMaxWidth,
},

workspaceSectionMobile: {
width: '100%',
alignSelf: 'center',
},

Expand Down
4 changes: 4 additions & 0 deletions src/styles/utils/spacing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ export default {
padding: 20,
},

p8: {
padding: 32,
},

p9: {
padding: 36,
},
Expand Down

0 comments on commit 7845e2a

Please sign in to comment.