From 1d58befa03b4dd93f27a96cec91823c852b37a8a Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 2 Jan 2024 10:52:45 +0100 Subject: [PATCH 1/8] refactor & fix back button, and fix logo color --- .../headerWithBackButtonPropTypes.js | 3 --- src/components/HeaderWithBackButton/index.js | 18 ++---------------- src/components/IllustratedHeaderPageLayout.js | 4 +--- src/pages/ShareCodePage.js | 7 ++++--- src/pages/settings/AboutPage/AboutPage.js | 6 ++++-- .../settings/Preferences/PreferencesPage.js | 5 +++-- src/pages/settings/Profile/ProfilePage.js | 3 +-- .../settings/Security/SecuritySettingsPage.js | 5 +++-- .../settings/Wallet/WalletPage/WalletPage.js | 2 +- src/pages/workspace/WorkspacesListPage.js | 4 +++- 10 files changed, 22 insertions(+), 35 deletions(-) diff --git a/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js b/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js index a98ab7d52741..109e60adf672 100644 --- a/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js +++ b/src/components/HeaderWithBackButton/headerWithBackButtonPropTypes.js @@ -96,9 +96,6 @@ const propTypes = { /** Whether we should navigate to report page when the route have a topMostReport */ shouldNavigateToTopMostReport: PropTypes.bool, - - /** Whether we should show the back button only on mobile */ - shouldUseCentralPaneView: PropTypes.bool, }; export default propTypes; diff --git a/src/components/HeaderWithBackButton/index.js b/src/components/HeaderWithBackButton/index.js index eab71beaaf8d..29af23cdbf2c 100755 --- a/src/components/HeaderWithBackButton/index.js +++ b/src/components/HeaderWithBackButton/index.js @@ -14,7 +14,6 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useThrottledButtonState from '@hooks/useThrottledButtonState'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import getButtonState from '@libs/getButtonState'; import Navigation from '@libs/Navigation/Navigation'; import CONST from '@src/CONST'; @@ -41,7 +40,6 @@ function HeaderWithBackButton({ shouldShowPinButton = false, shouldShowThreeDotsButton = false, shouldDisableThreeDotsButton = false, - shouldUseCentralPaneView = false, stepCounter = null, subtitle = '', title = '', @@ -63,8 +61,6 @@ function HeaderWithBackButton({ const {translate} = useLocalize(); const {isKeyboardShown} = useKeyboardState(); const waitForNavigate = useWaitForNavigation(); - const {isSmallScreenWidth} = useWindowDimensions(); - const shouldFinalShowBackButton = shouldShowBackButton && (!shouldUseCentralPaneView || isSmallScreenWidth); return ( - - {shouldFinalShowBackButton && ( + + {shouldShowBackButton && ( { diff --git a/src/components/IllustratedHeaderPageLayout.js b/src/components/IllustratedHeaderPageLayout.js index 89e21c92c31e..765f6c412ab4 100644 --- a/src/components/IllustratedHeaderPageLayout.js +++ b/src/components/IllustratedHeaderPageLayout.js @@ -35,9 +35,7 @@ const defaultProps = { function IllustratedHeaderPageLayout({backgroundColor, children, illustration, footer, overlayContent, ...propsToPassToHeader}) { const theme = useTheme(); const styles = useThemeStyles(); - const {isSmallScreenWidth} = useWindowDimensions(); - - const shouldUseMaxHeight = propsToPassToHeader.shouldUseCentralPaneView && !isSmallScreenWidth; + const shouldUseMaxHeight = !propsToPassToHeader.shouldShowBackButton; return ( Navigation.goBack(isReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(this.props.report.reportID) : ROUTES.SETTINGS.ROOT)} - shouldUseCentralPaneView - shouldShowBorderBottom + shouldShowBackButton={isReport || this.props.isSmallScreenWidth} /> @@ -136,4 +137,4 @@ ShareCodePage.propTypes = propTypes; ShareCodePage.defaultProps = defaultProps; ShareCodePage.displayName = 'ShareCodePage'; -export default compose(withEnvironment, withLocalize, withCurrentUserPersonalDetails, withThemeStyles)(ShareCodePage); +export default compose(withEnvironment, withLocalize, withCurrentUserPersonalDetails, withThemeStyles, withWindowDimensions)(ShareCodePage); diff --git a/src/pages/settings/AboutPage/AboutPage.js b/src/pages/settings/AboutPage/AboutPage.js index 2de1b93ac400..e486f4d7120c 100644 --- a/src/pages/settings/AboutPage/AboutPage.js +++ b/src/pages/settings/AboutPage/AboutPage.js @@ -11,6 +11,7 @@ import Text from '@components/Text'; import TextLink from '@components/TextLink'; import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions'; +import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import compose from '@libs/compose'; @@ -42,6 +43,7 @@ function getFlavor() { function AboutPage(props) { const styles = useThemeStyles(); + const theme = useTheme(); const {translate} = props; const popoverAnchor = useRef(null); const waitForNavigate = useWaitForNavigation(); @@ -104,8 +106,7 @@ function AboutPage(props) { Navigation.goBack(ROUTES.SETTINGS.ROOT)} - shouldUseCentralPaneView - shouldShowBorderBottom + shouldShowBackButton={props.isSmallScreenWidth} /> @@ -114,6 +115,7 @@ function AboutPage(props) { v{Environment.isInternalTestBuild() ? `${pkg.version} PR:${CONST.PULL_REQUEST_NUMBER}${getFlavor()}` : `${pkg.version}${getFlavor()}`} diff --git a/src/pages/settings/Preferences/PreferencesPage.js b/src/pages/settings/Preferences/PreferencesPage.js index 8357b22866f8..1e72456e4f58 100755 --- a/src/pages/settings/Preferences/PreferencesPage.js +++ b/src/pages/settings/Preferences/PreferencesPage.js @@ -13,6 +13,7 @@ import useEnvironment from '@hooks/useEnvironment'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; @@ -45,14 +46,14 @@ function PreferencesPage(props) { const styles = useThemeStyles(); const {isProduction} = useEnvironment(); const {translate, preferredLocale} = useLocalize(); + const {isSmallScreenWidth} = useWindowDimensions(); return ( Navigation.goBack(ROUTES.SETTINGS)} backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.PREFERENCES.ROOT].backgroundColor} illustration={LottieAnimations.PreferencesDJ} - shouldUseCentralPaneView + shouldShowBackButton={isSmallScreenWidth} > Navigation.goBack(ROUTES.SETTINGS.ROOT)} - shouldUseCentralPaneView - shouldShowBorderBottom + shouldShowBackButton={props.isSmallScreenWidth} /> diff --git a/src/pages/settings/Security/SecuritySettingsPage.js b/src/pages/settings/Security/SecuritySettingsPage.js index b475855e2f4e..f67ea15c5e13 100644 --- a/src/pages/settings/Security/SecuritySettingsPage.js +++ b/src/pages/settings/Security/SecuritySettingsPage.js @@ -11,6 +11,7 @@ import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import compose from '@libs/compose'; import Navigation from '@libs/Navigation/Navigation'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -38,6 +39,7 @@ function SecuritySettingsPage(props) { const styles = useThemeStyles(); const {translate} = props; const waitForNavigate = useWaitForNavigation(); + const {isSmallScreenWidth} = useWindowDimensions(); const menuItems = useMemo(() => { const baseMenuItems = [ @@ -67,10 +69,9 @@ function SecuritySettingsPage(props) { Navigation.goBack(ROUTES.SETTINGS.ROOT)} - shouldShowBackButton + shouldShowBackButton={isSmallScreenWidth} illustration={LottieAnimations.Safe} backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.SECURITY].backgroundColor} - shouldUseCentralPaneView > diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.js b/src/pages/settings/Wallet/WalletPage/WalletPage.js index 2d9fe599ccb7..38a00071c427 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.js +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.js @@ -323,7 +323,7 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod Navigation.goBack(ROUTES.SETTINGS.ROOT)} - shouldUseCentralPaneView + shouldShowBackButton={isSmallScreenWidth} /> diff --git a/src/pages/workspace/WorkspacesListPage.js b/src/pages/workspace/WorkspacesListPage.js index 686eff6e25ba..08e0065884ae 100755 --- a/src/pages/workspace/WorkspacesListPage.js +++ b/src/pages/workspace/WorkspacesListPage.js @@ -14,6 +14,7 @@ import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import compose from '@libs/compose'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; @@ -111,6 +112,7 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, u const styles = useThemeStyles(); const {translate} = useLocalize(); const {isOffline} = useNetwork(); + const {isSmallScreenWidth} = useWindowDimensions(); /** * @param {Boolean} isPaymentItem whether the item being rendered is the payments menu item @@ -187,7 +189,7 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, u illustration={LottieAnimations.WorkspacePlanet} onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS.ROOT)} title={translate('common.workspaces')} - shouldUseCentralPaneView + shouldShowBackButton={isSmallScreenWidth} footer={