Skip to content

Commit

Permalink
refactor & fix back button, and fix logo color
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmydel committed Jan 2, 2024
1 parent 188a9d8 commit 1d58bef
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
18 changes: 2 additions & 16 deletions src/components/HeaderWithBackButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -41,7 +40,6 @@ function HeaderWithBackButton({
shouldShowPinButton = false,
shouldShowThreeDotsButton = false,
shouldDisableThreeDotsButton = false,
shouldUseCentralPaneView = false,
stepCounter = null,
subtitle = '',
title = '',
Expand All @@ -63,27 +61,15 @@ function HeaderWithBackButton({
const {translate} = useLocalize();
const {isKeyboardShown} = useKeyboardState();
const waitForNavigate = useWaitForNavigation();
const {isSmallScreenWidth} = useWindowDimensions();
const shouldFinalShowBackButton = shouldShowBackButton && (!shouldUseCentralPaneView || isSmallScreenWidth);
return (
<View
// Hover on some part of close icons will not work on Electron if dragArea is true
// https://github.com/Expensify/App/issues/29598
dataSet={{dragArea: false}}
style={[styles.headerBar, shouldShowBorderBottom && styles.borderBottom, shouldShowBackButton && styles.pl2]}
>
<View
style={[
styles.dFlex,
styles.flexRow,
styles.alignItemsCenter,
styles.flexGrow1,
styles.justifyContentBetween,
styles.overflowHidden,
!shouldFinalShowBackButton && styles.pl5,
]}
>
{shouldFinalShowBackButton && (
<View style={[styles.dFlex, styles.flexRow, styles.alignItemsCenter, styles.flexGrow1, styles.justifyContentBetween, styles.overflowHidden, !shouldShowBackButton && styles.pl5]}>
{shouldShowBackButton && (
<Tooltip text={translate('common.back')}>
<PressableWithoutFeedback
onPress={() => {
Expand Down
4 changes: 1 addition & 3 deletions src/components/IllustratedHeaderPageLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<HeaderPageLayout
Expand Down
7 changes: 4 additions & 3 deletions src/pages/ShareCodePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsDefaultPro
import withEnvironment from '@components/withEnvironment';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import withThemeStyles, {withThemeStylesPropTypes} from '@components/withThemeStyles';
import withWindowDimensions, {windowDimensionsPropTypes} from '@components/withWindowDimensions';
import Clipboard from '@libs/Clipboard';
import compose from '@libs/compose';
import getPlatform from '@libs/getPlatform';
Expand All @@ -34,6 +35,7 @@ const propTypes = {
...withLocalizePropTypes,
...withCurrentUserPersonalDetailsPropTypes,
...withThemeStylesPropTypes,
...windowDimensionsPropTypes,
};

const defaultProps = {
Expand Down Expand Up @@ -82,8 +84,7 @@ class ShareCodePage extends React.Component {
<HeaderWithBackButton
title={this.props.translate('common.shareCode')}
onBackButtonPress={() => Navigation.goBack(isReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(this.props.report.reportID) : ROUTES.SETTINGS.ROOT)}
shouldUseCentralPaneView
shouldShowBorderBottom
shouldShowBackButton={isReport || this.props.isSmallScreenWidth}
/>

<ScrollView style={[this.props.themeStyles.flex1, this.props.themeStyles.mt3]}>
Expand Down Expand Up @@ -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);
6 changes: 4 additions & 2 deletions src/pages/settings/AboutPage/AboutPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -104,8 +106,7 @@ function AboutPage(props) {
<HeaderWithBackButton
title={props.translate('initialSettingsPage.about')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS.ROOT)}
shouldUseCentralPaneView
shouldShowBorderBottom
shouldShowBackButton={props.isSmallScreenWidth}
/>
<ScrollView contentContainerStyle={[styles.flexGrow1, styles.flexColumn, styles.justifyContentBetween, safeAreaPaddingBottomStyle]}>
<View style={[styles.flex1]}>
Expand All @@ -114,6 +115,7 @@ function AboutPage(props) {
<Logo
height={80}
width={80}
fill={theme.QRLogo}
/>
<Text style={[styles.textLabel, styles.alignSelfCenter, styles.mt6, styles.mb2, styles.colorMuted, styles.userSelectText]}>
v{Environment.isInternalTestBuild() ? `${pkg.version} PR:${CONST.PULL_REQUEST_NUMBER}${getFlavor()}` : `${pkg.version}${getFlavor()}`}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/settings/Preferences/PreferencesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -45,14 +46,14 @@ function PreferencesPage(props) {
const styles = useThemeStyles();
const {isProduction} = useEnvironment();
const {translate, preferredLocale} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();

return (
<IllustratedHeaderPageLayout
title={translate('common.preferences')}
// onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)}
backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.PREFERENCES.ROOT].backgroundColor}
illustration={LottieAnimations.PreferencesDJ}
shouldUseCentralPaneView
shouldShowBackButton={isSmallScreenWidth}
>
<View style={styles.mb6}>
<Text
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Profile/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ function ProfilePage(props) {
<HeaderWithBackButton
title={props.translate('common.profile')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS.ROOT)}
shouldUseCentralPaneView
shouldShowBorderBottom
shouldShowBackButton={props.isSmallScreenWidth}
/>
<ScrollView>
<View style={[styles.mt4]}>
Expand Down
5 changes: 3 additions & 2 deletions src/pages/settings/Security/SecuritySettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -38,6 +39,7 @@ function SecuritySettingsPage(props) {
const styles = useThemeStyles();
const {translate} = props;
const waitForNavigate = useWaitForNavigation();
const {isSmallScreenWidth} = useWindowDimensions();

const menuItems = useMemo(() => {
const baseMenuItems = [
Expand Down Expand Up @@ -67,10 +69,9 @@ function SecuritySettingsPage(props) {
<IllustratedHeaderPageLayout
title={translate('initialSettingsPage.security')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS.ROOT)}
shouldShowBackButton
shouldShowBackButton={isSmallScreenWidth}
illustration={LottieAnimations.Safe}
backgroundColor={theme.PAGE_THEMES[SCREENS.SETTINGS.SECURITY].backgroundColor}
shouldUseCentralPaneView
>
<ScrollView contentContainerStyle={[styles.flexGrow1, styles.flexColumn, styles.justifyContentBetween]}>
<View style={[styles.flex1]}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Wallet/WalletPage/WalletPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function WalletPage({bankAccountList, cardList, fundList, isLoadingPaymentMethod
<HeaderWithBackButton
title={translate('common.wallet')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS.ROOT)}
shouldUseCentralPaneView
shouldShowBackButton={isSmallScreenWidth}
/>
<View style={[styles.flex1, styles.mb4]}>
<ScrollView>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/workspace/WorkspacesListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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={
<Button
accessibilityLabel={translate('workspace.new.newWorkspace')}
Expand Down

0 comments on commit 1d58bef

Please sign in to comment.