import {
  NavigationContainer,
  DefaultTheme,
  DarkTheme,
} from '@react-navigation/native';
import {
  createStackNavigator,
  CardStyleInterpolators,
} from '@react-navigation/stack';
import * as React from 'react';
import { ColorSchemeName } from 'react-native';
import useModel from 'flooks';
import { useTranslation } from 'react-i18next';

//登录模块
import LoginScreen from '../login/LoginScreen';
import RegisterScreen from '../login/RegisterScreen';
import CertificationScreen from '../login/CertificationScreen';
import TransportationScreen from '../login/TransportationScreen';
import ApplyLocationScreen from '../login/ApplyLocationScreen';
import AuditResultScreen from '../login/AuditResultScreen';

import ForgetPsdScreen from '../login/ForgetPsdScreen';

//地图模块
import SearchMapScreen from '../map/SearchMapScreen';

import { LoginStackParamList } from '../types';
import LinkingConfiguration from './LinkingConfiguration';

import User from '../stores/User';

const MainStack = createStackNavigator<LoginStackParamList>();
export default function Navigation({
  colorScheme,
}: {
  colorScheme: ColorSchemeName;
}) {
  const { initialRouteName } = useModel(User, ['initialRouteName']);
  const { t } = useTranslation();
  return (
    <MainStack.Navigator
      initialRouteName={
        initialRouteName !== 'Root' ? initialRouteName : 'Login'
      }
      screenOptions={{
        cardOverlayEnabled: true,
        cardStyle: { backgroundColor: '#f2f2f2', flex: 1 },
        contentStyle: { backgroundColor: '#f2f2f2', flex: 1 },
        gestureEnabled: true,
        stackPresentation: 'push',
        cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
        headerStyle: {
          backgroundColor: '#FFC21C',
          elevation: 0,
          shadowOffset: {
            width: 0,
            height: 0,
          },
          shadowOpacity: 0,
          shadowRadius: 0,
        },
        headerTintColor: '#fff',
        headerTitleStyle: {
          fontWeight: 'bold',
        },
        headerTitleAlign: 'center',
        headerBackTitleVisible: false,
      }}
    >
      <MainStack.Screen
        name="Login"
        component={LoginScreen}
        options={{ headerShown: false }}
      />
      <MainStack.Screen
        name="Register"
        component={RegisterScreen}
        options={{ title: t('qi-shou-ke-hu-duan') }}
      />
      <MainStack.Screen
        name="Certification"
        component={CertificationScreen}
        options={{ title: t('shen-fen-ren-zheng-xin-xi') }}
      />
      <MainStack.Screen
        name="Transportation"
        component={TransportationScreen}
        options={{ title: t('song-can-jiao-tong-gong-ju-xin-xi') }}
      />
      <MainStack.Screen
        name="ApplyLocation"
        component={ApplyLocationScreen}
        options={{ title: t('xuan-ze-gong-zuo-di-dian') }}
      />
      <MainStack.Screen
        name="AuditResult"
        component={AuditResultScreen}
        options={{ title: t('qi-shou-shen-he') }}
      />

      <MainStack.Screen
        name="SearchMap"
        options={{ title: t('xuan-ze-di-dian') }}
        component={SearchMapScreen}
      />

      <MainStack.Screen
        name="ForgetPsd"
        options={{ title: '找回密码' }}
        component={ForgetPsdScreen}
      />
    </MainStack.Navigator>
  );
}
