Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

RootNavigationContainer.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { NavigationContainer } from '@react-navigation/native';
  2. import { createStackNavigator } from '@react-navigation/stack';
  3. import React, { useCallback } from 'react';
  4. import { connect } from '../../../base/redux';
  5. import { DialInSummary } from '../../../invite';
  6. import Prejoin from '../../../prejoin/components/Prejoin.native';
  7. import WelcomePage from '../../../welcome/components/WelcomePage';
  8. import { isWelcomePageEnabled } from '../../../welcome/functions';
  9. import { _ROOT_NAVIGATION_READY } from '../actionTypes';
  10. import { rootNavigationRef } from '../rootNavigationContainerRef';
  11. import { screen } from '../routes';
  12. import {
  13. conferenceNavigationContainerScreenOptions,
  14. connectingScreenOptions,
  15. dialInSummaryScreenOptions,
  16. navigationContainerTheme,
  17. preJoinScreenOptions,
  18. welcomeScreenOptions
  19. } from '../screenOptions';
  20. import ConnectingPage from './ConnectingPage';
  21. import ConferenceNavigationContainer
  22. from './conference/components/ConferenceNavigationContainer';
  23. const RootStack = createStackNavigator();
  24. type Props = {
  25. /**
  26. * Redux dispatch function.
  27. */
  28. dispatch: Function,
  29. /**
  30. * Is welcome page available?
  31. */
  32. isWelcomePageAvailable: boolean
  33. }
  34. const RootNavigationContainer = ({ dispatch, isWelcomePageAvailable }: Props) => {
  35. const initialRouteName = isWelcomePageAvailable
  36. ? screen.welcome.main : screen.connecting;
  37. const onReady = useCallback(() => {
  38. dispatch({
  39. type: _ROOT_NAVIGATION_READY,
  40. ready: true
  41. });
  42. }, [ dispatch ]);
  43. return (
  44. <NavigationContainer
  45. independent = { true }
  46. onReady = { onReady }
  47. ref = { rootNavigationRef }
  48. theme = { navigationContainerTheme }>
  49. <RootStack.Navigator
  50. initialRouteName = { initialRouteName }>
  51. {
  52. isWelcomePageAvailable
  53. && <>
  54. <RootStack.Screen
  55. component = { WelcomePage }
  56. name = { screen.welcome.main }
  57. options = { welcomeScreenOptions } />
  58. <RootStack.Screen
  59. component = { DialInSummary }
  60. name = { screen.dialInSummary }
  61. options = { dialInSummaryScreenOptions } />
  62. </>
  63. }
  64. <RootStack.Screen
  65. component = { ConnectingPage }
  66. name = { screen.connecting }
  67. options = { connectingScreenOptions } />
  68. <RootStack.Screen
  69. component = { Prejoin }
  70. name = { screen.preJoin }
  71. options = { preJoinScreenOptions } />
  72. <RootStack.Screen
  73. component = { ConferenceNavigationContainer }
  74. name = { screen.conference.root }
  75. options = { conferenceNavigationContainerScreenOptions } />
  76. </RootStack.Navigator>
  77. </NavigationContainer>
  78. );
  79. };
  80. /**
  81. * Maps part of the Redux store to the props of this component.
  82. *
  83. * @param {Object} state - The Redux state.
  84. * @returns {Props}
  85. */
  86. function mapStateToProps(state: Object) {
  87. return {
  88. isWelcomePageAvailable: isWelcomePageEnabled(state)
  89. };
  90. }
  91. export default connect(mapStateToProps)(RootNavigationContainer);