import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { PortalProvider } from '@gorhom/portal';
import { DialogProvider } from 'context/dialog';
import { isLoggedInVar } from 'state-management/session';
import { useReactiveVar } from '@apollo/client';
import { linking } from './linking';
import { Auth, Main } from './stack';
export const Navigation: React.FC = () => {
  const isLoggedIn = useReactiveVar(isLoggedInVar);
  const stack = isLoggedIn ? <Main /> : <Auth />;
  return (
    <DialogProvider>
      <NavigationContainer linking={linking}>
        <PortalProvider>{stack}</PortalProvider>
      </NavigationContainer>
    </DialogProvider>
  );
};
