-
Notifications
You must be signed in to change notification settings - Fork 3k
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
mountiny
merged 74 commits into
Expensify:navigation-refactor
from
adamgrzybowski:remove-drawer
Apr 22, 2023
Merged
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 6e1691b
extract modal screens to the RightModalStack
adamgrzybowski f7a1ed1
create responsive stack navigator
adamgrzybowski 17b47f8
remove drawer
adamgrzybowski 543cb76
replace BaseDrawerNavigator with ReportScreen
adamgrzybowski e87f205
add handling initial state on resize
adamgrzybowski 53cd8e1
fullScreenModalStack
adamgrzybowski 674883e
add border color for sidebar
adamgrzybowski f432729
rename WideView to ThreePaneView
adamgrzybowski 74798c0
Remove withDrawerState and isDrawerOpen (#3)
staszekscp b3d01d4
add new Navigators and adjust linking config
adamgrzybowski 8ec253d
modify Navigation.js
adamgrzybowski e26af41
use ReportScreenWrapper to set initial params and add ensureCentralPa…
adamgrzybowski b22258c
fix not working FAB on ThreePaneView
staszekscp 08c2ccc
modyfi linkTo to push instead of navigate in specified conditions
adamgrzybowski b7d2535
Revert "add getTopmostReportId"
adamgrzybowski 8d2d330
remove isModal option from the RightModalStackScreen and rename navig…
adamgrzybowski 6e46cb0
move ensuring report screen on the stack to the custom router
adamgrzybowski 3dbabdc
fix ReportSccreenWrapper reportID loading when opening directly after…
adamgrzybowski 58fbc77
add getTopmostReportId
staszekscp 298328b
improve readability
staszekscp ac7043c
fix
staszekscp e0fc4ca
fix the not found page
adamgrzybowski 8d070fb
remove isDrawerReady from pages and actions
adamgrzybowski 95dd4ee
fix rebase problems
adamgrzybowski c0e4814
wrap navigation on concierge page with useFocusEffect
adamgrzybowski b1a80a0
add firstRenderRef to the ReportScreen
adamgrzybowski e808e81
uncomment section for getting state in the linkTo
adamgrzybowski c58f0d3
fix going back sidebar behavior
staszekscp 7872b50
cleanup
staszekscp 1a71cc4
fix comment
staszekscp d98111a
Merge pull request #8 from adamgrzybowski/fix-going-back
adamgrzybowski 387820a
add optional chaining for type safety
staszekscp 3913906
add accidentally removed Select_Year in linking config
adamgrzybowski 701cd01
add proper animation for opening report screen on the android
adamgrzybowski b0f6c88
fix crashing safari
staszekscp eaf8b97
Merge branch 'navigation-refactor' into remove-drawer
adamgrzybowski 803711c
apply code suggestions
adamgrzybowski c354a4c
add animation for closing report screen
adamgrzybowski ba4ab72
remove getReportIDFromRoute helper function from /AppNavigator
adamgrzybowski b919e64
fix eslint errors in ThreePaneView and StyleUtils
adamgrzybowski 85665d1
fix fab on android
staszekscp 71b7c61
remove unused onLayout prop
staszekscp aea4187
remove unused onLayout prop
staszekscp 9c626fa
create CustomFlatList that remembers the offset when frozen
adamgrzybowski 9ce4817
fix navigating push to currently visible report screens
adamgrzybowski 3dfae04
add dismiss modal to the concierge page
adamgrzybowski 091232e
use goBack on the BlockinView and ReportScreen
adamgrzybowski 7d53900
add prop types for the ResponsiveStackNavigator
adamgrzybowski 6e501c8
add JSDocs for getTopmostReportId and CustomRouter
adamgrzybowski fbbb0d6
remove renderRightPanel function from the THreePaneView
adamgrzybowski 62b5df8
remove drawer related functions from the Navigation.js
adamgrzybowski 907ecb9
fix linting errors
adamgrzybowski 12925ce
merge navigation-refactor into remove-drawer
adamgrzybowski fab09fb
fix styles
staszekscp 90d5548
remove getNavigationModalCardStyles
staszekscp 4ff3feb
openOnAdminRoom support
staszekscp f6aabf9
fix proptypes
staszekscp 9912285
feat: testing
WoLewicki f075d79
fix: tests
WoLewicki a4100b4
fix linting errors
adamgrzybowski a84b889
add suggestes chagnes
adamgrzybowski 16f651a
Merge branch 'navigation-refactor' into remove-drawer
adamgrzybowski ef5f498
feat: another approach to heavy first render
WoLewicki 1083956
add suggested chagnes
adamgrzybowski 68e66c0
remove unnecessary isDrawerReady and isDrawerOpen
staszekscp d0fc931
apply suggested changes
staszekscp 83749b4
chore: make tests pass for now
WoLewicki 5bdfc35
rem
staszekscp 2305c61
add
staszekscp 04b5c75
add last line
staszekscp 0dde99f
Update src/libs/Navigation/Navigation.js
adamgrzybowski 66756e7
Update src/libs/Navigation/AppNavigator/Navigators/CentralPaneNavigat…
adamgrzybowski e54d869
add suggested chagnes
adamgrzybowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {FlatList} from 'react-native'; | ||
|
||
export default FlatList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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