123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- import { NavigationContainer, Theme } from '@react-navigation/native';
- import { createStackNavigator } from '@react-navigation/stack';
- import React, { useCallback } from 'react';
- import { StatusBar } from 'react-native';
- import { connect } from 'react-redux';
-
- import { IReduxState, IStore } from '../../../app/types';
- import DialInSummary from '../../../invite/components/dial-in-summary/native/DialInSummary';
- import Prejoin from '../../../prejoin/components/native/Prejoin';
- import UnsafeRoomWarning from '../../../prejoin/components/native/UnsafeRoomWarning';
- import { isUnsafeRoomWarningEnabled } from '../../../prejoin/functions';
- // eslint-disable-next-line
- // @ts-ignore
- import WelcomePage from '../../../welcome/components/WelcomePage';
- import { isWelcomePageEnabled } from '../../../welcome/functions';
- import { _ROOT_NAVIGATION_READY } from '../actionTypes';
- import { rootNavigationRef } from '../rootNavigationContainerRef';
- import { screen } from '../routes';
- import {
- conferenceNavigationContainerScreenOptions,
- connectingScreenOptions,
- dialInSummaryScreenOptions,
- navigationContainerTheme,
- preJoinScreenOptions,
- unsafeMeetingScreenOptions,
- welcomeScreenOptions
- } from '../screenOptions';
-
- import ConnectingPage from './ConnectingPage';
- import ConferenceNavigationContainer
- from './conference/components/ConferenceNavigationContainer';
-
- const RootStack = createStackNavigator();
-
-
- interface IProps {
-
- /**
- * Redux dispatch function.
- */
- dispatch: IStore['dispatch'];
-
- /**
- * Is unsafe room warning available?
- */
- isUnsafeRoomWarningAvailable: boolean;
-
- /**
- * Is welcome page available?
- */
- isWelcomePageAvailable: boolean;
- }
-
-
- const RootNavigationContainer = ({ dispatch, isUnsafeRoomWarningAvailable, isWelcomePageAvailable }: IProps) => {
- const initialRouteName = isWelcomePageAvailable
- ? screen.welcome.main : screen.connecting;
- const onReady = useCallback(() => {
- dispatch({
- type: _ROOT_NAVIGATION_READY,
- ready: true
- });
- }, [ dispatch ]);
-
- return (
- <NavigationContainer
- independent = { true }
- onReady = { onReady }
- ref = { rootNavigationRef }
- theme = { navigationContainerTheme as Theme }>
- <StatusBar
- animated = { true }
- backgroundColor = 'transparent'
- barStyle = { 'light-content' }
- translucent = { true } />
- <RootStack.Navigator
- initialRouteName = { initialRouteName }>
- {
- isWelcomePageAvailable
- && <>
- <RootStack.Screen // @ts-ignore
- component = { WelcomePage }
- name = { screen.welcome.main }
- options = { welcomeScreenOptions } />
- <RootStack.Screen
-
- // @ts-ignore
- component = { DialInSummary }
- name = { screen.dialInSummary }
- options = { dialInSummaryScreenOptions } />
- </>
- }
- <RootStack.Screen
- component = { ConnectingPage }
- name = { screen.connecting }
- options = { connectingScreenOptions } />
- <RootStack.Screen
- component = { Prejoin }
- name = { screen.preJoin }
- options = { preJoinScreenOptions } />
- {
- isUnsafeRoomWarningAvailable
- && <RootStack.Screen
- component = { UnsafeRoomWarning }
- name = { screen.unsafeRoomWarning }
- options = { unsafeMeetingScreenOptions } />
- }
- <RootStack.Screen
- component = { ConferenceNavigationContainer }
- name = { screen.conference.root }
- options = { conferenceNavigationContainerScreenOptions } />
- </RootStack.Navigator>
- </NavigationContainer>
- );
- };
-
- /**
- * Maps part of the Redux store to the props of this component.
- *
- * @param {Object} state - The Redux state.
- * @returns {IProps}
- */
- function mapStateToProps(state: IReduxState) {
- return {
- isUnsafeRoomWarningAvailable: isUnsafeRoomWarningEnabled(state),
- isWelcomePageAvailable: isWelcomePageEnabled(state)
- };
- }
-
- export default connect(mapStateToProps)(RootNavigationContainer);
|