2021-11-11 14:32:56 +00:00
|
|
|
import { NavigationContainer } from '@react-navigation/native';
|
2022-07-07 15:05:58 +00:00
|
|
|
import { createStackNavigator } from '@react-navigation/stack';
|
2022-05-06 09:20:22 +00:00
|
|
|
import React, { useCallback } from 'react';
|
2021-11-11 14:32:56 +00:00
|
|
|
|
2022-01-25 12:55:57 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { DialInSummary } from '../../../invite';
|
2022-10-28 10:07:58 +00:00
|
|
|
import Prejoin from '../../../prejoin/components/native/Prejoin';
|
2022-07-28 07:28:29 +00:00
|
|
|
import WelcomePage from '../../../welcome/components/WelcomePage';
|
2022-06-16 09:49:07 +00:00
|
|
|
import { isWelcomePageEnabled } from '../../../welcome/functions';
|
2022-05-06 09:20:22 +00:00
|
|
|
import { _ROOT_NAVIGATION_READY } from '../actionTypes';
|
2022-01-25 12:55:57 +00:00
|
|
|
import { rootNavigationRef } from '../rootNavigationContainerRef';
|
|
|
|
import { screen } from '../routes';
|
2021-11-11 14:32:56 +00:00
|
|
|
import {
|
2022-06-16 09:49:07 +00:00
|
|
|
conferenceNavigationContainerScreenOptions,
|
|
|
|
connectingScreenOptions,
|
2021-11-11 14:32:56 +00:00
|
|
|
dialInSummaryScreenOptions,
|
2022-06-16 09:49:07 +00:00
|
|
|
navigationContainerTheme,
|
2022-07-28 07:28:29 +00:00
|
|
|
preJoinScreenOptions,
|
|
|
|
welcomeScreenOptions
|
2022-01-25 12:55:57 +00:00
|
|
|
} from '../screenOptions';
|
2021-11-11 14:32:56 +00:00
|
|
|
|
2022-03-17 14:13:58 +00:00
|
|
|
import ConnectingPage from './ConnectingPage';
|
2022-01-25 12:55:57 +00:00
|
|
|
import ConferenceNavigationContainer
|
|
|
|
from './conference/components/ConferenceNavigationContainer';
|
2021-11-11 14:32:56 +00:00
|
|
|
|
2022-07-07 15:05:58 +00:00
|
|
|
const RootStack = createStackNavigator();
|
2021-11-11 14:32:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
2022-05-06 09:20:22 +00:00
|
|
|
/**
|
|
|
|
* Redux dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
2021-11-11 14:32:56 +00:00
|
|
|
/**
|
|
|
|
* Is welcome page available?
|
|
|
|
*/
|
|
|
|
isWelcomePageAvailable: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-06 09:20:22 +00:00
|
|
|
const RootNavigationContainer = ({ dispatch, isWelcomePageAvailable }: Props) => {
|
2022-03-21 16:23:57 +00:00
|
|
|
const initialRouteName = isWelcomePageAvailable
|
2022-07-28 07:28:29 +00:00
|
|
|
? screen.welcome.main : screen.connecting;
|
2022-05-06 09:20:22 +00:00
|
|
|
const onReady = useCallback(() => {
|
|
|
|
dispatch({
|
|
|
|
type: _ROOT_NAVIGATION_READY,
|
|
|
|
ready: true
|
|
|
|
});
|
|
|
|
}, [ dispatch ]);
|
2022-03-21 16:23:57 +00:00
|
|
|
|
|
|
|
return (
|
2022-05-06 10:18:57 +00:00
|
|
|
<NavigationContainer
|
|
|
|
independent = { true }
|
2022-05-06 09:20:22 +00:00
|
|
|
onReady = { onReady }
|
2022-05-06 10:18:57 +00:00
|
|
|
ref = { rootNavigationRef }
|
|
|
|
theme = { navigationContainerTheme }>
|
|
|
|
<RootStack.Navigator
|
|
|
|
initialRouteName = { initialRouteName }>
|
|
|
|
{
|
|
|
|
isWelcomePageAvailable
|
|
|
|
&& <>
|
|
|
|
<RootStack.Screen
|
2022-07-28 07:28:29 +00:00
|
|
|
component = { WelcomePage }
|
|
|
|
name = { screen.welcome.main }
|
|
|
|
options = { welcomeScreenOptions } />
|
2022-05-06 10:18:57 +00:00
|
|
|
<RootStack.Screen
|
|
|
|
component = { DialInSummary }
|
|
|
|
name = { screen.dialInSummary }
|
|
|
|
options = { dialInSummaryScreenOptions } />
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
<RootStack.Screen
|
|
|
|
component = { ConnectingPage }
|
|
|
|
name = { screen.connecting }
|
2022-06-16 09:49:07 +00:00
|
|
|
options = { connectingScreenOptions } />
|
|
|
|
<RootStack.Screen
|
|
|
|
component = { Prejoin }
|
|
|
|
name = { screen.preJoin }
|
|
|
|
options = { preJoinScreenOptions } />
|
2022-05-06 10:18:57 +00:00
|
|
|
<RootStack.Screen
|
|
|
|
component = { ConferenceNavigationContainer }
|
|
|
|
name = { screen.conference.root }
|
2022-06-16 09:49:07 +00:00
|
|
|
options = { conferenceNavigationContainerScreenOptions } />
|
2022-05-06 10:18:57 +00:00
|
|
|
</RootStack.Navigator>
|
|
|
|
</NavigationContainer>
|
2022-03-21 16:23:57 +00:00
|
|
|
);
|
|
|
|
};
|
2021-11-11 14:32:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux store to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state: Object) {
|
|
|
|
return {
|
2022-06-16 09:49:07 +00:00
|
|
|
isWelcomePageAvailable: isWelcomePageEnabled(state)
|
2021-11-11 14:32:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(RootNavigationContainer);
|