Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
9.7 kB
1
Indexable
import { RootParamList } from '../params';
import { NavigationContainer, NavigationContainerRef } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { ComponentProps, forwardRef } from 'react';
import { useTheme } from '@hooks/useTheme';
import Routes from '../routes';
import { useRemoteConfig } from '@hooks/useRemoteConfig';

const Stack = createStackNavigator<RootParamList>();
const RootStack = () => {
  const config = useRemoteConfig();

  return (
    <Stack.Navigator
      screenOptions={{
        headerShown: false,
      }}
    >
      <Stack.Screen name={Routes.Splash} component={require('@screens/splash-screen').default} />
      <Stack.Screen name={Routes.SignIn} component={require('@screens/signin-screen').default} />
      <Stack.Screen name={Routes.Welcome} component={require('@screens/welcome-screen').default} />
      <Stack.Screen
        name={Routes.InAppBrowser}
        component={require('@screens/inapp-browser-screen').default}
      />
      <Stack.Screen
        name={Routes.UserName}
        component={require('@screens/username-screen').default}
      />
      <Stack.Screen name={Routes.Email} component={require('@screens/email-screen').default} />
      <Stack.Screen
        name={Routes.PhoneNumber}
        component={require('@screens/phone-number-screen').default}
      />
      <Stack.Screen
        name={Routes.PhoneNumberConfirmation}
        component={require('@screens/phone-number-confirmation-screen').default}
      />
      <Stack.Screen
        name={Routes.CreateHandle}
        component={require('@screens/create-handle-screen').default}
      />
      <Stack.Screen name={Routes.Handle} component={require('@screens/handle-screen').default} />
      <Stack.Screen
        name={Routes.RegisteredHandle}
        component={require('@screens/registered-handle-screen').default}
      />
      <Stack.Screen
        name={Routes.Onboarding}
        component={require('@containers/AuthFlow/OnboardingScreen').default}
      />
      <Stack.Screen
        name={Routes.ResetPassword}
        component={require('@screens/reset-password-screen').default}
      />
      <Stack.Screen
        name={Routes.WelcomeInvite}
        component={require('@screens/welcome-invite-screen').default}
      />
      <Stack.Screen
        name={Routes.AuthorizedNavigator}
        component={require('./authorized-navigator').default}
      />

      {/*Explore*/}

      <Stack.Screen name={Routes.Profile} component={require('@screens/profile-screen').default} />
      <Stack.Screen
        name={Routes.ExpertsTopics}
        component={require('@screens/experts-topics-screen').default}
      />
      <Stack.Screen
        name={Routes.ProfileDetail}
        component={require('@screens/profile-details-screen').default}
      />
      <Stack.Screen
        name={Routes.AddCardDetail}
        component={require('@screens/add-card-details-screen').default}
      />
      <Stack.Screen
        name={Routes.BusyCall}
        component={require('@screens/busy-call-screen').default}
        options={{
          gestureEnabled: false,
        }}
      />
      <Stack.Screen
        name={Routes.AllAdvisors}
        component={require('@screens/all-advisors-screen').default}
      />
      <Stack.Screen
        name={Routes.RejectedCall}
        component={require('@screens/rejected-call-screen').default}
      />
      <Stack.Screen
        name={Routes.CallFeedback}
        component={require('@screens/call-feedback-screen').default}
      />

      {/*Common*/}
      <Stack.Screen
        name={Routes.StripeAccount}
        component={require('@containers/MainFlow/ProfileFlow/StripeAccountScreen').default}
      />
      <Stack.Screen
        name={Routes.StripeAccountDetails}
        component={require('@containers/MainFlow/ProfileFlow/StripeAccountDetails').default}
      />

      {/*Call*/}
      {config.FEATURES__ROLODEX_FLOW__BOTTOM_TAB_ENABLED && (
        <Stack.Screen
          name={Routes.CallList}
          component={require('@screens/call-list-screen').default}
        />
      )}

      <Stack.Screen
        name={Routes.Favorites}
        component={require('@screens/favorites-screen').default}
      />
      <Stack.Screen
        name={Routes.CallDetails}
        component={require('@screens/call-details-screen').default}
      />

      {/*Profile*/}
      <Stack.Screen
        name={Routes.AccountSettings}
        component={require('@screens/account-settings-screen').default}
      />
      <Stack.Screen
        name={Routes.EditCountry}
        component={require('@screens/edit-country-screen').default}
      />
      <Stack.Screen
        name={Routes.Language}
        component={require('@screens/language-screen').default}
      />
      <Stack.Screen
        name={Routes.Billing}
        component={require('@containers/MainFlow/ProfileFlow/EditPaymentMethodScreen').default}
      />
      <Stack.Screen
        name={Routes.EditPaymentMethod}
        component={require('@containers/MainFlow/ProfileFlow/EditPaymentMethodScreen').default}
      />
      <Stack.Screen
        name={Routes.ProfileScreenSettings}
        component={require('@screens/profile-screen-settings').default}
      />
      <Stack.Screen
        name={Routes.AddSocialLink}
        component={require('@screens/add-social-link-screen').default}
      />
      <Stack.Screen
        name={Routes.ConversationTopics}
        component={require('@screens/conversation-topics-screen').default}
      />
      <Stack.Screen
        name={Routes.AddNewTopic}
        component={require('@screens/add-new-topic-screen').default}
      />
      <Stack.Screen
        name={Routes.AddNewCategory}
        component={require('@screens/add-new-category-screen').default}
      />
      <Stack.Screen
        name={Routes.EditCategory}
        component={require('@screens/edit-category-screen').default}
        options={{ gestureEnabled: false }}
      />
      <Stack.Screen
        name={Routes.EditTopic}
        component={require('@screens/edit-topic-screen').default}
      />
      <Stack.Screen
        name={Routes.InviteFriend}
        component={require('@screens/invite-friend-screen').default}
      />
      <Stack.Screen
        name={Routes.EnterCode}
        component={require('@screens/enter-code-screen').default}
      />
      <Stack.Screen
        name={Routes.ConfirmNewAvailability}
        component={require('@screens/confim-new-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.EditAvailability}
        component={require('@screens/edit-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.HandleIntro}
        component={require('@screens/handle-intro-screen').default}
      />
      <Stack.Screen
        name={Routes.FindHandle}
        component={require('@screens/find-handle-screen').default}
      />
      <Stack.Screen
        name={Routes.EnterPhone}
        component={require('@screens/enter-phone-screen').default}
      />
      <Stack.Screen
        name={Routes.HandleSuccess}
        component={require('@screens/handle-success-screen').default}
      />
      <Stack.Screen
        name={Routes.TutorialAvailability}
        component={require('@screens/tutorial-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.Availability}
        component={require('@screens/availability-screen').default}
      />
      <Stack.Screen
        name={Routes.ChooseFeaturePhoneBoothAvailability}
        component={require('@screens/choose-feature-phonebooth-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.ChooseDateAvailability}
        component={require('@screens/choose-date-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.ChooseTimeAvailability}
        component={require('@screens/choose-time-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.ChooseOccurencyRecurringAvailability}
        component={require('@screens/choose-occurency-recurring-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.ChooseDayOfTheWeekAvailability}
        component={require('@screens/choose-day-of-the-week-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.ChooseDayOfTheWeekWeeklyAvailability}
        component={require('@screens/choose-day-of-the-week-weekly-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.ChooseDateMonthlyAvailability}
        component={require('@screens/choose-date-monthly-availability-screen').default}
      />
      <Stack.Screen
        name={Routes.EditPhoneNumber}
        component={require('@screens/edit-phone-number-screen').default}
      />
      <Stack.Screen
        name={Routes.PhoneVerification}
        component={require('@screens/phone-verification-screen').default}
      />
      <Stack.Screen
        name={Routes.UpdatePassword}
        component={require('@screens/update-password-screen').default}
      />
    </Stack.Navigator>
  );
};

export const RootNavigator = forwardRef<
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  NavigationContainerRef<any>,
  Partial<ComponentProps<typeof NavigationContainer>>
>((props, ref) => {
  const theme = useTheme();
  return (
    <NavigationContainer {...props} ref={ref} theme={theme.navigation}>
      <RootStack />
    </NavigationContainer>
  );
});
RootNavigator.displayName = 'RootNavigator';

const exitRoutes = [Routes.Welcome];
export const canExit = (routeName: string) => exitRoutes.includes(routeName as never);