Skip to content

Commit

Permalink
address comment issues
Browse files Browse the repository at this point in the history
  • Loading branch information
staszekscp committed May 16, 2023
1 parent 01f20aa commit cc216e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions patches/@react-navigation+stack+6.3.16.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ index 1e9ee0e..d85c7b4 100644

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..5139382 100644
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,48 @@ export default class StackView extends React.Component<Props, State> {
@@ -375,29 +375,51 @@ export default class StackView extends React.Component<Props, State> {

private handleTransitionStart = (
{ route }: { route: Route<string> },
Expand All @@ -59,6 +59,7 @@ index 6bbce10..5139382 100644
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',
Expand All @@ -73,10 +74,12 @@ index 6bbce10..5139382 100644
+ { route }: { route: Route<string> },
+ state: StackNavigationState<ParamListBase>
+ ) => {
+ 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',
Expand Down
8 changes: 4 additions & 4 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ReportScreen extends React.Component {
skeletonViewContainerHeight: reportActionsListViewHeight,
isBannerVisible: true,
animationFinished: false,
screenDisappeared: false,
isScreenBlurred: false,
};
}

Expand All @@ -163,11 +163,11 @@ class ReportScreen extends React.Component {

// 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({screenDisappeared: e.data.closing});
this.setState({isScreenBlurred: e.data.closing});
});

this.gestureStartListener = this.props.navigation.getParent().addListener('gestureStart', () => {
this.setState({screenDisappeared: false});
this.setState({isScreenBlurred: false});
});
}

Expand Down Expand Up @@ -260,7 +260,7 @@ 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 isVisible = this.props.isFocused || !this.state.screenDisappeared;
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;
Expand Down
9 changes: 5 additions & 4 deletions src/pages/home/sidebar/SidebarLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,20 @@ class SidebarLinks extends React.Component {
}

this.state = {
screenDisappeared: false,
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({screenDisappeared: e.data.closing});
this.setState({isScreenBlurred: e.data.closing});
});

this.gestureStartListener = this.props.navigation.addListener('gestureStart', () => {
this.setState({screenDisappeared: false});
this.setState({isScreenBlurred: false});
});
}

Expand Down Expand Up @@ -161,7 +162,7 @@ class SidebarLinks extends React.Component {

render() {
const isLoading = _.isEmpty(this.props.personalDetails) || _.isEmpty(this.props.chatReports);
const isVisible = this.props.isFocused || !this.state.screenDisappeared;
const isVisible = this.props.isFocused || !this.state.isScreenBlurred;
const shouldFreeze = this.props.isSmallScreenWidth && this.isSidebarLoaded && !isVisible;
const optionListItems = SidebarUtils.getOrderedReportIDs(this.props.reportIDFromRoute);

Expand Down

0 comments on commit cc216e9

Please sign in to comment.