Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Navigation Reboot] Swap the DrawerNavigator for the ResponsiveNavigator #16581

Merged
merged 74 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
22ba888
remove web specific getNavigationModalCardStyles
adamgrzybowski Mar 20, 2023
6e1691b
extract modal screens to the RightModalStack
adamgrzybowski Mar 21, 2023
f7a1ed1
create responsive stack navigator
adamgrzybowski Mar 23, 2023
17b47f8
remove drawer
adamgrzybowski Mar 22, 2023
543cb76
replace BaseDrawerNavigator with ReportScreen
adamgrzybowski Mar 23, 2023
e87f205
add handling initial state on resize
adamgrzybowski Mar 23, 2023
53cd8e1
fullScreenModalStack
adamgrzybowski Mar 23, 2023
674883e
add border color for sidebar
adamgrzybowski Mar 24, 2023
f432729
rename WideView to ThreePaneView
adamgrzybowski Mar 24, 2023
74798c0
Remove withDrawerState and isDrawerOpen (#3)
staszekscp Mar 27, 2023
b3d01d4
add new Navigators and adjust linking config
adamgrzybowski Mar 24, 2023
8ec253d
modify Navigation.js
adamgrzybowski Mar 24, 2023
e26af41
use ReportScreenWrapper to set initial params and add ensureCentralPa…
adamgrzybowski Mar 27, 2023
b22258c
fix not working FAB on ThreePaneView
staszekscp Mar 28, 2023
08c2ccc
modyfi linkTo to push instead of navigate in specified conditions
adamgrzybowski Mar 28, 2023
b7d2535
Revert "add getTopmostReportId"
adamgrzybowski Mar 28, 2023
8d2d330
remove isModal option from the RightModalStackScreen and rename navig…
adamgrzybowski Mar 29, 2023
6e46cb0
move ensuring report screen on the stack to the custom router
adamgrzybowski Mar 29, 2023
3dbabdc
fix ReportSccreenWrapper reportID loading when opening directly after…
adamgrzybowski Mar 29, 2023
58fbc77
add getTopmostReportId
staszekscp Mar 28, 2023
298328b
improve readability
staszekscp Mar 28, 2023
ac7043c
fix
staszekscp Mar 30, 2023
e0fc4ca
fix the not found page
adamgrzybowski Mar 30, 2023
8d070fb
remove isDrawerReady from pages and actions
adamgrzybowski Mar 30, 2023
95dd4ee
fix rebase problems
adamgrzybowski Mar 31, 2023
c0e4814
wrap navigation on concierge page with useFocusEffect
adamgrzybowski Mar 31, 2023
b1a80a0
add firstRenderRef to the ReportScreen
adamgrzybowski Apr 3, 2023
e808e81
uncomment section for getting state in the linkTo
adamgrzybowski Apr 3, 2023
c58f0d3
fix going back sidebar behavior
staszekscp Apr 4, 2023
7872b50
cleanup
staszekscp Apr 4, 2023
1a71cc4
fix comment
staszekscp Apr 4, 2023
d98111a
Merge pull request #8 from adamgrzybowski/fix-going-back
adamgrzybowski Apr 4, 2023
387820a
add optional chaining for type safety
staszekscp Apr 5, 2023
3913906
add accidentally removed Select_Year in linking config
adamgrzybowski Apr 5, 2023
701cd01
add proper animation for opening report screen on the android
adamgrzybowski Apr 5, 2023
b0f6c88
fix crashing safari
staszekscp Apr 5, 2023
eaf8b97
Merge branch 'navigation-refactor' into remove-drawer
adamgrzybowski Apr 5, 2023
803711c
apply code suggestions
adamgrzybowski Apr 5, 2023
c354a4c
add animation for closing report screen
adamgrzybowski Apr 5, 2023
ba4ab72
remove getReportIDFromRoute helper function from /AppNavigator
adamgrzybowski Apr 5, 2023
b919e64
fix eslint errors in ThreePaneView and StyleUtils
adamgrzybowski Apr 5, 2023
85665d1
fix fab on android
staszekscp Apr 6, 2023
71b7c61
remove unused onLayout prop
staszekscp Apr 6, 2023
aea4187
remove unused onLayout prop
staszekscp Apr 6, 2023
9c626fa
create CustomFlatList that remembers the offset when frozen
adamgrzybowski Apr 6, 2023
9ce4817
fix navigating push to currently visible report screens
adamgrzybowski Apr 7, 2023
3dfae04
add dismiss modal to the concierge page
adamgrzybowski Apr 7, 2023
091232e
use goBack on the BlockinView and ReportScreen
adamgrzybowski Apr 7, 2023
7d53900
add prop types for the ResponsiveStackNavigator
adamgrzybowski Apr 7, 2023
6e501c8
add JSDocs for getTopmostReportId and CustomRouter
adamgrzybowski Apr 7, 2023
fbbb0d6
remove renderRightPanel function from the THreePaneView
adamgrzybowski Apr 7, 2023
62b5df8
remove drawer related functions from the Navigation.js
adamgrzybowski Apr 7, 2023
907ecb9
fix linting errors
adamgrzybowski Apr 7, 2023
12925ce
merge navigation-refactor into remove-drawer
adamgrzybowski Apr 11, 2023
fab09fb
fix styles
staszekscp Apr 12, 2023
90d5548
remove getNavigationModalCardStyles
staszekscp Apr 12, 2023
4ff3feb
openOnAdminRoom support
staszekscp Apr 12, 2023
f6aabf9
fix proptypes
staszekscp Apr 12, 2023
9912285
feat: testing
WoLewicki Apr 12, 2023
f075d79
fix: tests
WoLewicki Apr 13, 2023
a4100b4
fix linting errors
adamgrzybowski Apr 17, 2023
a84b889
add suggestes chagnes
adamgrzybowski Apr 17, 2023
16f651a
Merge branch 'navigation-refactor' into remove-drawer
adamgrzybowski Apr 18, 2023
ef5f498
feat: another approach to heavy first render
WoLewicki Apr 20, 2023
1083956
add suggested chagnes
adamgrzybowski Apr 20, 2023
68e66c0
remove unnecessary isDrawerReady and isDrawerOpen
staszekscp Apr 21, 2023
d0fc931
apply suggested changes
staszekscp Apr 21, 2023
83749b4
chore: make tests pass for now
WoLewicki Apr 21, 2023
5bdfc35
rem
staszekscp Apr 21, 2023
2305c61
add
staszekscp Apr 21, 2023
04b5c75
add last line
staszekscp Apr 21, 2023
0dde99f
Update src/libs/Navigation/Navigation.js
adamgrzybowski Apr 21, 2023
66756e7
Update src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigat…
adamgrzybowski Apr 21, 2023
e54d869
add suggested chagnes
adamgrzybowski Apr 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import SafeArea from './components/SafeArea';
import * as Environment from './libs/Environment/Environment';
import {WindowDimensionsProvider} from './components/withWindowDimensions';
import {KeyboardStateProvider} from './components/withKeyboardState';
import {CurrentReportIdContextProvider} from './components/withCurrentReportId';

// For easier debugging and development, when we are in web we expose Onyx to the window, so you can more easily set data into Onyx
if (window && Environment.isDevelopment()) {
Expand Down Expand Up @@ -43,6 +44,7 @@ const App = () => (
HTMLEngineProvider,
WindowDimensionsProvider,
KeyboardStateProvider,
CurrentReportIdContextProvider,
]}
>
<CustomStatusBar />
Expand Down
2 changes: 2 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ const CONST = {
},
},

RIGHT_MODAL_BACKGROUND_OVERLAY_OPACITY: 0.4,

NEW_EXPENSIFY_URL: ACTIVE_EXPENSIFY_URL,
APP_DOWNLOAD_LINKS: {
ANDROID: `https://play.google.com/store/apps/details?id=${ANDROID_PACKAGE_NAME}`,
Expand Down
9 changes: 9 additions & 0 deletions src/NAVIGATORS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This is a file containing constants for navigators loceted directly in the rootStack in AuthScreen
* The ResponsiveStackNavigatur displays stack differently basing on these constants
* */
export default {
CENTRAL_PANE_NAVIGATOR: 'CentralPaneNavigator',
RIGHT_MODAL_NAVIGATOR: 'RightModalNavigator',
FULL_SCREEN_NAVIGATOR: 'FullScreenNavigator',
};
2 changes: 1 addition & 1 deletion src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
NEW_GROUP: 'new/group',
NEW_CHAT: 'new/chat',
REPORT,
REPORT_WITH_ID: 'r/:reportID',
REPORT_WITH_ID: 'r/:reportID?',
getReportRoute: reportID => `r/${reportID}`,
SELECT_YEAR: 'select-year',
getYearSelectionRoute: (minYear, maxYear, currYear, backTo) => `select-year?min=${minYear}&max=${maxYear}&year=${currYear}&backTo=${backTo}`,
Expand Down
2 changes: 1 addition & 1 deletion src/components/BlockingViews/BlockingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const BlockingView = props => (
{props.shouldShowBackHomeLink
? (
<TextLink
onPress={() => Navigation.dismissModal(true)}
onPress={Navigation.goBack}
style={[styles.link, styles.mt2]}
>
{props.link}
Expand Down
85 changes: 85 additions & 0 deletions src/components/FlatList/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React, {forwardRef} from 'react';
import {FlatList} from 'react-native';
import PropTypes from 'prop-types';

const propTypes = {
/** Same as for FlatList */
onScroll: PropTypes.func,

/** Same as for FlatList */
onLayout: PropTypes.func,

/** Same as for FlatList */
// eslint-disable-next-line react/forbid-prop-types
maintainVisibleContentPosition: PropTypes.object,

/** Passed via forwardRef so we can access the FlatList ref */
innerRef: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({current: PropTypes.instanceOf(FlatList)}),
]).isRequired,
};

const defaultProps = {
/** Same as for FlatList */
onScroll: undefined,

/** Same as for FlatList */
onLayout: undefined,

/** Same as for FlatList */
maintainVisibleContentPosition: undefined,
};

// FlatList wrapped with the freeze component will lose its scroll state when frozen (only for Android).
// CustomFlatList saves the offset and use it for scrollToOffset() when unfrozen.
function CustomFlatList(props) {
const contentOffsetRef = React.useRef(null);
const isHidden = React.useRef(false);
const [ready, setReady] = React.useState(true);

const handleOnScroll = (event) => {
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 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);
}
}
};

return (
<FlatList
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={props.innerRef}
onScroll={handleOnScroll}
onLayout={handleOnLayout}
maintainVisibleContentPosition={ready ? props.maintainVisibleContentPosition : undefined}
/>
);
}

CustomFlatList.propTypes = propTypes;
CustomFlatList.defaultProps = defaultProps;

// eslint-disable-next-line react/jsx-props-no-spreading
export default forwardRef((props, ref) => <CustomFlatList {...props} innerRef={ref} />);
3 changes: 3 additions & 0 deletions src/components/FlatList/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {FlatList} from 'react-native';

export default FlatList;
3 changes: 2 additions & 1 deletion src/components/InvertedFlatList/BaseInvertedFlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import _ from 'underscore';
import React, {forwardRef, Component} from 'react';
import PropTypes from 'prop-types';
import {FlatList, View} from 'react-native';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This caused a minor type console error - #20591

import {View} from 'react-native';
import * as CollectionUtils from '../../libs/CollectionUtils';
import FlatList from '../FlatList';

const propTypes = {
/** Same as FlatList can be any array of anything */
Expand Down
4 changes: 0 additions & 4 deletions src/components/LHNOptionsList/LHNOptionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const propTypes = {
/** Toggle between compact and default view of the option */
optionMode: PropTypes.oneOf(_.values(CONST.OPTION_MODE)).isRequired,

/** Callback to execute when the SectionList lays out */
onLayout: PropTypes.func.isRequired,

/** Whether to allow option focus or not */
shouldDisableFocusOptions: PropTypes.bool,
};
Expand Down Expand Up @@ -99,7 +96,6 @@ class LHNOptionsList extends Component {
initialNumToRender={5}
maxToRenderPerBatch={5}
windowSize={5}
onLayout={this.props.onLayout}
/>
</View>
);
Expand Down
69 changes: 69 additions & 0 deletions src/components/withCurrentReportId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, {createContext, forwardRef} from 'react';
import PropTypes from 'prop-types';

import getComponentDisplayName from '../libs/getComponentDisplayName';
import Navigation from '../libs/Navigation/Navigation';

const CurrentReportIdContext = createContext(null);

const withCurrentReportIdPropTypes = {
/** Actual content wrapped by this component */
children: PropTypes.node.isRequired,
};

class CurrentReportIdContextProvider extends React.Component {
constructor(props) {
super(props);

this.state = {
currentReportId: '',
};
}

/**
* The context this component exposes to child components
* @returns {object} currentReportId to share between central pane and drawer
*/
getContextValue() {
return {
updateCurrentReportId: this.updateCurrentReportId.bind(this),
currentReportId: this.state.currentReportId,
};
}

/**
* @param {Object} state
* @returns {String}
*/
updateCurrentReportId(state) {
return this.setState({currentReportId: Navigation.getTopmostReportId(state)});
}

render() {
return (
<CurrentReportIdContext.Provider value={this.getContextValue()}>
{this.props.children}
</CurrentReportIdContext.Provider>
);
}
}

CurrentReportIdContextProvider.propTypes = withCurrentReportIdPropTypes;

export default function withCurrentReportId(WrappedComponent) {
const WithCurrentReportId = forwardRef((props, ref) => (
<CurrentReportIdContext.Consumer>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
{translateUtils => <WrappedComponent {...translateUtils} {...props} ref={ref} />}
</CurrentReportIdContext.Consumer>
));

WithCurrentReportId.displayName = `withCurrentReportId(${getComponentDisplayName(WrappedComponent)})`;

return WithCurrentReportId;
}

export {
withCurrentReportIdPropTypes,
CurrentReportIdContextProvider,
};
42 changes: 0 additions & 42 deletions src/components/withDrawerState.js

This file was deleted.

Loading
Loading