From 68a40f865bb0d47e1689eb6b4c11d671fb551e4d Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 12:34:45 +0100 Subject: [PATCH 001/600] add test navigator --- src/NAVIGATORS.ts | 1 + src/ROUTES.ts | 1 + src/SCREENS.ts | 1 + .../Navigation/AppNavigator/AuthScreens.js | 6 ++++ .../Navigators/SettingsNavigator.js | 36 +++++++++++++++++++ src/libs/Navigation/linkingConfig.js | 6 ++++ .../FloatingActionButtonAndPopover.js | 8 ++--- 7 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js diff --git a/src/NAVIGATORS.ts b/src/NAVIGATORS.ts index a3a041e65684..52480d874d7b 100644 --- a/src/NAVIGATORS.ts +++ b/src/NAVIGATORS.ts @@ -5,5 +5,6 @@ export default { CENTRAL_PANE_NAVIGATOR: 'CentralPaneNavigator', RIGHT_MODAL_NAVIGATOR: 'RightModalNavigator', + SETTINGS_NAVIGATOR: 'Settings_Navigator', FULL_SCREEN_NAVIGATOR: 'FullScreenNavigator', } as const; diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 57d4eb8187ec..bd5f6cc422b3 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -58,6 +58,7 @@ export default { }, SETTINGS: 'settings', + SETTINGS_NEW: 'settings_new', SETTINGS_PROFILE: 'settings/profile', SETTINGS_SHARE_CODE: 'settings/shareCode', SETTINGS_DISPLAY_NAME: 'settings/profile/display-name', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index afc368858f55..f18fb49dff80 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -16,6 +16,7 @@ export default { NOT_FOUND: 'not-found', TRANSITION_BETWEEN_APPS: 'TransitionBetweenApps', VALIDATE_LOGIN: 'ValidateLogin', + SETTINGS_NEW: 'SettingsNew', SETTINGS: { ROOT: 'Settings_Root', PREFERENCES: 'Settings_Preferences', diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index aedb2fa8d741..52a7f0c41afe 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -35,6 +35,7 @@ import defaultScreenOptions from './defaultScreenOptions'; import getRootNavigatorScreenOptions from './getRootNavigatorScreenOptions'; import CentralPaneNavigator from './Navigators/CentralPaneNavigator'; import RightModalNavigator from './Navigators/RightModalNavigator'; +import SettingsNavigator from './Navigators/SettingsNavigator'; const loadReportAttachments = () => require('../../../pages/home/report/ReportAttachments').default; const loadSidebarScreen = () => require('../../../pages/home/sidebar/SidebarScreen').default; @@ -335,6 +336,11 @@ function AuthScreens({isUsingMemoryOnlyKeys, lastUpdateIDAppliedToClient, sessio component={RightModalNavigator} listeners={modalScreenListeners} /> + + + + + + ); +} + +SettingsNavigator.propTypes = propTypes; +SettingsNavigator.displayName = 'SettingsNavigator'; + +export default SettingsNavigator; diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 44473998ac62..4137260e2390 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -429,6 +429,12 @@ export default { }, }, }, + + [NAVIGATORS.SETTINGS_NAVIGATOR]: { + screens: { + [SCREENS.SETTINGS_NEW]: ROUTES.SETTINGS_NEW, + } + } }, }, }; diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 739f7e3e0295..1eebf43d8a0a 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -243,11 +243,9 @@ function FloatingActionButtonAndPopover(props) { isActive={isCreateMenuActive} ref={anchorRef} onPress={() => { - if (isCreateMenuActive) { - hideCreateMenu(); - } else { - showCreateMenu(); - } + console.log('FloatingActionButtonAndPopover.js: showCreateMenu()'); + // navigate to new screen + Navigation.navigate(ROUTES.SETTINGS_NEW); }} /> From bddaa69fad1bfc22d4cd5afe66e38c7ebba4003e Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 13:43:00 +0100 Subject: [PATCH 002/600] draft --- src/ROUTES.ts | 1 + .../Navigators/SettingsNavigator.js | 41 +++++++++++++------ .../createCustomStackNavigator/index.js | 15 +++++-- src/libs/Navigation/linkingConfig.js | 4 +- .../FloatingActionButtonAndPopover.js | 2 +- 5 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index bd5f6cc422b3..95d6f13a8921 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -59,6 +59,7 @@ export default { SETTINGS: 'settings', SETTINGS_NEW: 'settings_new', + SETTINGS_NEW_PROFILE: 'settings_new/profile', SETTINGS_PROFILE: 'settings/profile', SETTINGS_SHARE_CODE: 'settings/shareCode', SETTINGS_DISPLAY_NAME: 'settings/profile/display-name', diff --git a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js index 46d80cb0fb55..ef4d0b30a05f 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js @@ -1,12 +1,13 @@ -import {createStackNavigator} from '@react-navigation/stack'; import PropTypes from 'prop-types'; import React from 'react'; -import {View} from 'react-native'; -import RHPScreenOptions from '@libs/Navigation/AppNavigator/RHPScreenOptions'; +import { View } from 'react-native'; import useThemeStyles from '@styles/useThemeStyles'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; - -const Stack = createStackNavigator(); +import useWindowDimensions from '@hooks/useWindowDimensions'; +import getRootNavigatorScreenOptions from '@libs/Navigation/AppNavigator/getRootNavigatorScreenOptions'; +import createCustomStackNavigator from '@libs/Navigation/AppNavigator/createCustomStackNavigator'; +import NAVIGATORS from '@src/NAVIGATORS'; +import ROUTES from '@src/ROUTES'; const propTypes = { /* Navigation functions provided by React Navigation */ @@ -15,18 +16,32 @@ const propTypes = { }).isRequired, }; +const RootStack = createCustomStackNavigator(); + function SettingsNavigator() { const styles = useThemeStyles(); + const {isSmallScreenWidth} = useWindowDimensions(); + const screenOptions = getRootNavigatorScreenOptions(isSmallScreenWidth); return ( - - - - - + + + + + + ); } diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js index 8924b01e2acb..bb2edb3aa2bb 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js @@ -19,20 +19,23 @@ const propTypes = { /* Screen options defined for this navigator */ // eslint-disable-next-line react/forbid-prop-types screenOptions: PropTypes.object, + + centralRoute: PropTypes.string, }; const defaultProps = { initialRouteName: undefined, screenOptions: undefined, + centralRoute: NAVIGATORS.CENTRAL_PANE_NAVIGATOR, }; -function reduceReportRoutes(routes) { +function reduceReportRoutes(routes, centralRoute=NAVIGATORS.CENTRAL_PANE_NAVIGATOR) { const result = []; let count = 0; const reverseRoutes = [...routes].reverse(); reverseRoutes.forEach((route) => { - if (route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR) { + if (route.name === centralRoute) { // Remove all report routes except the last 3. This will improve performance. if (count < 3) { result.push(route); @@ -43,6 +46,8 @@ function reduceReportRoutes(routes) { } }); + console.log('reduceReportRoutes', centralRoute, routes, result); + return result.reverse(); } @@ -62,14 +67,16 @@ function ResponsiveStackNavigator(props) { }); const stateToRender = useMemo(() => { - const result = reduceReportRoutes(state.routes); + const result = reduceReportRoutes(state.routes, props.centralRoute); return { ...state, index: result.length - 1, routes: [...result], }; - }, [state]); + }, [props.centralRoute, state]); + + console.log('ResponsiveStackNavigator', props.centralRoute); return ( diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 4137260e2390..05f6e3c4e344 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -432,8 +432,8 @@ export default { [NAVIGATORS.SETTINGS_NAVIGATOR]: { screens: { - [SCREENS.SETTINGS_NEW]: ROUTES.SETTINGS_NEW, - } + [SCREENS.SETTINGS_NEW_PROFILE]: {path: ROUTES.SETTINGS_NEW_PROFILE}, + }, } }, }, diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index 1eebf43d8a0a..c798121b1d2a 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -245,7 +245,7 @@ function FloatingActionButtonAndPopover(props) { onPress={() => { console.log('FloatingActionButtonAndPopover.js: showCreateMenu()'); // navigate to new screen - Navigation.navigate(ROUTES.SETTINGS_NEW); + Navigation.navigate(ROUTES.SETTINGS_NEW_PROFILE); }} /> From d8910f7d0d038a80b7b1e490008bf4b26a2f7527 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 13:53:09 +0100 Subject: [PATCH 003/600] add patch --- .../@react-navigation+stack+6.3.16+002+dontDetachScreen.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/@react-navigation+stack+6.3.16+002+dontDetachScreen.patch b/patches/@react-navigation+stack+6.3.16+002+dontDetachScreen.patch index d64fc4fecf74..ac4e8bafa8ab 100644 --- a/patches/@react-navigation+stack+6.3.16+002+dontDetachScreen.patch +++ b/patches/@react-navigation+stack+6.3.16+002+dontDetachScreen.patch @@ -43,7 +43,7 @@ index 7558eb3..b7bb75e 100644 }) : STATE_TRANSITIONING_OR_BELOW_TOP; } + -+ const isHomeScreenAndNotOnTop = route.name === 'Home' && isScreenActive !== STATE_ON_TOP; ++ const isHomeScreenAndNotOnTop = (route.name === 'Home' || route.name === 'SettingsHome') && isScreenActive !== STATE_ON_TOP; + const { headerShown = true, From 52388b93907b5aeef07c91e5c03244494124e1bf Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 14:32:14 +0100 Subject: [PATCH 004/600] draft --- src/NAVIGATORS.ts | 1 - src/ROUTES.ts | 2 +- src/SCREENS.ts | 2 +- .../Navigation/AppNavigator/AuthScreens.js | 2 +- .../Navigators/SettingsNavigator.js | 27 ++++++++++++------- src/libs/Navigation/linkTo.js | 1 + src/libs/Navigation/linkingConfig.js | 15 +++++++++-- 7 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/NAVIGATORS.ts b/src/NAVIGATORS.ts index 52480d874d7b..a3a041e65684 100644 --- a/src/NAVIGATORS.ts +++ b/src/NAVIGATORS.ts @@ -5,6 +5,5 @@ export default { CENTRAL_PANE_NAVIGATOR: 'CentralPaneNavigator', RIGHT_MODAL_NAVIGATOR: 'RightModalNavigator', - SETTINGS_NAVIGATOR: 'Settings_Navigator', FULL_SCREEN_NAVIGATOR: 'FullScreenNavigator', } as const; diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 95d6f13a8921..3d1a52230f3e 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -58,7 +58,7 @@ export default { }, SETTINGS: 'settings', - SETTINGS_NEW: 'settings_new', + SETTINGS_HOME: 'settings_new', SETTINGS_NEW_PROFILE: 'settings_new/profile', SETTINGS_PROFILE: 'settings/profile', SETTINGS_SHARE_CODE: 'settings/shareCode', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index f18fb49dff80..b721d7f32c4b 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -16,7 +16,7 @@ export default { NOT_FOUND: 'not-found', TRANSITION_BETWEEN_APPS: 'TransitionBetweenApps', VALIDATE_LOGIN: 'ValidateLogin', - SETTINGS_NEW: 'SettingsNew', + SETTINGS_HOME: 'SettingsHome', SETTINGS: { ROOT: 'Settings_Root', PREFERENCES: 'Settings_Preferences', diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 52a7f0c41afe..1d8ce5c69164 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -337,7 +337,7 @@ function AuthScreens({isUsingMemoryOnlyKeys, lastUpdateIDAppliedToClient, sessio listeners={modalScreenListeners} /> diff --git a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js index ef4d0b30a05f..da46b8a4a761 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js @@ -8,38 +8,47 @@ import getRootNavigatorScreenOptions from '@libs/Navigation/AppNavigator/getRoot import createCustomStackNavigator from '@libs/Navigation/AppNavigator/createCustomStackNavigator'; import NAVIGATORS from '@src/NAVIGATORS'; import ROUTES from '@src/ROUTES'; +import SCREENS from '@src/SCREENS'; +import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators'; const propTypes = { /* Navigation functions provided by React Navigation */ navigation: PropTypes.shape({ goBack: PropTypes.func.isRequired, + getState: PropTypes.func.isRequired, }).isRequired, }; const RootStack = createCustomStackNavigator(); -function SettingsNavigator() { +function SettingsNavigator({navigation}) { const styles = useThemeStyles(); const {isSmallScreenWidth} = useWindowDimensions(); const screenOptions = getRootNavigatorScreenOptions(isSmallScreenWidth); + console.log('navigation state', navigation.getState()); + return ( - + + {/* */} ); diff --git a/src/libs/Navigation/linkTo.js b/src/libs/Navigation/linkTo.js index 286074914cf7..72ff8f795a95 100644 --- a/src/libs/Navigation/linkTo.js +++ b/src/libs/Navigation/linkTo.js @@ -58,6 +58,7 @@ export default function linkTo(navigation, path, type) { const state = getStateFromPath(path); const action = getActionFromState(state, linkingConfig.config); + console.log('linkTo', state, action); // If action type is different than NAVIGATE we can't change it to the PUSH safely if (action.type === CONST.NAVIGATION.ACTION_TYPE.NAVIGATE) { diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 05f6e3c4e344..1a63a8e47569 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -430,9 +430,20 @@ export default { }, }, - [NAVIGATORS.SETTINGS_NAVIGATOR]: { + [NAVIGATORS.FULL_SCREEN_NAVIGATOR]: { screens: { - [SCREENS.SETTINGS_NEW_PROFILE]: {path: ROUTES.SETTINGS_NEW_PROFILE}, + Settings: { + screens: { + [SCREENS.SETTINGS_HOME]: { + path: ROUTES.SETTINGS_HOME, + exact: true, + }, + [SCREENS.SETTINGS_NEW_PROFILE]: { + path: ROUTES.SETTINGS_NEW_PROFILE, + exact: true, + }, + } + } }, } }, From 0d665ef8c9270972710606527d09671c1648de77 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:02:19 +0100 Subject: [PATCH 005/600] another step --- .../Navigators/SettingsNavigator.js | 10 +++---- src/libs/Navigation/linkingConfig.js | 27 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js index da46b8a4a761..fa0bc62cc9c0 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js @@ -2,15 +2,14 @@ import PropTypes from 'prop-types'; import React from 'react'; import { View } from 'react-native'; import useThemeStyles from '@styles/useThemeStyles'; -import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import useWindowDimensions from '@hooks/useWindowDimensions'; import getRootNavigatorScreenOptions from '@libs/Navigation/AppNavigator/getRootNavigatorScreenOptions'; import createCustomStackNavigator from '@libs/Navigation/AppNavigator/createCustomStackNavigator'; -import NAVIGATORS from '@src/NAVIGATORS'; -import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators'; +const loadSidebarScreen = () => require('../../../../pages/home/sidebar/SidebarScreen').default; + const propTypes = { /* Navigation functions provided by React Navigation */ navigation: PropTypes.shape({ @@ -33,15 +32,14 @@ function SettingsNavigator({navigation}) { diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 1a63a8e47569..71f7f6916355 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -432,18 +432,21 @@ export default { [NAVIGATORS.FULL_SCREEN_NAVIGATOR]: { screens: { - Settings: { - screens: { - [SCREENS.SETTINGS_HOME]: { - path: ROUTES.SETTINGS_HOME, - exact: true, - }, - [SCREENS.SETTINGS_NEW_PROFILE]: { - path: ROUTES.SETTINGS_NEW_PROFILE, - exact: true, - }, - } - } + [SCREENS.SETTINGS_HOME]: { + path: ROUTES.SETTINGS_HOME, + }, + SettingsCentralPane: { + path: ROUTES.SETTINGS_NEW_PROFILE, + exact: true, + }, + // Settings: { + // screens: { + // [SCREENS.SETTINGS_NEW_PROFILE]: { + // path: ROUTES.SETTINGS_NEW_PROFILE, + // exact: true, + // }, + // } + // } }, } }, From dba92bfb1fe64b727baf8d56665953c36b7c1846 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:05:44 +0100 Subject: [PATCH 006/600] another step forward --- src/SCREENS.ts | 1 + .../Navigation/AppNavigator/Navigators/SettingsNavigator.js | 2 +- src/libs/Navigation/linkingConfig.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index b721d7f32c4b..b7def3ce8e23 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -17,6 +17,7 @@ export default { TRANSITION_BETWEEN_APPS: 'TransitionBetweenApps', VALIDATE_LOGIN: 'ValidateLogin', SETTINGS_HOME: 'SettingsHome', + SETTINGS_NEW_PROFILE: 'SettingsNewProfile', SETTINGS: { ROOT: 'Settings_Root', PREFERENCES: 'Settings_Preferences', diff --git a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js index fa0bc62cc9c0..705eaf35eb7b 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js @@ -39,7 +39,7 @@ function SettingsNavigator({navigation}) { getComponent={loadSidebarScreen} /> diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 71f7f6916355..0d09a984ae61 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -435,7 +435,7 @@ export default { [SCREENS.SETTINGS_HOME]: { path: ROUTES.SETTINGS_HOME, }, - SettingsCentralPane: { + [SCREENS.SETTINGS_NEW_PROFILE]: { path: ROUTES.SETTINGS_NEW_PROFILE, exact: true, }, From 14e07418e95a4e342b33f278e8690d6525ae60a4 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:19:38 +0100 Subject: [PATCH 007/600] another step forward --- .../Navigators/SettingsNavigator.js | 7 +-- .../CustomRouter.js | 53 +++++++++++++------ .../createCustomStackNavigator/index.js | 1 + src/libs/Navigation/linkingConfig.js | 2 +- .../FloatingActionButtonAndPopover.js | 2 +- 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js index 705eaf35eb7b..3d82337c6ad7 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js @@ -32,6 +32,7 @@ function SettingsNavigator({navigation}) { - {/* */} ); diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js index 5d3eb38d49dc..2a05a90796bb 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js @@ -3,12 +3,14 @@ import lodashFindLast from 'lodash/findLast'; import _ from 'underscore'; import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; +import CentralPaneNavigator from '../Navigators/CentralPaneNavigator'; /** * @param {Object} state - react-navigation state + * @param {String} centralRoute - name of the central route * @returns {Boolean} */ -const isAtLeastOneCentralPaneNavigatorInState = (state) => _.find(state.routes, (r) => r.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR); +const isAtLeastOneCentralPaneNavigatorInState = (state, centralRoute) => _.find(state.routes, (r) => r.name === centralRoute); /** * @param {Object} state - react-navigation state @@ -41,22 +43,37 @@ const getTopMostReportIDFromRHP = (state) => { * The report screen will self set proper reportID param based on the helper function findLastAccessedReport (look at ReportScreenWrapper for more info) * * @param {Object} state - react-navigation state + * @param {String} centralRoute - name of the central route */ -const addCentralPaneNavigatorRoute = (state) => { +const addCentralPaneNavigatorRoute = (state, centralRoute) => { const reportID = getTopMostReportIDFromRHP(state); - const centralPaneNavigatorRoute = { - name: NAVIGATORS.CENTRAL_PANE_NAVIGATOR, - state: { - routes: [ - { - name: SCREENS.REPORT, - params: { - reportID, + let centralPaneNavigatorRoute; + if (centralRoute === NAVIGATORS.CENTRAL_PANE_NAVIGATOR) { + centralPaneNavigatorRoute = { + name: NAVIGATORS.CENTRAL_PANE_NAVIGATOR, + state: { + routes: [ + { + name: SCREENS.REPORT, + params: { + reportID, + }, }, - }, - ], - }, - }; + ], + }, + }; + } else { + centralPaneNavigatorRoute = { + name: centralRoute, + state: { + routes: [ + { + name: 'SettingsCentralPane', + }, + ], + }, + }; + } state.routes.splice(1, 0, centralPaneNavigatorRoute); // eslint-disable-next-line no-param-reassign state.index = state.routes.length - 1; @@ -64,16 +81,20 @@ const addCentralPaneNavigatorRoute = (state) => { function CustomRouter(options) { const stackRouter = StackRouter(options); + const centralRoute = options.centralRoute || NAVIGATORS.CENTRAL_PANE_NAVIGATOR; + console.log('CustomRouter', centralRoute); return { ...stackRouter, getRehydratedState(partialState, {routeNames, routeParamList}) { + console.log('getRehydratedState', centralRoute); // Make sure that there is at least one CentralPaneNavigator (ReportScreen by default) in the state if this is a wide layout - if (!isAtLeastOneCentralPaneNavigatorInState(partialState) && !options.getIsSmallScreenWidth()) { + if (!isAtLeastOneCentralPaneNavigatorInState(partialState, centralRoute) && !options.getIsSmallScreenWidth()) { + console.log('getRehydratedState', centralRoute, 'adding CentralPaneNavigator'); // If we added a route we need to make sure that the state.stale is true to generate new key for this route // eslint-disable-next-line no-param-reassign partialState.stale = true; - addCentralPaneNavigatorRoute(partialState); + addCentralPaneNavigatorRoute(partialState, centralRoute); } const state = stackRouter.getRehydratedState(partialState, {routeNames, routeParamList}); return state; diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js index bb2edb3aa2bb..120e6e99dd61 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js @@ -64,6 +64,7 @@ function ResponsiveStackNavigator(props) { initialRouteName: props.initialRouteName, // Options for useNavigationBuilder won't update on prop change, so we need to pass a getter for the router to have the current state of isSmallScreenWidth. getIsSmallScreenWidth: () => isSmallScreenWidthRef.current, + centralRoute: props.centralRoute, }); const stateToRender = useMemo(() => { diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 0d09a984ae61..71f7f6916355 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -435,7 +435,7 @@ export default { [SCREENS.SETTINGS_HOME]: { path: ROUTES.SETTINGS_HOME, }, - [SCREENS.SETTINGS_NEW_PROFILE]: { + SettingsCentralPane: { path: ROUTES.SETTINGS_NEW_PROFILE, exact: true, }, diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js index c798121b1d2a..5ad3e4431b32 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js @@ -245,7 +245,7 @@ function FloatingActionButtonAndPopover(props) { onPress={() => { console.log('FloatingActionButtonAndPopover.js: showCreateMenu()'); // navigate to new screen - Navigation.navigate(ROUTES.SETTINGS_NEW_PROFILE); + Navigation.navigate(ROUTES.SETTINGS_HOME); }} /> From 18ed44a367f7cdc2e423bf3d1cdb16d2fa90a584 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:39:52 +0100 Subject: [PATCH 008/600] another step forward 123 --- .../AppNavigator/Navigators/SettingsNavigator.js | 6 +++++- .../createCustomStackNavigator/CustomRouter.js | 11 ++++++----- .../AppNavigator/createCustomStackNavigator/index.js | 6 +++++- src/libs/Navigation/NavigationRoot.js | 1 + src/libs/Navigation/linkingConfig.js | 8 ++++++-- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js index 3d82337c6ad7..13cd7ebfd27c 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js @@ -9,6 +9,7 @@ import SCREENS from '@src/SCREENS'; import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators'; const loadSidebarScreen = () => require('../../../../pages/home/sidebar/SidebarScreen').default; +const loadPage = () => require('../../../../pages/ErrorPage/NotFoundPage').default; const propTypes = { /* Navigation functions provided by React Navigation */ @@ -27,17 +28,20 @@ function SettingsNavigator({navigation}) { console.log('navigation state', navigation.getState()); + console.log('loadSidebarScreen', loadSidebarScreen, 'not found page', loadPage) + return ( _.find(state.routes, (r) => r.name === centralRoute); +const isAtLeastOneCentralPaneNavigatorInState = (state, centralRoute) => { + console.log('isAtLeastOneCentralPaneNavigatorInState', centralRoute); + return _.find(state.routes, (r) => r.name === centralRoute) +}; /** * @param {Object} state - react-navigation state @@ -81,16 +83,15 @@ const addCentralPaneNavigatorRoute = (state, centralRoute) => { function CustomRouter(options) { const stackRouter = StackRouter(options); - const centralRoute = options.centralRoute || NAVIGATORS.CENTRAL_PANE_NAVIGATOR; - console.log('CustomRouter', centralRoute); return { ...stackRouter, getRehydratedState(partialState, {routeNames, routeParamList}) { + const centralRoute = options.centralRoute(); console.log('getRehydratedState', centralRoute); // Make sure that there is at least one CentralPaneNavigator (ReportScreen by default) in the state if this is a wide layout if (!isAtLeastOneCentralPaneNavigatorInState(partialState, centralRoute) && !options.getIsSmallScreenWidth()) { - console.log('getRehydratedState', centralRoute, 'adding CentralPaneNavigator'); + console.log('getRehydratedState', centralRoute, 'adding central pane'); // If we added a route we need to make sure that the state.stale is true to generate new key for this route // eslint-disable-next-line no-param-reassign partialState.stale = true; diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js index 120e6e99dd61..25fee9a02c77 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/index.js @@ -52,19 +52,23 @@ function reduceReportRoutes(routes, centralRoute=NAVIGATORS.CENTRAL_PANE_NAVIGAT } function ResponsiveStackNavigator(props) { + console.log('ResponsiveStackNavigator', props.centralRoute) const {isSmallScreenWidth} = useWindowDimensions(); const isSmallScreenWidthRef = useRef(isSmallScreenWidth); isSmallScreenWidthRef.current = isSmallScreenWidth; + const centralRouteRef = useRef(props.centralRoute); + centralRouteRef.current = props.centralRoute; + const {navigation, state, descriptors, NavigationContent} = useNavigationBuilder(CustomRouter, { children: props.children, screenOptions: props.screenOptions, initialRouteName: props.initialRouteName, // Options for useNavigationBuilder won't update on prop change, so we need to pass a getter for the router to have the current state of isSmallScreenWidth. getIsSmallScreenWidth: () => isSmallScreenWidthRef.current, - centralRoute: props.centralRoute, + centralRoute: () => centralRouteRef.current, }); const stateToRender = useMemo(() => { diff --git a/src/libs/Navigation/NavigationRoot.js b/src/libs/Navigation/NavigationRoot.js index 2373066cf4bd..314a324dc0fe 100644 --- a/src/libs/Navigation/NavigationRoot.js +++ b/src/libs/Navigation/NavigationRoot.js @@ -75,6 +75,7 @@ function NavigationRoot(props) { if (!navigationRef.isReady() || !props.authenticated) { return; } + // TODO: Add force rehydration! // We need to force state rehydration so the CustomRouter can add the CentralPaneNavigator route if necessary. navigationRef.resetRoot(navigationRef.getRootState()); }, [isSmallScreenWidth, props.authenticated]); diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 71f7f6916355..2fd0db3cd48f 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -436,8 +436,12 @@ export default { path: ROUTES.SETTINGS_HOME, }, SettingsCentralPane: { - path: ROUTES.SETTINGS_NEW_PROFILE, - exact: true, + screens: { + [SCREENS.SETTINGS_NEW_PROFILE]: { + path: ROUTES.SETTINGS_NEW_PROFILE, + exact: true, + } + } }, // Settings: { // screens: { From 7fa40aedb098807d85aa709f9527e26080b58ab2 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:49:31 +0100 Subject: [PATCH 009/600] mini step forward --- .../Navigators/SettingsNavigator.js | 7 +- src/libs/Navigation/linkingConfig.js | 402 +++++++++--------- 2 files changed, 199 insertions(+), 210 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js index 13cd7ebfd27c..4cfb5a9ae82b 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js @@ -7,9 +7,9 @@ import getRootNavigatorScreenOptions from '@libs/Navigation/AppNavigator/getRoot import createCustomStackNavigator from '@libs/Navigation/AppNavigator/createCustomStackNavigator'; import SCREENS from '@src/SCREENS'; import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators'; +import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; -const loadSidebarScreen = () => require('../../../../pages/home/sidebar/SidebarScreen').default; -const loadPage = () => require('../../../../pages/ErrorPage/NotFoundPage').default; +const loadPage = () => require('../../../../pages/settings/InitialSettingsPage').default; const propTypes = { /* Navigation functions provided by React Navigation */ @@ -28,14 +28,11 @@ function SettingsNavigator({navigation}) { console.log('navigation state', navigation.getState()); - console.log('loadSidebarScreen', loadSidebarScreen, 'not found page', loadPage) - return ( Date: Tue, 21 Nov 2023 16:14:00 +0100 Subject: [PATCH 010/600] add initial state --- .../AppNavigator/Navigators/SettingsNavigator.js | 1 - .../createCustomStackNavigator/CustomRouter.js | 11 ++++++++++- src/libs/Navigation/Navigation.js | 8 +++++++- src/pages/settings/InitialSettingsPage.js | 1 + src/pages/settings/Preferences/PreferencesPage.js | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js index 4cfb5a9ae82b..e1d68e58e973 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/SettingsNavigator.js @@ -7,7 +7,6 @@ import getRootNavigatorScreenOptions from '@libs/Navigation/AppNavigator/getRoot import createCustomStackNavigator from '@libs/Navigation/AppNavigator/createCustomStackNavigator'; import SCREENS from '@src/SCREENS'; import * as ModalStackNavigators from '@libs/Navigation/AppNavigator/ModalStackNavigators'; -import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; const loadPage = () => require('../../../../pages/settings/InitialSettingsPage').default; diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js index 31bf4a7bb1b5..3a53a54e60ad 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js @@ -70,7 +70,7 @@ const addCentralPaneNavigatorRoute = (state, centralRoute) => { state: { routes: [ { - name: 'SettingsCentralPane', + name: SCREENS.SETTINGS.PREFERENCES, }, ], }, @@ -86,6 +86,15 @@ function CustomRouter(options) { return { ...stackRouter, + getInitialState({routeNames, routeParamList, routeGetIdList}) { + console.log('getInitialState', routeNames, routeParamList, routeGetIdList); + const centralRoute = options.centralRoute(); + const initialState = stackRouter.getInitialState({routeNames, routeParamList, routeGetIdList}); + if (!isAtLeastOneCentralPaneNavigatorInState(initialState, centralRoute) && !options.getIsSmallScreenWidth()) { + addCentralPaneNavigatorRoute(initialState, centralRoute); + } + return initialState; + }, getRehydratedState(partialState, {routeNames, routeParamList}) { const centralRoute = options.centralRoute(); console.log('getRehydratedState', centralRoute); diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index 7a2c61ea7b53..bcf0effa37a4 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -66,7 +66,7 @@ const getActiveRouteIndex = function (route, index) { return getActiveRouteIndex(childActiveRoute, route.state.index || 0); } - if (route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { + if (route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR || route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR) { return 0; } @@ -147,6 +147,12 @@ function goBack(fallbackRoute, shouldEnforceFallback = false, shouldPopToTop = f navigationRef.current.goBack(); return; } + + if(lastRoute.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR) { + console.log('lastRoute', lastRoute); + navigationRef.current.goBack(); + return; + } } if (shouldEnforceFallback || (isFirstRouteInNavigator && fallbackRoute)) { diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index d88105b31360..628ca489fc70 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -388,6 +388,7 @@ function InitialSettingsPage(props) { headerContent={headerContent} headerContainerStyles={[styles.staticHeaderImage, styles.justifyContentCenter]} backgroundColor={theme.PAGE_BACKGROUND_COLORS[SCREENS.SETTINGS.ROOT]} + onBackButtonPress={() => Navigation.goBack()} > {getMenuItems} diff --git a/src/pages/settings/Preferences/PreferencesPage.js b/src/pages/settings/Preferences/PreferencesPage.js index 4dbc5fda9198..5c056385dd2d 100755 --- a/src/pages/settings/Preferences/PreferencesPage.js +++ b/src/pages/settings/Preferences/PreferencesPage.js @@ -45,7 +45,7 @@ function PreferencesPage(props) { return ( Navigation.goBack(ROUTES.SETTINGS)} + shouldShowBackButton={false} backgroundColor={theme.PAGE_BACKGROUND_COLORS[SCREENS.SETTINGS.PREFERENCES]} illustration={LottieAnimations.PreferencesDJ} > From 6b1dee1cfb3ce68b8bb9c3a4283d3dee3f9db837 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Tue, 21 Nov 2023 16:44:04 +0100 Subject: [PATCH 011/600] few fixes --- src/SCREENS.ts | 1 + .../AppNavigator/ModalStackNavigators.js | 6 +++--- .../CustomRouter.js | 2 +- src/libs/Navigation/Navigation.js | 21 ++++++++++++++----- src/libs/Navigation/linkingConfig.js | 5 +---- .../sidebar/PressableAvatarWithIndicator.js | 2 +- src/pages/settings/InitialSettingsPage.js | 7 ++++++- 7 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index b7def3ce8e23..6ef776ef4507 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -21,6 +21,7 @@ export default { SETTINGS: { ROOT: 'Settings_Root', PREFERENCES: 'Settings_Preferences', + PROFILE: 'Settings_Profile', WORKSPACES: 'Settings_Workspaces', SECURITY: 'Settings_Security', STATUS: 'Settings_Status', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js index a2f9bdd7a903..1368f12a0213 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js @@ -1,4 +1,4 @@ -import {CardStyleInterpolators, createStackNavigator} from '@react-navigation/stack'; +import {createStackNavigator} from '@react-navigation/stack'; import React from 'react'; import _ from 'underscore'; import styles from '@styles/styles'; @@ -7,7 +7,8 @@ import SCREENS from '@src/SCREENS'; const defaultSubRouteOptions = { cardStyle: styles.navigationScreenCardStyle, headerShown: false, - cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS, + // TODO: Can remove it + // cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS, }; /** @@ -131,7 +132,6 @@ const NewTeachersUniteNavigator = createModalStackNavigator({ }); const SettingsModalStackNavigator = createModalStackNavigator({ - [SCREENS.SETTINGS.ROOT]: () => require('../../../pages/settings/InitialSettingsPage').default, Settings_Share_Code: () => require('../../../pages/ShareCodePage').default, [SCREENS.SETTINGS.WORKSPACES]: () => require('../../../pages/workspace/WorkspacesListPage').default, Settings_Profile: () => require('../../../pages/settings/Profile/ProfilePage').default, diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js index 3a53a54e60ad..5ac04ab884a4 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js @@ -70,7 +70,7 @@ const addCentralPaneNavigatorRoute = (state, centralRoute) => { state: { routes: [ { - name: SCREENS.SETTINGS.PREFERENCES, + name: SCREENS.SETTINGS.PROFILE, }, ], }, diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js index bcf0effa37a4..da5e8fbaecf0 100644 --- a/src/libs/Navigation/Navigation.js +++ b/src/libs/Navigation/Navigation.js @@ -121,6 +121,7 @@ function navigate(route = ROUTES.HOME, type) { * @param {Boolean} shouldPopToTop - Should we navigate to LHN on back press */ function goBack(fallbackRoute, shouldEnforceFallback = false, shouldPopToTop = false) { + console.log('goBack', 1, navigationRef.current.state); if (!canNavigate('goBack')) { return; } @@ -132,14 +133,17 @@ function goBack(fallbackRoute, shouldEnforceFallback = false, shouldPopToTop = f return; } } + console.log('goBack', 2); if (!navigationRef.current.canGoBack()) { Log.hmmm('[Navigation] Unable to go back'); return; } + console.log('goBack', 3); const isFirstRouteInNavigator = !getActiveRouteIndex(navigationRef.current.getState()); if (isFirstRouteInNavigator) { + console.log('goBack', 4); const rootState = navigationRef.getRootState(); const lastRoute = _.last(rootState.routes); // If the user comes from a different flow (there is more than one route in RHP) we should go back to the previous flow on UP button press instead of using the fallbackRoute. @@ -148,18 +152,21 @@ function goBack(fallbackRoute, shouldEnforceFallback = false, shouldPopToTop = f return; } - if(lastRoute.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR) { - console.log('lastRoute', lastRoute); - navigationRef.current.goBack(); - return; - } + // if(lastRoute.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR) { + // console.log('lastRoute', lastRoute); + // navigationRef.current.goBack(); + // return; + // } } + console.log('goBack', 5); if (shouldEnforceFallback || (isFirstRouteInNavigator && fallbackRoute)) { navigate(fallbackRoute, CONST.NAVIGATION.TYPE.UP); return; } + console.log('goBack', 6); + const isCentralPaneFocused = findFocusedRoute(navigationRef.current.getState()).name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR; const distanceFromPathInRootNavigator = getDistanceFromPathInRootNavigator(fallbackRoute); @@ -169,6 +176,8 @@ function goBack(fallbackRoute, shouldEnforceFallback = false, shouldPopToTop = f return; } + console.log('goBack', 7); + // Add posibility to go back more than one screen in root navigator if that screen is on the stack. if (isCentralPaneFocused && fallbackRoute && distanceFromPathInRootNavigator > 0) { navigationRef.current.dispatch(StackActions.pop(distanceFromPathInRootNavigator)); @@ -176,6 +185,8 @@ function goBack(fallbackRoute, shouldEnforceFallback = false, shouldPopToTop = f } navigationRef.current.goBack(); + + console.log('goBack', 8); } /** diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 63f97f0fe6f8..8b745639147e 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -234,9 +234,6 @@ export default { }, SettingsCentralPane: { screens: { - [SCREENS.SETTINGS.ROOT]: { - path: ROUTES.SETTINGS, - }, [SCREENS.SETTINGS.WORKSPACES]: { path: ROUTES.SETTINGS_WORKSPACES, exact: true, @@ -309,7 +306,7 @@ export default { path: ROUTES.SETTINGS_ADD_BANK_ACCOUNT, exact: true, }, - Settings_Profile: { + [SCREENS.SETTINGS.PROFILE]: { path: ROUTES.SETTINGS_PROFILE, exact: true, }, diff --git a/src/pages/home/sidebar/PressableAvatarWithIndicator.js b/src/pages/home/sidebar/PressableAvatarWithIndicator.js index ddf89321b680..ec2f48cc6a91 100644 --- a/src/pages/home/sidebar/PressableAvatarWithIndicator.js +++ b/src/pages/home/sidebar/PressableAvatarWithIndicator.js @@ -46,7 +46,7 @@ function PressableAvatarWithIndicator({isCreateMenuOpen, currentUserPersonalDeta return; } - Navigation.navigate(ROUTES.SETTINGS); + Navigation.navigate(ROUTES.SETTINGS_HOME); }, [isCreateMenuOpen]); return ( diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index 628ca489fc70..caccb1438293 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -382,13 +382,18 @@ function InitialSettingsPage(props) { ); + const navigateBackTo = lodashGet(props.route, 'params.backTo', ROUTES.HOME); + return ( Navigation.goBack()} + onBackButtonPress={() => { + console.log('navigateBackTo', navigateBackTo); + Navigation.goBack(navigateBackTo) + }} > {getMenuItems} From 8703e12c99f6c7bb3dba18e242c65ad2bf9b49ec Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:38:07 +0100 Subject: [PATCH 012/600] fix closing settings --- src/pages/settings/InitialSettingsPage.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index caccb1438293..1ca111d205a0 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -390,10 +390,7 @@ function InitialSettingsPage(props) { headerContent={headerContent} headerContainerStyles={[styles.staticHeaderImage, styles.justifyContentCenter]} backgroundColor={theme.PAGE_BACKGROUND_COLORS[SCREENS.SETTINGS.ROOT]} - onBackButtonPress={() => { - console.log('navigateBackTo', navigateBackTo); - Navigation.goBack(navigateBackTo) - }} + onBackButtonPress={() => Navigation.navigate(navigateBackTo)} > {getMenuItems} From 248d664e47bd8c6234b7c63d868d2b9054903c27 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:41:10 +0100 Subject: [PATCH 013/600] revert --- src/pages/settings/Preferences/PreferencesPage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/settings/Preferences/PreferencesPage.js b/src/pages/settings/Preferences/PreferencesPage.js index 5c056385dd2d..0c02fe9772fb 100755 --- a/src/pages/settings/Preferences/PreferencesPage.js +++ b/src/pages/settings/Preferences/PreferencesPage.js @@ -45,7 +45,6 @@ function PreferencesPage(props) { return ( From a5ce5bfac7db7f8aca2c0d721f96b5cd8c13db74 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:57:55 +0100 Subject: [PATCH 014/600] fix deeplink --- .../CustomRouter.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js index 5ac04ab884a4..36faa6816c86 100644 --- a/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js +++ b/src/libs/Navigation/AppNavigator/createCustomStackNavigator/CustomRouter.js @@ -9,10 +9,7 @@ import SCREENS from '@src/SCREENS'; * @param {String} centralRoute - name of the central route * @returns {Boolean} */ -const isAtLeastOneCentralPaneNavigatorInState = (state, centralRoute) => { - console.log('isAtLeastOneCentralPaneNavigatorInState', centralRoute); - return _.find(state.routes, (r) => r.name === centralRoute) -}; +const isAtLeastOneCentralPaneNavigatorInState = (state, centralRoute) => _.find(state.routes, (r) => r.name === centralRoute); /** * @param {Object} state - react-navigation state @@ -48,9 +45,9 @@ const getTopMostReportIDFromRHP = (state) => { * @param {String} centralRoute - name of the central route */ const addCentralPaneNavigatorRoute = (state, centralRoute) => { - const reportID = getTopMostReportIDFromRHP(state); let centralPaneNavigatorRoute; if (centralRoute === NAVIGATORS.CENTRAL_PANE_NAVIGATOR) { + const reportID = getTopMostReportIDFromRHP(state); centralPaneNavigatorRoute = { name: NAVIGATORS.CENTRAL_PANE_NAVIGATOR, state: { @@ -81,6 +78,17 @@ const addCentralPaneNavigatorRoute = (state, centralRoute) => { state.index = state.routes.length - 1; }; +const addLHPRoute = (state, centralRoute) => { + const settingsHomeRoute = { + name: SCREENS.SETTINGS_HOME, + }; + if (state.routes[0].name !== SCREENS.SETTINGS_HOME && centralRoute === 'SettingsCentralPane') { + state.routes.splice(0, 0, settingsHomeRoute); + // eslint-disable-next-line no-param-reassign + state.index = state.routes.length - 1; + } +} + function CustomRouter(options) { const stackRouter = StackRouter(options); @@ -106,6 +114,7 @@ function CustomRouter(options) { partialState.stale = true; addCentralPaneNavigatorRoute(partialState, centralRoute); } + addLHPRoute(partialState, centralRoute); const state = stackRouter.getRehydratedState(partialState, {routeNames, routeParamList}); return state; }, From a30391373b3642f9316cc48124231de0952a3a5e Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Thu, 23 Nov 2023 10:11:31 +0100 Subject: [PATCH 015/600] add better linking --- src/libs/Navigation/linkingConfig.js | 364 +++++++++++++-------------- 1 file changed, 180 insertions(+), 184 deletions(-) diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 8b745639147e..a3ebd12838be 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -36,6 +36,178 @@ export default { [NAVIGATORS.RIGHT_MODAL_NAVIGATOR]: { screens: { + Settings: { + screens: { + Settings_Preferences_PriorityMode: { + path: ROUTES.SETTINGS_PRIORITY_MODE, + exact: true, + }, + Settings_Preferences_Language: { + path: ROUTES.SETTINGS_LANGUAGE, + exact: true, + }, + Settings_Preferences_Theme: { + path: ROUTES.SETTINGS_THEME, + exact: true, + }, + Settings_Close: { + path: ROUTES.SETTINGS_CLOSE, + exact: true, + }, + Settings_Wallet_DomainCards: { + path: ROUTES.SETTINGS_WALLET_DOMAINCARD.route, + exact: true, + }, + Settings_Wallet_ReportVirtualCardFraud: { + path: ROUTES.SETTINGS_REPORT_FRAUD.route, + exact: true, + }, + Settings_Wallet_EnablePayments: { + path: ROUTES.SETTINGS_ENABLE_PAYMENTS, + exact: true, + }, + Settings_Wallet_Transfer_Balance: { + path: ROUTES.SETTINGS_WALLET_TRANSFER_BALANCE, + exact: true, + }, + Settings_Wallet_Choose_Transfer_Account: { + path: ROUTES.SETTINGS_WALLET_CHOOSE_TRANSFER_ACCOUNT, + exact: true, + }, + Settings_ReportCardLostOrDamaged: { + path: ROUTES.SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED.route, + exact: true, + }, + Settings_Wallet_Card_Activate: { + path: ROUTES.SETTINGS_WALLET_CARD_ACTIVATE.route, + exact: true, + }, + Settings_Wallet_Cards_Digital_Details_Update_Address: { + path: ROUTES.SETTINGS_WALLET_CARD_DIGITAL_DETAILS_UPDATE_ADDRESS.route, + exact: true, + }, + Settings_Add_Debit_Card: { + path: ROUTES.SETTINGS_ADD_DEBIT_CARD, + exact: true, + }, + Settings_Add_Bank_Account: { + path: ROUTES.SETTINGS_ADD_BANK_ACCOUNT, + exact: true, + }, + Settings_Pronouns: { + path: ROUTES.SETTINGS_PRONOUNS, + exact: true, + }, + Settings_Display_Name: { + path: ROUTES.SETTINGS_DISPLAY_NAME, + exact: true, + }, + Settings_Timezone: { + path: ROUTES.SETTINGS_TIMEZONE, + exact: true, + }, + Settings_Timezone_Select: { + path: ROUTES.SETTINGS_TIMEZONE_SELECT, + exact: true, + }, + Settings_App_Download_Links: { + path: ROUTES.SETTINGS_APP_DOWNLOAD_LINKS, + exact: true, + }, + Settings_ContactMethods: { + path: ROUTES.SETTINGS_CONTACT_METHODS.route, + exact: true, + }, + Settings_ContactMethodDetails: { + path: ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.route, + }, + Settings_Lounge_Access: { + path: ROUTES.SETTINGS_LOUNGE_ACCESS, + }, + Settings_NewContactMethod: { + path: ROUTES.SETTINGS_NEW_CONTACT_METHOD, + exact: true, + }, + Settings_PersonalDetails_Initial: { + path: ROUTES.SETTINGS_PERSONAL_DETAILS, + exact: true, + }, + Settings_PersonalDetails_LegalName: { + path: ROUTES.SETTINGS_PERSONAL_DETAILS_LEGAL_NAME, + exact: true, + }, + Settings_PersonalDetails_DateOfBirth: { + path: ROUTES.SETTINGS_PERSONAL_DETAILS_DATE_OF_BIRTH, + exact: true, + }, + Settings_PersonalDetails_Address: { + path: ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS, + exact: true, + }, + Settings_PersonalDetails_Address_Country: { + path: ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS_COUNTRY.route, + exact: true, + }, + Settings_TwoFactorAuth: { + path: ROUTES.SETTINGS_2FA, + exact: true, + }, + [SCREENS.SETTINGS.STATUS]: { + path: ROUTES.SETTINGS_STATUS, + exact: true, + }, + Settings_Status_Set: { + path: ROUTES.SETTINGS_STATUS_SET, + exact: true, + }, + Workspace_Initial: { + path: ROUTES.WORKSPACE_INITIAL.route, + }, + Workspace_Settings: { + path: ROUTES.WORKSPACE_SETTINGS.route, + }, + Workspace_Settings_Currency: { + path: ROUTES.WORKSPACE_SETTINGS_CURRENCY.route, + }, + Workspace_Card: { + path: ROUTES.WORKSPACE_CARD.route, + }, + Workspace_Reimburse: { + path: ROUTES.WORKSPACE_REIMBURSE.route, + }, + Workspace_RateAndUnit: { + path: ROUTES.WORKSPACE_RATE_AND_UNIT.route, + }, + Workspace_Bills: { + path: ROUTES.WORKSPACE_BILLS.route, + }, + Workspace_Invoices: { + path: ROUTES.WORKSPACE_INVOICES.route, + }, + Workspace_Travel: { + path: ROUTES.WORKSPACE_TRAVEL.route, + }, + Workspace_Members: { + path: ROUTES.WORKSPACE_MEMBERS.route, + }, + Workspace_Invite: { + path: ROUTES.WORKSPACE_INVITE.route, + }, + Workspace_Invite_Message: { + path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, + }, + ReimbursementAccount: { + path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.route, + exact: true, + }, + GetAssistance: { + path: ROUTES.GET_ASSISTANCE.route, + }, + KeyboardShortcuts: { + path: ROUTES.KEYBOARD_SHORTCUTS, + }, + } + }, Private_Notes: { screens: { PrivateNotes_View: ROUTES.PRIVATE_NOTES_VIEW.route, @@ -234,28 +406,20 @@ export default { }, SettingsCentralPane: { screens: { - [SCREENS.SETTINGS.WORKSPACES]: { - path: ROUTES.SETTINGS_WORKSPACES, - exact: true, - }, - [SCREENS.SETTINGS.PREFERENCES]: { - path: ROUTES.SETTINGS_PREFERENCES, - exact: true, - }, - Settings_Preferences_PriorityMode: { - path: ROUTES.SETTINGS_PRIORITY_MODE, + Settings_Share_Code: { + path: ROUTES.SETTINGS_SHARE_CODE, exact: true, }, - Settings_Preferences_Language: { - path: ROUTES.SETTINGS_LANGUAGE, + [SCREENS.SETTINGS.WORKSPACES]: { + path: ROUTES.SETTINGS_WORKSPACES, exact: true, }, - Settings_Preferences_Theme: { - path: ROUTES.SETTINGS_THEME, + [SCREENS.SETTINGS.PROFILE]: { + path: ROUTES.SETTINGS_PROFILE, exact: true, }, - Settings_Close: { - path: ROUTES.SETTINGS_CLOSE, + [SCREENS.SETTINGS.PREFERENCES]: { + path: ROUTES.SETTINGS_PREFERENCES, exact: true, }, [SCREENS.SETTINGS.SECURITY]: { @@ -266,180 +430,12 @@ export default { path: ROUTES.SETTINGS_WALLET, exact: true, }, - Settings_Wallet_DomainCards: { - path: ROUTES.SETTINGS_WALLET_DOMAINCARD.route, - exact: true, - }, - Settings_Wallet_ReportVirtualCardFraud: { - path: ROUTES.SETTINGS_REPORT_FRAUD.route, - exact: true, - }, - Settings_Wallet_EnablePayments: { - path: ROUTES.SETTINGS_ENABLE_PAYMENTS, - exact: true, - }, - Settings_Wallet_Transfer_Balance: { - path: ROUTES.SETTINGS_WALLET_TRANSFER_BALANCE, - exact: true, - }, - Settings_Wallet_Choose_Transfer_Account: { - path: ROUTES.SETTINGS_WALLET_CHOOSE_TRANSFER_ACCOUNT, - exact: true, - }, - Settings_ReportCardLostOrDamaged: { - path: ROUTES.SETTINGS_WALLET_REPORT_CARD_LOST_OR_DAMAGED.route, - exact: true, - }, - Settings_Wallet_Card_Activate: { - path: ROUTES.SETTINGS_WALLET_CARD_ACTIVATE.route, - exact: true, - }, - Settings_Wallet_Cards_Digital_Details_Update_Address: { - path: ROUTES.SETTINGS_WALLET_CARD_DIGITAL_DETAILS_UPDATE_ADDRESS.route, - exact: true, - }, - Settings_Add_Debit_Card: { - path: ROUTES.SETTINGS_ADD_DEBIT_CARD, - exact: true, - }, - Settings_Add_Bank_Account: { - path: ROUTES.SETTINGS_ADD_BANK_ACCOUNT, - exact: true, - }, - [SCREENS.SETTINGS.PROFILE]: { - path: ROUTES.SETTINGS_PROFILE, - exact: true, - }, - Settings_Pronouns: { - path: ROUTES.SETTINGS_PRONOUNS, - exact: true, - }, - Settings_Display_Name: { - path: ROUTES.SETTINGS_DISPLAY_NAME, - exact: true, - }, - Settings_Timezone: { - path: ROUTES.SETTINGS_TIMEZONE, - exact: true, - }, - Settings_Timezone_Select: { - path: ROUTES.SETTINGS_TIMEZONE_SELECT, - exact: true, - }, Settings_About: { path: ROUTES.SETTINGS_ABOUT, exact: true, }, - Settings_App_Download_Links: { - path: ROUTES.SETTINGS_APP_DOWNLOAD_LINKS, - exact: true, - }, - Settings_ContactMethods: { - path: ROUTES.SETTINGS_CONTACT_METHODS.route, - exact: true, - }, - Settings_ContactMethodDetails: { - path: ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.route, - }, - Settings_Lounge_Access: { - path: ROUTES.SETTINGS_LOUNGE_ACCESS, - }, - Settings_NewContactMethod: { - path: ROUTES.SETTINGS_NEW_CONTACT_METHOD, - exact: true, - }, - Settings_PersonalDetails_Initial: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS, - exact: true, - }, - Settings_PersonalDetails_LegalName: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS_LEGAL_NAME, - exact: true, - }, - Settings_PersonalDetails_DateOfBirth: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS_DATE_OF_BIRTH, - exact: true, - }, - Settings_PersonalDetails_Address: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS, - exact: true, - }, - Settings_PersonalDetails_Address_Country: { - path: ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS_COUNTRY.route, - exact: true, - }, - Settings_TwoFactorAuth: { - path: ROUTES.SETTINGS_2FA, - exact: true, - }, - Settings_Share_Code: { - path: ROUTES.SETTINGS_SHARE_CODE, - exact: true, - }, - [SCREENS.SETTINGS.STATUS]: { - path: ROUTES.SETTINGS_STATUS, - exact: true, - }, - Settings_Status_Set: { - path: ROUTES.SETTINGS_STATUS_SET, - exact: true, - }, - Workspace_Initial: { - path: ROUTES.WORKSPACE_INITIAL.route, - }, - Workspace_Settings: { - path: ROUTES.WORKSPACE_SETTINGS.route, - }, - Workspace_Settings_Currency: { - path: ROUTES.WORKSPACE_SETTINGS_CURRENCY.route, - }, - Workspace_Card: { - path: ROUTES.WORKSPACE_CARD.route, - }, - Workspace_Reimburse: { - path: ROUTES.WORKSPACE_REIMBURSE.route, - }, - Workspace_RateAndUnit: { - path: ROUTES.WORKSPACE_RATE_AND_UNIT.route, - }, - Workspace_Bills: { - path: ROUTES.WORKSPACE_BILLS.route, - }, - Workspace_Invoices: { - path: ROUTES.WORKSPACE_INVOICES.route, - }, - Workspace_Travel: { - path: ROUTES.WORKSPACE_TRAVEL.route, - }, - Workspace_Members: { - path: ROUTES.WORKSPACE_MEMBERS.route, - }, - Workspace_Invite: { - path: ROUTES.WORKSPACE_INVITE.route, - }, - Workspace_Invite_Message: { - path: ROUTES.WORKSPACE_INVITE_MESSAGE.route, - }, - ReimbursementAccount: { - path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.route, - exact: true, - }, - GetAssistance: { - path: ROUTES.GET_ASSISTANCE.route, - }, - KeyboardShortcuts: { - path: ROUTES.KEYBOARD_SHORTCUTS, - }, }, }, - // Settings: { - // screens: { - // [SCREENS.SETTINGS_NEW_PROFILE]: { - // path: ROUTES.SETTINGS_NEW_PROFILE, - // exact: true, - // }, - // } - // } }, } }, From f24f917933ccbda3a92e95bd0508932f62684f88 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Thu, 23 Nov 2023 10:30:07 +0100 Subject: [PATCH 016/600] general refactor --- src/components/HeaderWithBackButton/index.js | 7 +++++-- src/pages/ShareCodePage.js | 1 + src/pages/settings/AboutPage/AboutPage.js | 1 + src/pages/settings/Preferences/PreferencesPage.js | 1 + src/pages/settings/Profile/LoungeAccessPage.js | 2 +- src/pages/settings/Profile/ProfilePage.js | 1 + src/pages/settings/Security/SecuritySettingsPage.js | 1 + src/pages/settings/Wallet/WalletPage/WalletPage.js | 1 + src/pages/workspace/WorkspacesListPage.js | 1 + 9 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/HeaderWithBackButton/index.js b/src/components/HeaderWithBackButton/index.js index edb3b8d26831..528ddb3ad310 100755 --- a/src/components/HeaderWithBackButton/index.js +++ b/src/components/HeaderWithBackButton/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import {Keyboard, View} from 'react-native'; +import { Keyboard, View } from 'react-native'; import AvatarWithDisplayName from '@components/AvatarWithDisplayName'; import Header from '@components/Header'; import Icon from '@components/Icon'; @@ -18,6 +18,7 @@ import * as StyleUtils from '@styles/StyleUtils'; import useThemeStyles from '@styles/useThemeStyles'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; +import useWindowDimensions from '@hooks/useWindowDimensions'; import headerWithBackButtonPropTypes from './headerWithBackButtonPropTypes'; function HeaderWithBackButton({ @@ -40,6 +41,7 @@ function HeaderWithBackButton({ shouldShowPinButton = false, shouldShowThreeDotsButton = false, shouldDisableThreeDotsButton = false, + shouldShowBackButtonOnlyOnMobile = false, stepCounter = null, subtitle = '', title = '', @@ -59,6 +61,7 @@ function HeaderWithBackButton({ const {translate} = useLocalize(); const {isKeyboardShown} = useKeyboardState(); const waitForNavigate = useWaitForNavigation(); + const {isSmallScreenWidth} = useWindowDimensions(); return ( - {shouldShowBackButton && ( + {shouldShowBackButton && (!shouldShowBackButtonOnlyOnMobile || isSmallScreenWidth) && ( { diff --git a/src/pages/ShareCodePage.js b/src/pages/ShareCodePage.js index d8322b8c58d5..05a3578557f4 100644 --- a/src/pages/ShareCodePage.js +++ b/src/pages/ShareCodePage.js @@ -82,6 +82,7 @@ class ShareCodePage extends React.Component { Navigation.goBack(isReport ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(this.props.report.reportID) : ROUTES.SETTINGS)} + shouldShowBackButtonOnlyOnMobile /> diff --git a/src/pages/settings/AboutPage/AboutPage.js b/src/pages/settings/AboutPage/AboutPage.js index a88a07117f08..59adb9a7befc 100644 --- a/src/pages/settings/AboutPage/AboutPage.js +++ b/src/pages/settings/AboutPage/AboutPage.js @@ -104,6 +104,7 @@ function AboutPage(props) { Navigation.goBack(ROUTES.SETTINGS)} + shouldShowBackButtonOnlyOnMobile /> diff --git a/src/pages/settings/Preferences/PreferencesPage.js b/src/pages/settings/Preferences/PreferencesPage.js index 0c02fe9772fb..cf2aee9d930d 100755 --- a/src/pages/settings/Preferences/PreferencesPage.js +++ b/src/pages/settings/Preferences/PreferencesPage.js @@ -47,6 +47,7 @@ function PreferencesPage(props) { title={translate('common.preferences')} backgroundColor={theme.PAGE_BACKGROUND_COLORS[SCREENS.SETTINGS.PREFERENCES]} illustration={LottieAnimations.PreferencesDJ} + shouldShowBackButtonOnlyOnMobile > Navigation.goBack(ROUTES.SETTINGS)} + onBackButtonPress={() => Navigation.goBack(ROUTES)} illustration={LottieAnimations.ExpensifyLounge} > Navigation.goBack(ROUTES.SETTINGS)} + shouldShowBackButtonOnlyOnMobile /> diff --git a/src/pages/settings/Wallet/WalletPage/WalletPage.js b/src/pages/settings/Wallet/WalletPage/WalletPage.js index 23d4112eea21..2a6ae9dc7105 100644 --- a/src/pages/settings/Wallet/WalletPage/WalletPage.js +++ b/src/pages/settings/Wallet/WalletPage/WalletPage.js @@ -326,6 +326,7 @@ function WalletPage({bankAccountList, betas, cardList, fundList, isLoadingPaymen Navigation.goBack(ROUTES.SETTINGS)} + shouldShowBackButtonOnlyOnMobile /> diff --git a/src/pages/workspace/WorkspacesListPage.js b/src/pages/workspace/WorkspacesListPage.js index dc0c6d8b3043..dbb73d9dd300 100755 --- a/src/pages/workspace/WorkspacesListPage.js +++ b/src/pages/workspace/WorkspacesListPage.js @@ -189,6 +189,7 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, u illustration={LottieAnimations.WorkspacePlanet} onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} title={translate('common.workspaces')} + shouldShowBackButtonOnlyOnMobile footer={