diff --git a/ios/Podfile.lock b/ios/Podfile.lock index f0d6720080e8..d62469e46b86 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1019,7 +1019,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Airship: c70eed50e429f97f5adb285423c7291fb7a032ae AirshipFrameworkProxy: 2eefb77bb77b5120b0f48814b0d44439aa3ad415 - boost: 57d2868c099736d80fcd648bf211b4431e51a558 + boost: a7c83b31436843459a1961bfd74b96033dc77234 CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: ff54429f0110d3c722630a98096ba689c39f6d5f @@ -1062,7 +1062,7 @@ SPEC CHECKSUMS: Permission-LocationWhenInUse: 3ba99e45c852763f730eabecec2870c2382b7bd4 Plaid: 7d340abeadb46c7aa1a91f896c5b22395a31fcf2 PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef - RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 + RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda RCTRequired: e9e7b8b45aa9bedb2fdad71740adf07a7265b9be RCTTypeSafety: 9ae0e9206625e995f0df4d5b9ddc94411929fb30 React: a71c8e1380f07e01de721ccd52bcf9c03e81867d @@ -1135,4 +1135,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 5feaab251246f42f41e69c8a28fa331b4899e814 -COCOAPODS: 1.12.0 +COCOAPODS: 1.11.3 diff --git a/patches/@react-navigation+stack+6.3.16.patch b/patches/@react-navigation+stack+6.3.16.patch new file mode 100644 index 000000000000..921f09491927 --- /dev/null +++ b/patches/@react-navigation+stack+6.3.16.patch @@ -0,0 +1,91 @@ +diff --git a/node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx b/node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx +index 1e9ee0e..d85c7b4 100644 +--- a/node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx ++++ b/node_modules/@react-navigation/stack/src/views/Stack/CardContainer.tsx +@@ -105,14 +105,14 @@ function CardContainer({ + const handleOpen = () => { + const { route } = scene.descriptor; + +- onTransitionEnd({ route }, false); ++ onTransitionEnd({ route }, false, scene.descriptor.navigation.getState()); + onOpenRoute({ route }); + }; + + const handleClose = () => { + const { route } = scene.descriptor; + +- onTransitionEnd({ route }, true); ++ onTransitionEnd({ route }, true, scene.descriptor.navigation.getState()); + onCloseRoute({ route }); + }; + +@@ -120,7 +120,7 @@ function CardContainer({ + const { route } = scene.descriptor; + + onPageChangeStart(); +- onGestureStart({ route }); ++ onGestureStart({ route }, scene.descriptor.navigation.getState()); + }; + + const handleGestureCanceled = () => { +diff --git a/node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx b/node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx +index 6bbce10..7f2eed3 100644 +--- a/node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx ++++ b/node_modules/@react-navigation/stack/src/views/Stack/StackView.tsx +@@ -375,29 +375,51 @@ export default class StackView extends React.Component { + + private handleTransitionStart = ( + { route }: { route: Route }, +- closing: boolean +- ) => ++ closing: boolean, ++ ) => { + this.props.navigation.emit({ + type: 'transitionStart', + data: { closing }, + target: route.key, + }); ++ } + + private handleTransitionEnd = ( + { route }: { route: Route }, +- closing: boolean +- ) => ++ closing: boolean, ++ state: StackNavigationState ++ ) => { + this.props.navigation.emit({ + type: 'transitionEnd', + data: { closing }, + target: route.key, + }); ++ // Patch introduced to pass information about events to screens lower in the stack, so they could be safely frozen ++ if (state?.index > 1) { ++ this.props.navigation.emit({ ++ type: 'transitionEnd', ++ data: { closing: !closing }, ++ target: state.routes[state.index - 2].key, ++ }); ++ } ++ } + +- private handleGestureStart = ({ route }: { route: Route }) => { ++ private handleGestureStart = ( ++ { route }: { route: Route }, ++ state: StackNavigationState ++ ) => { ++ console.log(state) + this.props.navigation.emit({ + type: 'gestureStart', + target: route.key, + }); ++ // Patch introduced to pass information about events to screens lower in the stack, so they could be safely frozen ++ if (state?.index > 1) { ++ this.props.navigation.emit({ ++ type: 'gestureStart', ++ target: state.routes[state.index - 2].key, ++ }); ++ } + }; + + private handleGestureEnd = ({ route }: { route: Route }) => { diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index ea5f5baa1558..9d7b6beaae3d 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -16,7 +16,7 @@ import themeColors from '../styles/themes/default'; import compose from '../libs/compose'; import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimensions'; import Button from './Button'; -import HeaderWithCloseButton from './HeaderWithCloseButton'; +import HeaderWithBackButton from './HeaderWithBackButton'; import fileDownload from '../libs/fileDownload'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; import ConfirmModal from './ConfirmModal'; @@ -270,11 +270,14 @@ class AttachmentModal extends PureComponent { propagateSwipe > {this.props.isSmallScreenWidth && } - this.downloadAttachment(source)} + shouldShowCloseButton={!this.props.isSmallScreenWidth} + shouldShowBackButton={this.props.isSmallScreenWidth} + onBackButtonPress={() => this.setState({isModalOpen: false})} onCloseButtonPress={() => this.setState({isModalOpen: false})} /> diff --git a/src/components/AvatarCropModal/AvatarCropModal.js b/src/components/AvatarCropModal/AvatarCropModal.js index 7f5104e22130..99da80593768 100644 --- a/src/components/AvatarCropModal/AvatarCropModal.js +++ b/src/components/AvatarCropModal/AvatarCropModal.js @@ -8,7 +8,7 @@ import compose from '../../libs/compose'; import styles from '../../styles/styles'; import themeColors from '../../styles/themes/default'; import Button from '../Button'; -import HeaderWithCloseButton from '../HeaderWithCloseButton'; +import HeaderWithBackButton from '../HeaderWithBackButton'; import Icon from '../Icon'; import * as Expensicons from '../Icon/Expensicons'; import Modal from '../Modal'; @@ -361,9 +361,9 @@ const AvatarCropModal = (props) => { onModalHide={resetState} > {props.isSmallScreenWidth && } - {props.translate('avatarCropModal.description')} ( {props.subtitle} {props.shouldShowBackHomeLink ? ( Navigation.dismissModal(true)} + onPress={Navigation.goBack} style={[styles.link, styles.mt2]} > {props.link} diff --git a/src/components/BlockingViews/FullPageNotFoundView.js b/src/components/BlockingViews/FullPageNotFoundView.js index 9a6e4ebd3ee3..cf2b4f1d4280 100644 --- a/src/components/BlockingViews/FullPageNotFoundView.js +++ b/src/components/BlockingViews/FullPageNotFoundView.js @@ -4,7 +4,7 @@ import {View} from 'react-native'; import BlockingView from './BlockingView'; import * as Illustrations from '../Icon/Illustrations'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; -import HeaderWithCloseButton from '../HeaderWithCloseButton'; +import HeaderWithBackButton from '../HeaderWithBackButton'; import Navigation from '../../libs/Navigation/Navigation'; import variables from '../../styles/variables'; import styles from '../../styles/styles'; @@ -25,12 +25,6 @@ const propTypes = { /** The key in the translations file to use for the subtitle */ subtitleKey: PropTypes.string, - /** Whether we should show a back icon */ - shouldShowBackButton: PropTypes.bool, - - /** Whether we should show a close button */ - shouldShowCloseButton: PropTypes.bool, - /** Whether we should show a go back home link */ shouldShowBackHomeLink: PropTypes.bool, @@ -47,10 +41,8 @@ const defaultProps = { titleKey: 'notFound.notHere', subtitleKey: 'notFound.pageNotFound', linkKey: 'notFound.goBackHome', - shouldShowBackButton: true, shouldShowBackHomeLink: false, - shouldShowCloseButton: true, - onBackButtonPress: () => Navigation.dismissModal(), + onBackButtonPress: Navigation.goBack, }; // eslint-disable-next-line rulesdir/no-negated-variables @@ -58,12 +50,7 @@ const FullPageNotFoundView = (props) => { if (props.shouldShow) { return ( <> - Navigation.dismissModal()} - /> + { - props.onScroll(event); - - // The last onScroll event happens after freezing the FlatList and it's called with offset: 0. - // Don't save this value because it's incorrect. - if (!isHidden.current) { - contentOffsetRef.current = event.nativeEvent.contentOffset; + const onScreenFocus = useCallback(() => { + if (!props.innerRef.current || !scrollPosition.offset) { + return; } - }; - const handleOnLayout = (event) => { - props.onLayout(event); - - if (event.nativeEvent.layout.height === 0) { - // If the layout height is equal to 0, we can assume that this flatList is frozen. - isHidden.current = true; - - // The maintainVisibleContentPosition prop causes glitches with animations and scrollToOffset. - // Use ready state to decide if this prop should be undefined to avoid glitching. - setReady(false); - } else { - isHidden.current = false; - if (props.innerRef.current && contentOffsetRef.current) { - props.innerRef.current.scrollToOffset({offset: contentOffsetRef.current.y, animated: false}); - setReady(true); - } + if (props.innerRef.current && scrollPosition.offset) { + props.innerRef.current.scrollToOffset({offset: scrollPosition.offset, animated: false}); } - }; + }, [scrollPosition.offset, props.innerRef]); + + useFocusEffect( + useCallback(() => { + onScreenFocus(); + }, [onScreenFocus]), + ); return ( props.onScroll(event)} + onMomentumScrollEnd={(event) => { + setScrollPosition({offset: event.nativeEvent.contentOffset.y}); + }} ref={props.innerRef} - onScroll={handleOnScroll} - onLayout={handleOnLayout} - maintainVisibleContentPosition={ready ? props.maintainVisibleContentPosition : undefined} /> ); } @@ -78,9 +65,9 @@ function CustomFlatList(props) { CustomFlatList.propTypes = propTypes; CustomFlatList.defaultProps = defaultProps; -// eslint-disable-next-line react/jsx-props-no-spreading export default forwardRef((props, ref) => ( diff --git a/src/components/HeaderWithCloseButton.js b/src/components/HeaderWithBackButton.js similarity index 96% rename from src/components/HeaderWithCloseButton.js rename to src/components/HeaderWithBackButton.js index e1c87c0c4728..949999e51708 100755 --- a/src/components/HeaderWithCloseButton.js +++ b/src/components/HeaderWithBackButton.js @@ -38,9 +38,6 @@ const propTypes = { /** Method to trigger when pressing more options button of the header */ onThreeDotsButtonPress: PropTypes.func, - /** Whether we should show a back icon */ - shouldShowBackButton: PropTypes.bool, - /** Whether we should show a border on the bottom of the Header */ shouldShowBorderBottom: PropTypes.bool, @@ -67,6 +64,9 @@ const propTypes = { /** Whether we should show a close button */ shouldShowCloseButton: PropTypes.bool, + /** Whether we should show a back button */ + shouldShowBackButton: PropTypes.bool, + /** Whether we should show the step counter */ shouldShowStepCounter: PropTypes.bool, @@ -103,16 +103,16 @@ const defaultProps = { title: '', subtitle: '', onDownloadButtonPress: () => {}, - onCloseButtonPress: () => {}, - onBackButtonPress: () => {}, + onBackButtonPress: Navigation.goBack, + onCloseButtonPress: Navigation.dismissModal, onThreeDotsButtonPress: () => {}, - shouldShowBackButton: false, shouldShowBorderBottom: false, shouldShowDownloadButton: false, shouldShowGetAssistanceButton: false, shouldShowThreeDotsButton: false, - shouldShowCloseButton: true, shouldShowStepCounter: true, + shouldShowCloseButton: false, + shouldShowBackButton: true, shouldShowAvatarWithDisplay: false, report: null, policies: {}, @@ -126,7 +126,7 @@ const defaultProps = { }, }; -class HeaderWithCloseButton extends Component { +class HeaderWithBackButton extends Component { constructor(props) { super(props); @@ -238,7 +238,7 @@ class HeaderWithCloseButton extends Component { } } -HeaderWithCloseButton.propTypes = propTypes; -HeaderWithCloseButton.defaultProps = defaultProps; +HeaderWithBackButton.propTypes = propTypes; +HeaderWithBackButton.defaultProps = defaultProps; -export default compose(withLocalize, withDelayToggleButtonState, withKeyboardState)(HeaderWithCloseButton); +export default compose(withLocalize, withDelayToggleButtonState, withKeyboardState)(HeaderWithBackButton); diff --git a/src/components/KeyboardShortcutsModal.js b/src/components/KeyboardShortcutsModal.js index b1a2dab61664..282007fb3d77 100644 --- a/src/components/KeyboardShortcutsModal.js +++ b/src/components/KeyboardShortcutsModal.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import {View, ScrollView} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import HeaderWithCloseButton from './HeaderWithCloseButton'; +import HeaderWithBackButton from './HeaderWithBackButton'; import Text from './Text'; import Modal from './Modal'; import CONST from '../CONST'; @@ -159,8 +159,10 @@ class KeyboardShortcutsModal extends React.Component { innerContainerStyle={{...styles.keyboardShortcutModalContainer, ...StyleUtils.getKeyboardShortcutsModalWidth(this.props.isSmallScreenWidth)}} onClose={KeyboardShortcutsActions.hideKeyboardShortcutModal} > - diff --git a/src/components/MoneyRequestHeader.js b/src/components/MoneyRequestHeader.js index ac7908677d68..6d255da21129 100644 --- a/src/components/MoneyRequestHeader.js +++ b/src/components/MoneyRequestHeader.js @@ -2,7 +2,7 @@ import React from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; -import HeaderWithCloseButton from './HeaderWithCloseButton'; +import HeaderWithBackButton from './HeaderWithBackButton'; import iouReportPropTypes from '../pages/iouReportPropTypes'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; import * as ReportUtils from '../libs/ReportUtils'; @@ -53,7 +53,7 @@ const MoneyRequestHeader = (props) => { : ReportUtils.getAvatar(lodashGet(props.personalDetails, [props.report.managerEmail, 'avatar']), props.report.managerEmail); return ( - { report={props.report} policies={props.policies} personalDetails={props.personalDetails} - shouldShowCloseButton={false} shouldShowBackButton={props.isSmallScreenWidth} - onBackButtonPress={() => Navigation.navigate(ROUTES.HOME)} + onBackButtonPress={() => Navigation.goBack(ROUTES.HOME)} /> {props.translate('common.to')} diff --git a/src/components/Pressable/PressableWithFeedback.js b/src/components/Pressable/PressableWithFeedback.js index 0f4c07c63f64..9e475b7169cf 100644 --- a/src/components/Pressable/PressableWithFeedback.js +++ b/src/components/Pressable/PressableWithFeedback.js @@ -46,10 +46,9 @@ const PressableWithFeedback = forwardRef((props, ref) => { setDisabled(props.disabled); return; } - onPress - .finally(() => { - setDisabled(props.disabled); - }); + onPress.finally(() => { + setDisabled(props.disabled); + }); }); }} > diff --git a/src/components/ReimbursementAccountLoadingIndicator.js b/src/components/ReimbursementAccountLoadingIndicator.js index e7876d18ad53..a110d3c747ba 100644 --- a/src/components/ReimbursementAccountLoadingIndicator.js +++ b/src/components/ReimbursementAccountLoadingIndicator.js @@ -6,8 +6,7 @@ import ReviewingBankInfoAnimation from '../../assets/animations/ReviewingBankInf import styles from '../styles/styles'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; import Text from './Text'; -import HeaderWithCloseButton from './HeaderWithCloseButton'; -import Navigation from '../libs/Navigation/Navigation'; +import HeaderWithBackButton from './HeaderWithBackButton'; import ScreenWrapper from './ScreenWrapper'; import FullScreenLoadingIndicator from './FullscreenLoadingIndicator'; import FullPageOfflineBlockingView from './BlockingViews/FullPageOfflineBlockingView'; @@ -25,10 +24,8 @@ const propTypes = { const ReimbursementAccountLoadingIndicator = (props) => ( - diff --git a/src/components/withCurrentReportId.js b/src/components/withCurrentReportId.js index ef87993060ed..8898ad45019f 100644 --- a/src/components/withCurrentReportId.js +++ b/src/components/withCurrentReportId.js @@ -49,10 +49,11 @@ CurrentReportIdContextProvider.propTypes = withCurrentReportIdPropTypes; export default function withCurrentReportId(WrappedComponent) { const WithCurrentReportId = forwardRef((props, ref) => ( - {/* eslint-disable-next-line react/jsx-props-no-spreading */} {(translateUtils) => ( diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 3de8f6032013..abb125dc6a9e 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -4,7 +4,6 @@ import PropTypes from 'prop-types'; import moment from 'moment'; import _ from 'underscore'; import lodashGet from 'lodash/get'; -import Str from 'expensify-common/lib/str'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; import CONST from '../../../CONST'; import compose from '../../compose'; @@ -178,6 +177,7 @@ class AuthScreens extends React.Component { animationEnabled: true, cardStyleInterpolator: (props) => modalCardStyleInterpolator(this.props.isSmallScreenWidth, false, props), cardOverlayEnabled: true, + animationTypeForReplace: 'pop', }; const rightModalNavigatorScreenOptions = { diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js index 7b33335fb86d..2340753d6578 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js @@ -598,6 +598,13 @@ const SettingsModalStackNavigator = createModalStackNavigator([ }, name: 'GetAssistance', }, + { + getComponent: () => { + const YearPickerPage = require('../../../pages/YearPickerPage').default; + return YearPickerPage; + }, + name: 'YearPicker_Root', + }, ]); const EnablePaymentsStackNavigator = createModalStackNavigator([ @@ -640,16 +647,6 @@ const WalletStatementStackNavigator = createModalStackNavigator([ }, ]); -const YearPickerStackNavigator = createModalStackNavigator([ - { - getComponent: () => { - const YearPickerPage = require('../../../pages/YearPickerPage').default; - return YearPickerPage; - }, - name: 'YearPicker_Root', - }, -]); - export { IOUBillStackNavigator, IOURequestModalStackNavigator, @@ -669,5 +666,4 @@ export { AddPersonalBankAccountModalStackNavigator, ReimbursementAccountModalStackNavigator, WalletStatementStackNavigator, - YearPickerStackNavigator, }; diff --git a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator.js index e86d66115304..83edd723b16b 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigator.js @@ -1,5 +1,7 @@ -import React from 'react'; +import React, {useEffect, useState} from 'react'; import {createStackNavigator} from '@react-navigation/stack'; +import {useIsFocused, useNavigation} from '@react-navigation/native'; +import {Freeze} from 'react-freeze'; import SCREENS from '../../../../SCREENS'; import ReportScreenWrapper from '../ReportScreenWrapper'; @@ -12,22 +14,47 @@ const url = getCurrentUrl(); const openOnAdminRoom = url ? new URL(url).searchParams.get('openOnAdminRoom') : undefined; function CentralPaneNavigator() { + const [isScreenBlurred, setIsScreenBlurred] = useState(false); + const [screenIndex, setScreenIndex] = useState(null); + const isFocused = useIsFocused(); + const navigation = useNavigation(); + + useEffect(() => { + if (screenIndex !== null) { + return; + } + setScreenIndex(navigation.getState().index); + }, [navigation, screenIndex]); + + useEffect(() => { + const unsubscribe = navigation.addListener('state', () => { + if (navigation.getState().index - screenIndex > 2) { + setIsScreenBlurred(true); + } else { + setIsScreenBlurred(false); + } + }); + return () => unsubscribe(); + }, [isFocused, isScreenBlurred, navigation, screenIndex]); + return ( - - - + + + + + ); } diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js index 8946b4737286..a3b3ee3f9231 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.js @@ -84,11 +84,6 @@ function RigthModalNavigator() { options={defaultModalScreenOptions} component={ModalStackNavigators.WalletStatementStackNavigator} /> - originalGetTopmostReportId(state); /** - * @private - * @param {Boolean} shouldOpenDrawer + * Method for finding on which index in stack we are. + * @param {Object} route + * @param {Number} index + * @returns {Number} */ -function goBack() { - if (!canNavigate('goBack')) { - return; +const getActiveRouteIndex = function (route, index) { + if (route.routes) { + const childActiveRoute = route.routes[route.index || 0]; + return getActiveRouteIndex(childActiveRoute, route.index || 0); } - if (!navigationRef.current.canGoBack()) { - Log.hmmm('[Navigation] Unable to go back'); - return; + if (route.state && route.state.routes) { + const childActiveRoute = route.state.routes[route.state.index || 0]; + return getActiveRouteIndex(childActiveRoute, route.state.index || 0); } - navigationRef.current.goBack(); -} + + if (route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { + return 0; + } + + return index; +}; /** * Main navigation method for redirecting to a route. * @param {String} route + * @param {String} type - Type of action to perform. Currently UP is supported. */ -function navigate(route = ROUTES.HOME) { +function navigate(route = ROUTES.HOME, type) { if (!canNavigate('navigate', {route})) { // Store intended route if the navigator is not yet available, // we will try again after the NavigationContainer is ready @@ -73,7 +82,29 @@ function navigate(route = ROUTES.HOME) { // More info: https://github.com/Expensify/App/issues/13146 DomUtils.blurActiveElement(); - linkTo(navigationRef.current, route); + linkTo(navigationRef.current, route, type); +} + +/** + * @param {String} fallbackRoute - Fallback route if pop/goBack action should, but is not possible within RHP + * @param {Bool} shouldEnforceFallback - Enforces navigation to fallback route + */ +function goBack(fallbackRoute = ROUTES.HOME, shouldEnforceFallback = false) { + if (!canNavigate('goBack')) { + return; + } + + if (!navigationRef.current.canGoBack()) { + Log.hmmm('[Navigation] Unable to go back'); + return; + } + + if (shouldEnforceFallback || (!getActiveRouteIndex(navigationRef.current.getState()) && fallbackRoute)) { + navigate(fallbackRoute, 'UP'); + return; + } + + navigationRef.current.goBack(); } /** diff --git a/src/libs/Navigation/linkTo.js b/src/libs/Navigation/linkTo.js index 9da007fad66a..86871f822bd1 100644 --- a/src/libs/Navigation/linkTo.js +++ b/src/libs/Navigation/linkTo.js @@ -4,7 +4,7 @@ import NAVIGATORS from '../../NAVIGATORS'; import linkingConfig from './linkingConfig'; import getTopmostReportId from './getTopmostReportId'; -export default function linkTo(navigation, path) { +export default function linkTo(navigation, path, type) { const normalizedPath = !path.startsWith('/') ? `/${path}` : path; if (navigation === undefined) { throw new Error("Couldn't find a navigation object. Is your component inside a screen in a navigator?"); @@ -33,6 +33,11 @@ export default function linkTo(navigation, path) { if (action.payload.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR && getTopmostReportId(root.getState()) !== getTopmostReportId(state)) { action.type = 'PUSH'; + // If this action is navigating to the RightModalNavigator and the last route on the root navigator is also RightModalNavigator + // then we want to replace the current RHP state with new one + } else if (type === 'UP') { + action.type = 'REPLACE'; + // If this action is navigating to the RightModalNavigator and the last route on the root navigator is not RightModalNavigator then push } else if (action.payload.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR && _.last(root.getState().routes).name !== NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { action.type = 'PUSH'; diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 876eb943d354..898017f6bbb9 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -190,6 +190,9 @@ export default { GetAssistance: { path: ROUTES.GET_ASSISTANCE, }, + YearPicker_Root: { + path: ROUTES.SELECT_YEAR, + }, }, }, Report_Details: { @@ -291,11 +294,6 @@ export default { WalletStatement_Root: ROUTES.WALLET_STATEMENT_WITH_DATE, }, }, - Select_Year: { - screens: { - YearPicker_Root: ROUTES.SELECT_YEAR, - }, - }, }, }, }, diff --git a/src/pages/AddPersonalBankAccountPage.js b/src/pages/AddPersonalBankAccountPage.js index 36d82b1a7068..8e9e067957c3 100644 --- a/src/pages/AddPersonalBankAccountPage.js +++ b/src/pages/AddPersonalBankAccountPage.js @@ -3,7 +3,7 @@ import React from 'react'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; -import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../components/HeaderWithBackButton'; import ScreenWrapper from '../components/ScreenWrapper'; import Navigation from '../libs/Navigation/Navigation'; import * as BankAccounts from '../libs/actions/BankAccounts'; @@ -89,11 +89,9 @@ class AddPersonalBankAccountPage extends React.Component { includeSafeAreaPaddingBottom={shouldShowSuccess} shouldEnablePickerAvoiding={false} > - Navigation.goBack(ROUTES.SETTINGS_PAYMENTS)} /> {shouldShowSuccess ? ( { class DetailsPage extends React.PureComponent { render() { const login = lodashGet(this.props.route.params, 'login', ''); - const reportID = lodashGet(this.props.route.params, 'reportID', ''); let details = lodashGet(this.props.personalDetails, login); if (!details) { @@ -99,9 +99,6 @@ class DetailsPage extends React.PureComponent { const isSMSLogin = details.login ? Str.isSMSLogin(details.login) : false; - // If we have a reportID param this means that we - // arrived here via the ParticipantsPage and should be allowed to navigate back to it - const shouldShowBackButton = Boolean(reportID); const shouldShowLocalTime = !ReportUtils.hasAutomatedExpensifyEmails([details.login]) && details.timezone; let pronouns = details.pronouns; @@ -116,11 +113,9 @@ class DetailsPage extends React.PureComponent { return ( - Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal()} + onBackButtonPress={() => Navigation.goBack(ROUTES.HOME)} /> { return ( <> - Navigation.dismissModal()} - shouldShowBackButton - onBackButtonPress={() => Navigation.goBack()} - /> + - Navigation.dismissModal()} - shouldShowBackButton onBackButtonPress={() => Wallet.setAdditionalDetailsQuestions(null)} /> - Navigation.dismissModal()} - /> + {this.props.translate('additionalDetailsStep.helpText')} diff --git a/src/pages/EnablePayments/EnablePaymentsPage.js b/src/pages/EnablePayments/EnablePaymentsPage.js index 954c82edbabe..e0a1f5a22eee 100644 --- a/src/pages/EnablePayments/EnablePaymentsPage.js +++ b/src/pages/EnablePayments/EnablePaymentsPage.js @@ -15,11 +15,12 @@ import OnfidoStep from './OnfidoStep'; import AdditionalDetailsStep from './AdditionalDetailsStep'; import TermsStep from './TermsStep'; import ActivateStep from './ActivateStep'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; -import Navigation from '../../libs/Navigation/Navigation'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import FailedKYC from './FailedKYC'; import compose from '../../libs/compose'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; +import Navigation from '../../libs/Navigation/Navigation'; +import ROUTES from '../../ROUTES'; const propTypes = { /** Information about the network from Onyx */ @@ -59,9 +60,9 @@ class EnablePaymentsPage extends React.Component { if (this.props.userWallet.errorCode === CONST.WALLET.ERROR.KYC) { return ( <> - Navigation.dismissModal()} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PAYMENTS)} /> diff --git a/src/pages/EnablePayments/OnfidoStep.js b/src/pages/EnablePayments/OnfidoStep.js index 9c22175464ee..31727f51cb69 100644 --- a/src/pages/EnablePayments/OnfidoStep.js +++ b/src/pages/EnablePayments/OnfidoStep.js @@ -5,7 +5,7 @@ import ONYXKEYS from '../../ONYXKEYS'; import * as BankAccounts from '../../libs/actions/BankAccounts'; import Navigation from '../../libs/Navigation/Navigation'; import CONST from '../../CONST'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import * as Wallet from '../../libs/actions/Wallet'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; @@ -39,10 +39,8 @@ class OnfidoStep extends React.Component { render() { return ( <> - Navigation.dismissModal()} - shouldShowBackButton onBackButtonPress={() => Wallet.updateCurrentStep(CONST.WALLET.STEP.ADDITIONAL_DETAILS)} /> diff --git a/src/pages/EnablePayments/TermsStep.js b/src/pages/EnablePayments/TermsStep.js index 216787d12c5c..0e088e68f04c 100644 --- a/src/pages/EnablePayments/TermsStep.js +++ b/src/pages/EnablePayments/TermsStep.js @@ -1,8 +1,7 @@ import React from 'react'; import {ScrollView} from 'react-native'; import {withOnyx} from 'react-native-onyx'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; -import Navigation from '../../libs/Navigation/Navigation'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import styles from '../../styles/styles'; import * as BankAccounts from '../../libs/actions/BankAccounts'; @@ -69,10 +68,8 @@ class TermsStep extends React.Component { const errorMessage = this.state.error ? this.props.translate('common.error.acceptTerms') : ErrorUtils.getLatestErrorMessage(this.props.walletTerms) || ''; return ( <> - Navigation.dismissModal()} - /> + + { return ( - Navigation.dismissModal(true)} - shouldShowBackButton - onBackButtonPress={() => Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} />
{({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> - Navigation.dismissModal(true)} - /> + + 0 ? safeAreaPaddingBottomStyle : {}]}> -
- - { return ( -
- { return ( -
{ style={[styles.flex1, styles.justifyContentBetween]} includeSafeAreaPaddingBottom={false} > - Navigation.goBack()} />
- Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} /> {errorComponent} diff --git a/src/pages/ReimbursementAccount/RequestorOnfidoStep.js b/src/pages/ReimbursementAccount/RequestorOnfidoStep.js index 46eb79375bf7..aad5def99518 100644 --- a/src/pages/ReimbursementAccount/RequestorOnfidoStep.js +++ b/src/pages/ReimbursementAccount/RequestorOnfidoStep.js @@ -13,8 +13,7 @@ import Growl from '../../libs/Growl'; import CONST from '../../CONST'; import FullPageOfflineBlockingView from '../../components/BlockingViews/FullPageOfflineBlockingView'; import StepPropTypes from './StepPropTypes'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; -import Navigation from '../../libs/Navigation/Navigation'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import ScreenWrapper from '../../components/ScreenWrapper'; const propTypes = { @@ -43,14 +42,12 @@ class RequestorOnfidoStep extends React.Component { render() { return ( - diff --git a/src/pages/ReimbursementAccount/RequestorStep.js b/src/pages/ReimbursementAccount/RequestorStep.js index 74b183fe3d32..b69067550848 100644 --- a/src/pages/ReimbursementAccount/RequestorStep.js +++ b/src/pages/ReimbursementAccount/RequestorStep.js @@ -4,10 +4,9 @@ import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import styles from '../../styles/styles'; import withLocalize from '../../components/withLocalize'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import CONST from '../../CONST'; import TextLink from '../../components/TextLink'; -import Navigation from '../../libs/Navigation/Navigation'; import CheckboxWithLabel from '../../components/CheckboxWithLabel'; import Text from '../../components/Text'; import * as BankAccounts from '../../libs/actions/BankAccounts'; @@ -115,14 +114,12 @@ class RequestorStep extends React.Component { return ( - - {maxAttemptsReached && ( diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 9ed7bfa86092..48b873596e88 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -10,7 +10,7 @@ import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import ONYXKEYS from '../ONYXKEYS'; import ScreenWrapper from '../components/ScreenWrapper'; import Navigation from '../libs/Navigation/Navigation'; -import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../components/HeaderWithBackButton'; import styles from '../styles/styles'; import DisplayNames from '../components/DisplayNames'; import * as OptionsListUtils from '../libs/OptionsListUtils'; @@ -120,11 +120,7 @@ class ReportDetailsPage extends Component { return ( - Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal()} - /> + diff --git a/src/pages/ReportParticipantsPage.js b/src/pages/ReportParticipantsPage.js index a4a4d4b8e17a..febf3c890a68 100755 --- a/src/pages/ReportParticipantsPage.js +++ b/src/pages/ReportParticipantsPage.js @@ -7,7 +7,7 @@ import Str from 'expensify-common/lib/str'; import lodashGet from 'lodash/get'; import styles from '../styles/styles'; import ONYXKEYS from '../ONYXKEYS'; -import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../components/HeaderWithBackButton'; import Navigation from '../libs/Navigation/Navigation'; import ScreenWrapper from '../components/ScreenWrapper'; import OptionsList from '../components/OptionsList'; @@ -85,11 +85,8 @@ const ReportParticipantsPage = (props) => { {({safeAreaPaddingBottomStyle}) => ( - - + {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> - Navigation.dismissModal(true)} - /> + - Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal(true)} /> diff --git a/src/pages/YearPickerPage.js b/src/pages/YearPickerPage.js index 5cab2fc73044..b82c5413bf7f 100644 --- a/src/pages/YearPickerPage.js +++ b/src/pages/YearPickerPage.js @@ -2,7 +2,7 @@ import _ from 'underscore'; import React from 'react'; import {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../components/withCurrentUserPersonalDetails'; import ScreenWrapper from '../components/ScreenWrapper'; -import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../components/HeaderWithBackButton'; import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import ROUTES from '../ROUTES'; import styles from '../styles/styles'; @@ -64,7 +64,7 @@ class YearPickerPage extends React.Component { */ updateSelectedYear(selectedYear) { // We have to navigate using concatenation here as it is not possible to pass a function as a route param - Navigation.navigate(`${this.props.route.params.backTo}?year=${selectedYear}`); + Navigation.goBack(`${ROUTES.SETTINGS_PERSONAL_DETAILS_DATE_OF_BIRTH}?year=${selectedYear}`, true); } /** @@ -89,11 +89,9 @@ class YearPickerPage extends React.Component { const headerMessage = this.state.inputText.trim() && !this.state.yearOptions.length ? this.props.translate('common.noResultsFound') : ''; return ( - Navigation.navigate(`${this.props.route.params.backTo}?year=${this.currentYear}` || ROUTES.HOME)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(`${this.props.route.params.backTo}?year=${this.currentYear}` || ROUTES.HOME)} /> { this.setState({animationFinished: true}); }); + + // ReportScreen is nested inside another navigator, so we need to listen to the parent navigator's events + this.transitionEndListener = this.props.navigation.getParent().addListener('transitionEnd', (e) => { + this.setState({isScreenBlurred: e.data.closing}); + }); + + this.gestureStartListener = this.props.navigation.getParent().addListener('gestureStart', () => { + this.setState({isScreenBlurred: false}); + }); } componentDidUpdate(prevProps) { @@ -175,6 +191,8 @@ class ReportScreen extends React.Component { this.unsubscribeVisibilityListener(); } Navigation.resetIsReportScreenReadyPromise(); + this.transitionEndListener(); + this.gestureStartListener(); } /** @@ -241,7 +259,8 @@ class ReportScreen extends React.Component { (ReportUtils.isUserCreatedPolicyRoom(this.props.report) && !Permissions.canUsePolicyRooms(this.props.betas)); // When the ReportScreen is not open/in the viewport, we want to "freeze" it for performance reasons - const shouldFreeze = this.props.isSmallScreenWidth && !this.props.isFocused; + const isVisible = this.props.isFocused || !this.state.isScreenBlurred; + const shouldFreeze = this.props.isSmallScreenWidth && !isVisible; const isLoading = !reportID || !this.props.isSidebarLoaded || _.isEmpty(this.props.personalDetails) || !this.state.animationFinished; @@ -294,7 +313,7 @@ class ReportScreen extends React.Component { ) : ( Navigation.goBack(ROUTES.HOME)} personalDetails={this.props.personalDetails} report={this.props.report} /> @@ -388,6 +407,7 @@ export default compose( withLocalize, withWindowDimensions, withNavigationFocus, + withNavigation, withNetwork(), withOnyx({ isSidebarLoaded: { diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 21fa3300f8a1..fa73f8650a31 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -49,7 +49,6 @@ import ArrowKeyFocusManager from '../../../components/ArrowKeyFocusManager'; import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; import KeyboardShortcut from '../../../libs/KeyboardShortcut'; import * as ComposerUtils from '../../../libs/ComposerUtils'; -import * as ComposerActions from '../../../libs/actions/Composer'; import * as Welcome from '../../../libs/actions/Welcome'; import Permissions from '../../../libs/Permissions'; import * as TaskUtils from '../../../libs/actions/Task'; diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js index 95e81854a671..2bfbceed1384 100644 --- a/src/pages/home/sidebar/SidebarLinks.js +++ b/src/pages/home/sidebar/SidebarLinks.js @@ -31,6 +31,7 @@ import reportPropTypes from '../../reportPropTypes'; import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; import withNavigationFocus from '../../../components/withNavigationFocus'; import withCurrentReportId from '../../../components/withCurrentReportId'; +import withNavigation, {withNavigationPropTypes} from '../../../components/withNavigation'; import Header from '../../../components/Header'; import defaultTheme from '../../../styles/themes/default'; import OptionsListSkeletonView from '../../../components/OptionsListSkeletonView'; @@ -78,6 +79,7 @@ const propTypes = { priorityMode: PropTypes.string, ...withLocalizePropTypes, + ...withNavigationPropTypes, }; const defaultProps = { @@ -92,17 +94,42 @@ const defaultProps = { }; class SidebarLinks extends React.Component { + transitionEndListener = null; + + gestureStartListener = null; + constructor(props) { super(props); this.showSearchPage = this.showSearchPage.bind(this); this.showSettingsPage = this.showSettingsPage.bind(this); this.showReportPage = this.showReportPage.bind(this); + + if (this.props.isSmallScreenWidth) { + App.confirmReadyToOpenApp(); + } + + this.state = { + isScreenBlurred: false, + }; } componentDidMount() { App.setSidebarLoaded(); this.isSidebarLoaded = true; + // SidebarLinks need to have information if the screen is blurred in order to enable freeze + this.transitionEndListener = this.props.navigation.addListener('transitionEnd', (e) => { + this.setState({isScreenBlurred: e.data.closing}); + }); + + this.gestureStartListener = this.props.navigation.addListener('gestureStart', () => { + this.setState({isScreenBlurred: false}); + }); + } + + componentWillUnmount() { + this.transitionEndListener(); + this.gestureStartListener(); } showSearchPage() { @@ -138,7 +165,8 @@ class SidebarLinks extends React.Component { render() { const isLoading = _.isEmpty(this.props.personalDetails) || _.isEmpty(this.props.chatReports); - const shouldFreeze = this.props.isSmallScreenWidth && !this.props.isFocused && this.isSidebarLoaded; + const isVisible = this.props.isFocused || !this.state.isScreenBlurred; + const shouldFreeze = this.props.isSmallScreenWidth && this.isSidebarLoaded && !isVisible; const optionListItems = SidebarUtils.getOrderedReportIDs(this.props.reportIDFromRoute); const skeletonPlaceholder = ; @@ -294,6 +322,7 @@ export default compose( withNavigationFocus, withWindowDimensions, withCurrentReportId, + withNavigation, withOnyx({ // Note: It is very important that the keys subscribed to here are the same // keys that are subscribed to at the top of SidebarUtils.js. If there was a key missing from here and data was updated diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index 20182afc4fff..4d835bc872ec 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -7,12 +7,13 @@ import ONYXKEYS from '../../ONYXKEYS'; import OptionsSelector from '../../components/OptionsSelector'; import Navigation from '../../libs/Navigation/Navigation'; import ScreenWrapper from '../../components/ScreenWrapper'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import compose from '../../libs/compose'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import * as IOU from '../../libs/actions/IOU'; import * as CurrencyUtils from '../../libs/CurrencyUtils'; import {withNetwork} from '../../components/OnyxProvider'; +import ROUTES from '../../ROUTES'; import CONST from '../../CONST'; import themeColors from '../../styles/themes/default'; import * as Expensicons from '../../components/Icon/Expensicons'; @@ -138,9 +139,9 @@ class IOUCurrencySelection extends Component { {({safeAreaPaddingBottomStyle}) => ( <> - Navigation.goBack(ROUTES.getIouRequestRoute(Navigation.getTopmostReportId()))} /> - Navigation.goBack(ROUTES.IOU_REQUEST)} /> {this.props.iou.loading ? ( diff --git a/src/pages/iou/ModalHeader.js b/src/pages/iou/ModalHeader.js deleted file mode 100644 index dd5b3fdadf54..000000000000 --- a/src/pages/iou/ModalHeader.js +++ /dev/null @@ -1,63 +0,0 @@ -import React from 'react'; -import {View, TouchableOpacity} from 'react-native'; -import PropTypes from 'prop-types'; -import styles from '../../styles/styles'; -import Icon from '../../components/Icon'; -import Header from '../../components/Header'; -import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; -import * as Expensicons from '../../components/Icon/Expensicons'; -import Tooltip from '../../components/Tooltip'; -import Navigation from '../../libs/Navigation/Navigation'; - -const propTypes = { - /** Title of the header */ - title: PropTypes.string.isRequired, - - /** Should we show the back button? */ - shouldShowBackButton: PropTypes.bool, - - /** Callback to fire on back button press */ - onBackButtonPress: PropTypes.func, - - ...withLocalizePropTypes, -}; - -const defaultProps = { - shouldShowBackButton: true, - onBackButtonPress: () => Navigation.goBack(), -}; - -const ModalHeader = (props) => ( - - - {props.shouldShowBackButton && ( - - - - - - )} -
- - - Navigation.dismissModal()} - style={[styles.touchableButtonImage]} - accessibilityRole="button" - accessibilityLabel={props.translate('common.close')} - > - - - - - - -); - -ModalHeader.displayName = 'ModalHeader'; -ModalHeader.propTypes = propTypes; -ModalHeader.defaultProps = defaultProps; -export default withLocalize(ModalHeader); diff --git a/src/pages/iou/MoneyRequestDescriptionPage.js b/src/pages/iou/MoneyRequestDescriptionPage.js index a186d6a41054..93b1470b6179 100644 --- a/src/pages/iou/MoneyRequestDescriptionPage.js +++ b/src/pages/iou/MoneyRequestDescriptionPage.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import TextInput from '../../components/TextInput'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import ScreenWrapper from '../../components/ScreenWrapper'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import Form from '../../components/Form'; import ONYXKEYS from '../../ONYXKEYS'; import styles from '../../styles/styles'; @@ -37,11 +37,11 @@ class MoneyRequestDescriptionPage extends Component { } /** - * Closes the modal and clears the description from Onyx. + * Goes back and clears the description from Onyx. */ - onCloseButtonPress() { + onBackButtonPress() { IOU.setMoneyRequestDescription(''); - Navigation.dismissModal(); + Navigation.goBack(); } /** @@ -62,11 +62,9 @@ class MoneyRequestDescriptionPage extends Component { shouldEnableMaxHeight onEntryTransitionEnd={() => this.descriptionInputRef && this.descriptionInputRef.focus()} > - { const currentStep = steps[currentStepIndex]; const moneyRequestStepIndex = _.indexOf(steps, Steps.MoneyRequestConfirm); const isEditingAmountAfterConfirm = currentStepIndex === 0 && previousStepIndex === _.indexOf(steps, Steps.MoneyRequestConfirm); + const navigateBack = isEditingAmountAfterConfirm ? () => navigateToStep(moneyRequestStepIndex) : navigateToPreviousStep; const reportID = lodashGet(props, 'route.params.reportID', ''); - const shouldShowBackButton = currentStepIndex > 0 || isEditingAmountAfterConfirm; const modalHeader = ( - navigateToStep(moneyRequestStepIndex) : navigateToPreviousStep} + onBackButtonPress={currentStepIndex === 0 ? Navigation.dismissModal : navigateBack} /> ); const amountButtonText = isEditingAmountAfterConfirm ? props.translate('common.save') : props.translate('common.next'); const enableMaxHeight = DeviceCapabilities.canUseTouchScreen() && currentStep === Steps.MoneyRequestParticipants; - return ( { {({safeAreaPaddingBottomStyle}) => ( <> - Navigation.navigate(ROUTES.SETTINGS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} /> diff --git a/src/pages/settings/AppDownloadLinks.js b/src/pages/settings/AppDownloadLinks.js index c120bf68872d..3c42e4901616 100644 --- a/src/pages/settings/AppDownloadLinks.js +++ b/src/pages/settings/AppDownloadLinks.js @@ -1,8 +1,7 @@ import _ from 'underscore'; import React from 'react'; import {ScrollView} from 'react-native'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; -import Navigation from '../../libs/Navigation/Navigation'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import CONST from '../../CONST'; import * as Expensicons from '../../components/Icon/Expensicons'; import ScreenWrapper from '../../components/ScreenWrapper'; @@ -14,6 +13,8 @@ import * as Link from '../../libs/actions/Link'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions'; import * as ReportActionContextMenu from '../home/report/ContextMenu/ReportActionContextMenu'; import {CONTEXT_MENU_TYPES} from '../home/report/ContextMenu/ContextMenuActions'; +import ROUTES from '../../ROUTES'; +import Navigation from '../../libs/Navigation/Navigation'; const propTypes = { ...withLocalizePropTypes, @@ -55,11 +56,9 @@ const AppDownloadLinksPage = (props) => { return ( - Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_ABOUT)} /> {_.map(menuItems, (item) => ( diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index eba3ccefb9fd..168f78b1d9fe 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -11,7 +11,7 @@ import * as Session from '../../libs/actions/Session'; import ONYXKEYS from '../../ONYXKEYS'; import Tooltip from '../../components/Tooltip'; import Avatar from '../../components/Avatar'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import Navigation from '../../libs/Navigation/Navigation'; import * as Expensicons from '../../components/Icon/Expensicons'; import ScreenWrapper from '../../components/ScreenWrapper'; @@ -314,10 +314,7 @@ class InitialSettingsPage extends React.Component { {({safeAreaPaddingBottomStyle}) => ( <> - Navigation.dismissModal(true)} - /> + - Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_SECURITY)} /> {!_.isEmpty(this.props.account.success) ? ( - Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PAYMENTS)} /> { return ( payPalMeInput.current && payPalMeInput.current.focus()}> - Navigation.navigate(ROUTES.SETTINGS_PAYMENTS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PAYMENTS)} /> diff --git a/src/pages/settings/Payments/ChooseTransferAccountPage.js b/src/pages/settings/Payments/ChooseTransferAccountPage.js index 6fe32df5af15..224b727bf4e5 100644 --- a/src/pages/settings/Payments/ChooseTransferAccountPage.js +++ b/src/pages/settings/Payments/ChooseTransferAccountPage.js @@ -1,7 +1,7 @@ import React from 'react'; import {withOnyx} from 'react-native-onyx'; import {View} from 'react-native'; -import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import ScreenWrapper from '../../../components/ScreenWrapper'; import Navigation from '../../../libs/Navigation/Navigation'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; @@ -53,11 +53,9 @@ const ChooseTransferAccountPage = (props) => { return ( - Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal()} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PAYMENTS_TRANSFER_BALANCE)} /> - Navigation.navigate(ROUTES.SETTINGS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} /> - - Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_PAYMENTS)} /> diff --git a/src/pages/settings/Preferences/LanguagePage.js b/src/pages/settings/Preferences/LanguagePage.js index f4c1b14d948b..23f36e6e44e3 100644 --- a/src/pages/settings/Preferences/LanguagePage.js +++ b/src/pages/settings/Preferences/LanguagePage.js @@ -1,16 +1,16 @@ import _ from 'underscore'; import React from 'react'; import PropTypes from 'prop-types'; -import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import ScreenWrapper from '../../../components/ScreenWrapper'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import Navigation from '../../../libs/Navigation/Navigation'; -import ROUTES from '../../../ROUTES'; import OptionsList from '../../../components/OptionsList'; import styles from '../../../styles/styles'; import themeColors from '../../../styles/themes/default'; import * as Expensicons from '../../../components/Icon/Expensicons'; import * as App from '../../../libs/actions/App'; +import Navigation from '../../../libs/Navigation/Navigation'; +import ROUTES from '../../../ROUTES'; const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; @@ -36,11 +36,9 @@ const LanguagePage = (props) => { return ( - Navigation.navigate(ROUTES.SETTINGS_PREFERENCES)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PREFERENCES)} /> { return ( - Navigation.navigate(ROUTES.SETTINGS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} /> diff --git a/src/pages/settings/Preferences/PriorityModePage.js b/src/pages/settings/Preferences/PriorityModePage.js index 0e254311bb40..e044d906e862 100644 --- a/src/pages/settings/Preferences/PriorityModePage.js +++ b/src/pages/settings/Preferences/PriorityModePage.js @@ -2,11 +2,9 @@ import _, {compose} from 'underscore'; import React from 'react'; import {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; -import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import ScreenWrapper from '../../../components/ScreenWrapper'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import Navigation from '../../../libs/Navigation/Navigation'; -import ROUTES from '../../../ROUTES'; import OptionsList from '../../../components/OptionsList'; import styles from '../../../styles/styles'; import Text from '../../../components/Text'; @@ -15,6 +13,8 @@ import * as Expensicons from '../../../components/Icon/Expensicons'; import ONYXKEYS from '../../../ONYXKEYS'; import * as User from '../../../libs/actions/User'; import CONST from '../../../CONST'; +import Navigation from '../../../libs/Navigation/Navigation'; +import ROUTES from '../../../ROUTES'; const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; @@ -48,11 +48,9 @@ const PriorityModePage = (props) => { return ( - Navigation.navigate(ROUTES.SETTINGS_PREFERENCES)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PREFERENCES)} /> {props.translate('priorityModePage.explainerText')} - Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS)} /> { return ( - Navigation.navigate(ROUTES.SETTINGS_PROFILE)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)} /> diff --git a/src/pages/settings/Profile/Contacts/NewContactMethodPage.js b/src/pages/settings/Profile/Contacts/NewContactMethodPage.js index 221f4a0ff549..b4af941cf1bf 100644 --- a/src/pages/settings/Profile/Contacts/NewContactMethodPage.js +++ b/src/pages/settings/Profile/Contacts/NewContactMethodPage.js @@ -7,7 +7,7 @@ import lodashGet from 'lodash/get'; import Str from 'expensify-common/lib/str'; import {parsePhoneNumber} from 'awesome-phonenumber'; import compose from '../../../../libs/compose'; -import HeaderWithCloseButton from '../../../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../../../components/HeaderWithBackButton'; import ScreenWrapper from '../../../../components/ScreenWrapper'; import Text from '../../../../components/Text'; import TextInput from '../../../../components/TextInput'; @@ -119,11 +119,9 @@ function NewContactMethodPage(props) { }} includeSafeAreaPaddingBottom={false} > - Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHODS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS)} /> - Navigation.navigate(ROUTES.SETTINGS_PROFILE)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)} /> - Navigation.navigate(ROUTES.SETTINGS_PERSONAL_DETAILS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PERSONAL_DETAILS)} /> - Navigation.navigate(ROUTES.SETTINGS_PERSONAL_DETAILS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PERSONAL_DETAILS)} /> - Navigation.navigate(ROUTES.SETTINGS_PERSONAL_DETAILS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PERSONAL_DETAILS)} /> { return ( - Navigation.navigate(ROUTES.SETTINGS_PROFILE)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)} /> diff --git a/src/pages/settings/Profile/ProfilePage.js b/src/pages/settings/Profile/ProfilePage.js index 88890bcd0f99..3ecfa65a7f1a 100755 --- a/src/pages/settings/Profile/ProfilePage.js +++ b/src/pages/settings/Profile/ProfilePage.js @@ -6,7 +6,7 @@ import {withOnyx} from 'react-native-onyx'; import {ScrollView} from 'react-native-gesture-handler'; import _ from 'underscore'; import AvatarWithImagePicker from '../../../components/AvatarWithImagePicker'; -import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import MenuItem from '../../../components/MenuItem'; import MenuItemWithTopDescription from '../../../components/MenuItemWithTopDescription'; import OfflineWithFeedback from '../../../components/OfflineWithFeedback'; @@ -82,11 +82,9 @@ const ProfilePage = (props) => { return ( - Navigation.navigate(ROUTES.SETTINGS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} /> {({safeAreaPaddingBottomStyle}) => ( <> - Navigation.navigate(ROUTES.SETTINGS_PROFILE)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)} /> {this.props.translate('pronounsPage.isShownOnProfile')} { return ( - Navigation.navigate(ROUTES.SETTINGS_PROFILE)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_PROFILE)} /> diff --git a/src/pages/settings/Profile/TimezoneSelectPage.js b/src/pages/settings/Profile/TimezoneSelectPage.js index 6e410655b2b5..a5853d3c99d5 100644 --- a/src/pages/settings/Profile/TimezoneSelectPage.js +++ b/src/pages/settings/Profile/TimezoneSelectPage.js @@ -4,17 +4,17 @@ import _ from 'underscore'; import moment from 'moment-timezone'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../../components/withCurrentUserPersonalDetails'; import ScreenWrapper from '../../../components/ScreenWrapper'; -import HeaderWithCloseButton from '../../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import ROUTES from '../../../ROUTES'; import CONST from '../../../CONST'; import styles from '../../../styles/styles'; -import Navigation from '../../../libs/Navigation/Navigation'; import * as PersonalDetails from '../../../libs/actions/PersonalDetails'; import compose from '../../../libs/compose'; import OptionsSelector from '../../../components/OptionsSelector'; import themeColors from '../../../styles/themes/default'; import * as Expensicons from '../../../components/Icon/Expensicons'; +import Navigation from '../../../libs/Navigation/Navigation'; +import ROUTES from '../../../ROUTES'; const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; @@ -124,11 +124,9 @@ class TimezoneSelectPage extends Component { {({safeAreaPaddingBottomStyle}) => ( <> - Navigation.navigate(ROUTES.SETTINGS_TIMEZONE)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_TIMEZONE)} /> - Navigation.navigate(ROUTES.SETTINGS_SECURITY)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_SECURITY)} /> { return ( - Navigation.navigate(ROUTES.SETTINGS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} /> diff --git a/src/pages/tasks/NewTaskDescriptionPage.js b/src/pages/tasks/NewTaskDescriptionPage.js index 0d2c7ff7fff4..6e929ffba87b 100644 --- a/src/pages/tasks/NewTaskDescriptionPage.js +++ b/src/pages/tasks/NewTaskDescriptionPage.js @@ -4,7 +4,7 @@ import {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import Navigation from '../../libs/Navigation/Navigation'; import ScreenWrapper from '../../components/ScreenWrapper'; import styles from '../../styles/styles'; @@ -68,10 +68,8 @@ const NewTaskDescriptionPage = (props) => { inputRef.current.focus(); }} > - Navigation.dismissModal()} - shouldShowBackButton onBackButtonPress={() => Navigation.goBack()} /> { onEntryTransitionEnd={() => inputRef.current && inputRef.current.focus()} includeSafeAreaPaddingBottom={false} > - Navigation.dismissModal()} - shouldShowBackButton - onBackButtonPress={() => Navigation.goBack()} - /> + { return ( - Navigation.dismissModal()} - shouldShowBackButton onBackButtonPress={() => Navigation.goBack()} /> diff --git a/src/pages/tasks/NewTaskTitlePage.js b/src/pages/tasks/NewTaskTitlePage.js index 09d082fba080..63609cfe692e 100644 --- a/src/pages/tasks/NewTaskTitlePage.js +++ b/src/pages/tasks/NewTaskTitlePage.js @@ -4,7 +4,7 @@ import {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import Navigation from '../../libs/Navigation/Navigation'; import ScreenWrapper from '../../components/ScreenWrapper'; import styles from '../../styles/styles'; @@ -76,10 +76,8 @@ const NewTaskTitlePage = (props) => { }} includeSafeAreaPaddingBottom={false} > - Navigation.dismissModal()} - shouldShowBackButton onBackButtonPress={() => Navigation.goBack()} /> { {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> - Navigation.goBack()} - shouldShowBackButton onBackButtonPress={() => Navigation.goBack()} /> diff --git a/src/pages/tasks/TaskDescriptionPage.js b/src/pages/tasks/TaskDescriptionPage.js index d96682151f18..1b72f16462cd 100644 --- a/src/pages/tasks/TaskDescriptionPage.js +++ b/src/pages/tasks/TaskDescriptionPage.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import ScreenWrapper from '../../components/ScreenWrapper'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import Form from '../../components/Form'; import ONYXKEYS from '../../ONYXKEYS'; @@ -71,7 +71,7 @@ function TaskDescriptionPage(props) { includeSafeAreaPaddingBottom={false} onEntryTransitionEnd={() => inputRef.current && inputRef.current.focus()} > - Navigation.goBack()} diff --git a/src/pages/tasks/TaskShareDestinationSelectorModal.js b/src/pages/tasks/TaskShareDestinationSelectorModal.js index cd155d915956..32870a97bf81 100644 --- a/src/pages/tasks/TaskShareDestinationSelectorModal.js +++ b/src/pages/tasks/TaskShareDestinationSelectorModal.js @@ -8,7 +8,7 @@ import * as OptionsListUtils from '../../libs/OptionsListUtils'; import ONYXKEYS from '../../ONYXKEYS'; import styles from '../../styles/styles'; import Navigation from '../../libs/Navigation/Navigation'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import ScreenWrapper from '../../components/ScreenWrapper'; import Timing from '../../libs/actions/Timing'; import CONST from '../../CONST'; @@ -141,10 +141,8 @@ const TaskShareDestinationSelectorModal = (props) => { {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> - Navigation.goBack()} - shouldShowBackButton onBackButtonPress={() => Navigation.goBack()} /> diff --git a/src/pages/tasks/TaskTitlePage.js b/src/pages/tasks/TaskTitlePage.js index 9fb5e3b8a479..05a8b1d4b432 100644 --- a/src/pages/tasks/TaskTitlePage.js +++ b/src/pages/tasks/TaskTitlePage.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import ScreenWrapper from '../../components/ScreenWrapper'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import Form from '../../components/Form'; import ONYXKEYS from '../../ONYXKEYS'; @@ -72,7 +72,7 @@ function TaskTitlePage(props) { includeSafeAreaPaddingBottom={false} onEntryTransitionEnd={() => inputRef.current && inputRef.current.focus()} > - Navigation.goBack()} diff --git a/src/pages/wallet/WalletStatementPage.js b/src/pages/wallet/WalletStatementPage.js index 033e24dc912d..443d8ad755e6 100644 --- a/src/pages/wallet/WalletStatementPage.js +++ b/src/pages/wallet/WalletStatementPage.js @@ -6,7 +6,7 @@ import moment from 'moment'; import Str from 'expensify-common/lib/str'; import Navigation from '../../libs/Navigation/Navigation'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import ScreenWrapper from '../../components/ScreenWrapper'; import ONYXKEYS from '../../ONYXKEYS'; import compose from '../../libs/compose'; @@ -94,10 +94,9 @@ class WalletStatementPage extends React.Component { return ( - Navigation.dismissModal(true)} onDownloadButtonPress={() => this.processDownload(this.yearMonth)} /> diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index bc4d6274534c..bd23cb663a2b 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -14,7 +14,7 @@ import * as Expensicons from '../../components/Icon/Expensicons'; import ScreenWrapper from '../../components/ScreenWrapper'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import MenuItem from '../../components/MenuItem'; -import HeaderWithCloseButton from '../../components/HeaderWithCloseButton'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import compose from '../../libs/compose'; import Avatar from '../../components/Avatar'; import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView'; @@ -134,11 +134,8 @@ const WorkspaceInitialPage = (props) => { shouldShow={_.isEmpty(policy)} onBackButtonPress={() => Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)} > - Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)} - onCloseButtonPress={() => Navigation.dismissModal()} shouldShowThreeDotsButton shouldShowGetAssistanceButton guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_INITIAL} @@ -150,6 +147,7 @@ const WorkspaceInitialPage = (props) => { }, ]} threeDotsAnchorPosition={styles.threeDotsPopoverOffset} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_WORKSPACES)} /> Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)} > - - this.clearErrors(true)} shouldShowGetAssistanceButton guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} - shouldShowBackButton - onBackButtonPress={() => Navigation.goBack()} + onBackButtonPress={() => { + this.clearErrors(); + Navigation.goBack(ROUTES.getWorkspaceMembersRoute(this.props.route.params.policyID)); + }} /> Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)} > - Navigation.dismissModal()} onBackButtonPress={() => { this.updateSearchValue(''); - Navigation.navigate(ROUTES.getWorkspaceInitialRoute(policyID)); + Navigation.goBack(ROUTES.getWorkspaceInitialRoute(policyID)); }} shouldShowGetAssistanceButton guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_MEMBERS} - shouldShowBackButton /> - Navigation.dismissModal()} - /> + Navigation.navigate(ROUTES.SETTINGS_WORKSPACES)} > - Navigation.navigate(ROUTES.getWorkspaceInitialRoute(policyID))} - onCloseButtonPress={() => Navigation.dismissModal()} + onBackButtonPress={() => Navigation.goBack(ROUTES.getWorkspaceInitialRoute(policyID))} /> {this.props.shouldUseScrollView ? ( - Navigation.navigate(ROUTES.SETTINGS)} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS)} /> {_.isEmpty(workspaces) ? ( ; +const Template = (args) => ; // Arguments can be passed to the component by binding // See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args diff --git a/tests/ui/UnreadIndicatorsTest.js b/tests/ui/UnreadIndicatorsTest.js index 8ac94782fd4b..70649900b61c 100644 --- a/tests/ui/UnreadIndicatorsTest.js +++ b/tests/ui/UnreadIndicatorsTest.js @@ -329,6 +329,13 @@ describe('Unread Indicators', () => { }, shouldNotify: true, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.PERSONAL_DETAILS, + value: { + [USER_C_EMAIL]: TestHelper.buildPersonalDetails(USER_C_EMAIL, USER_C_ACCOUNT_ID, 'C'), + }, + }, ]); return waitForPromisesToResolve(); }) diff --git a/tests/utils/LHNTestUtils.js b/tests/utils/LHNTestUtils.js index 1631cd6ccdca..9c96004bedea 100644 --- a/tests/utils/LHNTestUtils.js +++ b/tests/utils/LHNTestUtils.js @@ -6,6 +6,7 @@ import {LocaleContextProvider} from '../../src/components/withLocalize'; import SidebarLinks from '../../src/pages/home/sidebar/SidebarLinks'; import CONST from '../../src/CONST'; import DateUtils from '../../src/libs/DateUtils'; +import {CurrentReportIdContextProvider} from '../../src/components/withCurrentReportId'; // we have to mock `useIsFocused` because it's used in the SidebarLinks component const mockedNavigate = jest.fn(); @@ -16,6 +17,11 @@ jest.mock('@react-navigation/native', () => { useIsFocused: () => ({ navigate: mockedNavigate, }), + useNavigation: () => ({ + navigate: jest.fn(), + addListener: jest.fn(), + }), + createNavigationContainerRef: jest.fn(), }; }); @@ -180,7 +186,7 @@ function getDefaultRenderedSidebarLinks(reportIDFromRoute = '') { // and there are a lot of render warnings. It needs to be done like this because normally in // our app (App.js) is when the react application is wrapped in the context providers render( - + {}}