Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

RootNavigationContainer.tsx 3.9KB

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