-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Added transition handling between the side drawer and chats #2221
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
Merged
marcaaron
merged 48 commits into
Expensify:master
from
kidroca:kidroca/report-view-loading-state
Apr 8, 2021
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
3e91a32
refactor: convert ReportScreen to class component
kidroca 455a707
refactor: ReportScreen added drawer state
kidroca 53b65f9
feat: Loading components
kidroca 3395593
feat: ReportScreen add loading animation for content
kidroca 0c30b06
refactor: ReportScreen move loading animation to ReportView
kidroca 8252997
refactor: ReportActionsView remove extra calls to initial fetch
kidroca 0dd170b
refactor: ReportScreen extract withDrawerState HOC
kidroca 8a6df1b
refactor: withDrawerState implement with useIsDrawerOpen for simplicity
kidroca 8d89162
refactor: ReportView improve transition using drawer state
kidroca 283e6c0
refactor: ReportActionCompose remove drawer check
kidroca 4cf35fd
refactor: ReportScreen handle initial state
kidroca 7fa89be
refactor: update copy pasted display name
kidroca 96ff600
refactor: ReportScreen use reportID from route params
kidroca b2177a6
refactor: ReportScreen expand the drawer on back navigation
kidroca 2f4a7ea
feat: ReportActionCompose allow autoFocus to be configurable from par…
kidroca 073249e
refactor: ReportView optimizations
kidroca f3fea9b
refactor: ReportActionsView remove unnecessary logic around report sw…
kidroca 5d2f079
refactor: ReportActionsView remove `needsLayoutCalculation`
kidroca 199fb11
refactor: ReportActionCompose remove `withWindowDimensions` - unused
kidroca 7003ad8
feat: ReportScreen loading view layout transitions
kidroca 3396074
refactor: ReportScreen clean up comments and console.logs
kidroca fc371c0
refactor: ReportScreen restore reportID as number
kidroca b3414b6
Remove todo note, already addressed elsewhere and could cause confusion
kidroca 5ce7b33
refactor: ReportScreen remove error state
kidroca a3df62a
refactor: ReportScreen replace computed getters with methods
kidroca 809d041
Revert "feat: ReportActionCompose allow autoFocus to be configurable …
kidroca 0d50195
refactor: Address autoFocus usage and add documentation
kidroca a03f8ba
refactor: extract FullscreenLoading styles
kidroca 8184e0f
Drop: custom LoadingIndicator and use the built in ActivityIndicator
kidroca a3f92f5
drop: Remove layout animations
kidroca 0a96fa8
feat: ReportScreen don't wait for fetch just show a brief loading
kidroca 3b4a2c3
refactor: ReportActionsView remove `reset` method - no longer needed
kidroca f0d7bb5
refactor: ReportScreen move `fetchActions` call back to ReportActions…
kidroca c08d14e
refactor: ReportScreen replace comment with self explanatory code
kidroca 7847ffa
refactor: TextInputFocusable add isDisabled prop to the native compon…
kidroca a9ed45b
refactor: ReportActionCompose disable while app focus is away from th…
kidroca c5dacac
refactor: rename FullscreenLoadingIndicator
kidroca 4646f1c
refactor: ReportScreen move the full screen loader to this screen
kidroca 74eb008
refactor: add `visible` prop to loader
kidroca 7072ed6
refactor: ReportView cleanup unused styles
kidroca 9234aa8
refactor: ReportScreen restore Navigation usage
kidroca f762e41
refactor: ReportScreen remove unneeded check
kidroca 328f1ba
refactor: ReportActionsView setup unread indicator during mount
kidroca 3e5b599
refactor: ReportScreen remove navigation prop - unused
kidroca a89877c
refactor: ReportActionCompose move logic related to disabling the inp…
kidroca 2944644
Merge remote-tracking branch 'e.cash/master' into kidroca/report-view…
kidroca 64c048f
refactor: ReportScreen restore original navigation handling
kidroca db7b937
Merge remote-tracking branch 'e.cash/master' into kidroca/report-view…
kidroca 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 hidden or 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,25 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import {ActivityIndicator, StyleSheet, View} from 'react-native'; | ||
| import styles from '../styles/styles'; | ||
| import themeColors from '../styles/themes/default'; | ||
|
|
||
| const propTypes = { | ||
| /* Controls whether the loader is mounted and displayed */ | ||
| visible: PropTypes.bool.isRequired, | ||
| }; | ||
|
|
||
| /** | ||
| * Loading indication component intended to cover the whole page, while the page prepares for initial render | ||
| * | ||
| * @returns {JSX.Element} | ||
| */ | ||
| const FullScreenLoadingIndicator = ({visible}) => visible && ( | ||
| <View style={[StyleSheet.absoluteFillObject, styles.fullScreenLoading]}> | ||
| <ActivityIndicator color={themeColors.spinner} size="large" /> | ||
| </View> | ||
| ); | ||
|
|
||
| FullScreenLoadingIndicator.propTypes = propTypes; | ||
|
|
||
| export default FullScreenLoadingIndicator; |
This file contains hidden or 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 hidden or 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 hidden or 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,25 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import {useIsDrawerOpen} from '@react-navigation/drawer'; | ||
| import getComponentDisplayName from '../libs/getComponentDisplayName'; | ||
|
|
||
| export const withDrawerPropTypes = { | ||
| isDrawerOpen: PropTypes.bool.isRequired, | ||
| }; | ||
|
|
||
| export default function withDrawerState(WrappedComponent) { | ||
| const HOC_Wrapper = (props) => { | ||
| const isDrawerOpen = useIsDrawerOpen(); | ||
kidroca marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return ( | ||
| <WrappedComponent | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...props} | ||
| isDrawerOpen={isDrawerOpen} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| HOC_Wrapper.displayName = `withDrawerState(${getComponentDisplayName(WrappedComponent)})`; | ||
| return HOC_Wrapper; | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,54 +1,93 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import {withOnyx} from 'react-native-onyx'; | ||
| import {View} from 'react-native'; | ||
| import styles from '../../styles/styles'; | ||
| import ReportView from './report/ReportView'; | ||
| import ScreenWrapper from '../../components/ScreenWrapper'; | ||
| import HeaderView from './HeaderView'; | ||
| import Navigation from '../../libs/Navigation/Navigation'; | ||
| import ROUTES from '../../ROUTES'; | ||
| import ONYXKEYS from '../../ONYXKEYS'; | ||
| import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator'; | ||
|
|
||
| const propTypes = { | ||
| // id of the most recently viewed report | ||
| currentlyViewedReportID: PropTypes.string, | ||
| /* Navigation route context info provided by react navigation */ | ||
| route: PropTypes.shape({ | ||
| /* Route specific parameters used on this screen */ | ||
| params: PropTypes.shape({ | ||
| /* The ID of the report this screen should display */ | ||
| reportID: PropTypes.string, | ||
| }).isRequired, | ||
| }).isRequired, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| currentlyViewedReportID: '0', | ||
| }; | ||
| class ReportScreen extends React.Component { | ||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| const ReportScreen = (props) => { | ||
| const activeReportID = parseInt(props.currentlyViewedReportID, 10); | ||
| if (!activeReportID) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <ScreenWrapper | ||
| style={[ | ||
| styles.appContent, | ||
| styles.flex1, | ||
| styles.flexColumn, | ||
| ]} | ||
| > | ||
| <HeaderView | ||
| reportID={activeReportID} | ||
| onNavigationMenuButtonClicked={() => Navigation.navigate(ROUTES.HOME)} | ||
| /> | ||
| <View style={[styles.dFlex, styles.flex1]}> | ||
| <ReportView reportID={activeReportID} /> | ||
| </View> | ||
| </ScreenWrapper> | ||
| ); | ||
| }; | ||
| this.state = { | ||
| isLoading: true, | ||
| }; | ||
| } | ||
|
|
||
| componentDidMount() { | ||
| this.prepareTransition(); | ||
| } | ||
|
|
||
| componentDidUpdate(prevProps) { | ||
| const reportChanged = this.props.route.params.reportID !== prevProps.route.params.reportID; | ||
|
|
||
| if (reportChanged) { | ||
| this.prepareTransition(); | ||
| } | ||
| } | ||
|
|
||
| componentWillUnmount() { | ||
| clearTimeout(this.loadingTimerId); | ||
| } | ||
|
|
||
| /** | ||
| * Get the currently viewed report ID as number | ||
| * | ||
| * @returns {Number} | ||
| */ | ||
| getReportID() { | ||
| const params = this.props.route.params; | ||
| return Number.parseInt(params.reportID, 10); | ||
| } | ||
|
|
||
| /** | ||
| * When reports change there's a brief time content is not ready to be displayed | ||
| * | ||
| * @returns {Boolean} | ||
| */ | ||
| shouldShowLoader() { | ||
| return this.state.isLoading || !this.getReportID(); | ||
| } | ||
|
|
||
| /** | ||
| * Configures a small loading transition of fixed time and proceeds with rendering available data | ||
| */ | ||
| prepareTransition() { | ||
| this.setState({isLoading: true}); | ||
|
|
||
| clearTimeout(this.loadingTimerId); | ||
| this.loadingTimerId = setTimeout(() => this.setState({isLoading: false}), 300); | ||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
| <ScreenWrapper style={[styles.appContent, styles.flex1]}> | ||
| <HeaderView | ||
| reportID={this.getReportID()} | ||
| onNavigationMenuButtonClicked={() => Navigation.navigate(ROUTES.HOME)} | ||
| /> | ||
|
|
||
| <FullScreenLoadingIndicator visible={this.shouldShowLoader()} /> | ||
|
|
||
| <ReportView reportID={this.getReportID()} /> | ||
| </ScreenWrapper> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| ReportScreen.displayName = 'ReportScreen'; | ||
| ReportScreen.propTypes = propTypes; | ||
| ReportScreen.defaultProps = defaultProps; | ||
| export default withOnyx({ | ||
| currentlyViewedReportID: { | ||
| key: ONYXKEYS.CURRENTLY_VIEWED_REPORTID, | ||
| }, | ||
| })(ReportScreen); | ||
| export default ReportScreen; |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.