fix(rn,dialin-summary) simplify navigation

Only havee the screen in the hierarchy if we have a welcome page, since
it's the only way to access it.

Use goBack() from the navigator directly and avoid duplicating all props
to the screen.
This commit is contained in:
Saúl Ibarra Corretgé 2022-05-03 10:47:15 +02:00 committed by Saúl Ibarra Corretgé
parent 9dd44fc48e
commit fe7327cd21
3 changed files with 27 additions and 41 deletions

View File

@ -1,6 +1,6 @@
// @flow // @flow
import React, { Component } from 'react'; import React, { PureComponent } from 'react';
import { Linking, Platform, View } from 'react-native'; import { Linking, Platform, View } from 'react-native';
import { WebView } from 'react-native-webview'; import { WebView } from 'react-native-webview';
import { type Dispatch } from 'redux'; import { type Dispatch } from 'redux';
@ -13,8 +13,6 @@ import { LoadingIndicator } from '../../../../base/react';
import { connect } from '../../../../base/redux'; import { connect } from '../../../../base/redux';
import HeaderNavigationButton import HeaderNavigationButton
from '../../../../mobile/navigation/components/HeaderNavigationButton'; from '../../../../mobile/navigation/components/HeaderNavigationButton';
import { navigateRoot } from '../../../../mobile/navigation/rootNavigationContainerRef';
import { screen } from '../../../../mobile/navigation/routes';
import { getDialInfoPageURLForURIString } from '../../../functions'; import { getDialInfoPageURLForURIString } from '../../../functions';
import DialInSummaryErrorDialog from './DialInSummaryErrorDialog'; import DialInSummaryErrorDialog from './DialInSummaryErrorDialog';
@ -43,7 +41,7 @@ type Props = {
/** /**
* Implements a React native component that displays the dial in info page for a specific room. * Implements a React native component that displays the dial in info page for a specific room.
*/ */
class DialInSummary extends Component<Props> { class DialInSummary extends PureComponent<Props> {
/** /**
* Initializes a new instance. * Initializes a new instance.
@ -53,7 +51,6 @@ class DialInSummary extends Component<Props> {
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);
this._onNavigateToRoot = this._onNavigateToRoot.bind(this);
this._onError = this._onError.bind(this); this._onError = this._onError.bind(this);
this._onNavigate = this._onNavigate.bind(this); this._onNavigate = this._onNavigate.bind(this);
this._renderLoading = this._renderLoading.bind(this); this._renderLoading = this._renderLoading.bind(this);
@ -68,6 +65,9 @@ class DialInSummary extends Component<Props> {
*/ */
componentDidMount() { componentDidMount() {
const { navigation, t } = this.props; const { navigation, t } = this.props;
const onNavigationClose = () => {
navigation.goBack();
};
navigation.setOptions({ navigation.setOptions({
headerLeft: () => { headerLeft: () => {
@ -75,13 +75,15 @@ class DialInSummary extends Component<Props> {
return ( return (
<HeaderNavigationButton <HeaderNavigationButton
label = { t('dialog.close') } label = { t('dialog.close') }
onPress = { this._onNavigateToRoot } /> // eslint-disable-next-line react/jsx-no-bind
onPress = { onNavigationClose } />
); );
} }
return ( return (
<HeaderNavigationButton <HeaderNavigationButton
onPress = { this._onNavigateToRoot } // eslint-disable-next-line react/jsx-no-bind
onPress = { onNavigationClose }
src = { IconClose } /> src = { IconClose } />
); );
} }
@ -112,17 +114,6 @@ class DialInSummary extends Component<Props> {
); );
} }
_onNavigateToRoot: () => void;
/**
* Callback to handle navigation back to root.
*
* @returns {void}
*/
_onNavigateToRoot() {
navigateRoot(screen.root);
}
_onError: () => void; _onError: () => void;
/** /**

View File

@ -45,10 +45,16 @@ const RootNavigationContainer = ({ isWelcomePageAvailable }: Props) => {
initialRouteName = { initialRouteName }> initialRouteName = { initialRouteName }>
{ {
isWelcomePageAvailable isWelcomePageAvailable
&& <RootStack.Screen && <>
<RootStack.Screen
component = { WelcomePageNavigationContainer } component = { WelcomePageNavigationContainer }
name = { screen.root } name = { screen.root }
options = { drawerNavigatorScreenOptions } /> options = { drawerNavigatorScreenOptions } />
<RootStack.Screen
component = { DialInSummary }
name = { screen.dialInSummary }
options = { dialInSummaryScreenOptions } />
</>
} }
<RootStack.Screen <RootStack.Screen
component = { ConnectingPage } component = { ConnectingPage }
@ -57,10 +63,6 @@ const RootNavigationContainer = ({ isWelcomePageAvailable }: Props) => {
gestureEnabled: false, gestureEnabled: false,
headerShown: false headerShown: false
}} /> }} />
<RootStack.Screen
component = { DialInSummary }
name = { screen.dialInSummary }
options = { dialInSummaryScreenOptions } />
<RootStack.Screen <RootStack.Screen
component = { ConferenceNavigationContainer } component = { ConferenceNavigationContainer }
name = { screen.conference.root } name = { screen.conference.root }

View File

@ -43,21 +43,6 @@ export const fullScreenOptions = {
}; };
/**
* Dial-IN Info screen options and transition types.
*/
export const dialInSummaryScreenOptions = {
...TransitionPresets.ModalTransition,
gestureEnabled: true,
headerShown: true,
headerStyle: {
backgroundColor: BaseTheme.palette.screen02Header
},
headerTitleStyle: {
color: BaseTheme.palette.text01
}
};
/** /**
* Drawer navigator screens options and transition types. * Drawer navigator screens options and transition types.
*/ */
@ -203,6 +188,14 @@ export const presentationScreenOptions = {
*/ */
export const chatScreenOptions = presentationScreenOptions; export const chatScreenOptions = presentationScreenOptions;
/**
* Dial-IN Info screen options and transition types.
*/
export const dialInSummaryScreenOptions = {
...presentationScreenOptions,
headerLeft: undefined
};
/** /**
* Screen options for invite modal. * Screen options for invite modal.
*/ */