Skip to content

Instantly share code, notes, and snippets.

@qrobin
Created August 5, 2017 22:27
Show Gist options
  • Select an option

  • Save qrobin/d00bc4298619dcd161125a94cb09d63d to your computer and use it in GitHub Desktop.

Select an option

Save qrobin/d00bc4298619dcd161125a94cb09d63d to your computer and use it in GitHub Desktop.

Revisions

  1. QR created this gist Aug 5, 2017.
    262 changes: 262 additions & 0 deletions router.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,262 @@
    import React from 'react';
    import { StackNavigator } from 'react-navigation';
    import { Header, LeftButton, RightButton, Days } from 'atoms';
    import { Loading } from 'wrappers';
    import { goTo } from 'utils';

    import {
    // Loading
    LoadingScreen,

    // Login screens
    Guide, Login, ResetPassword,

    // Registration screens
    AskForSertificate, RegistrationStep1, RegistrationStep2, RegistrationStep3, RegistrationWOSert,

    // Application screens
    Chat, Tasks, DealsWithDocuments, Main, Options, Profile, Progress, Quizes, Settings, PasswordSettings, ProfileSettings, SecuritySettings, CallSettings, SertificateSettings
    } from 'screens';

    const AppNavigator = StackNavigator({
    LoginStack: {
    screen: (props) => <LoginStack screenProps={props} />
    },
    RegistrationStack: {
    screen: (props) => <RegistrationStack screenProps={props} />
    },
    ApplicationStack: {
    screen: (props) => <ApplicationStack screenProps={props} />
    },
    LoadingStack: {
    screen: (props) => <LoadingStack screenProps={props} />
    }
    }, {
    initialRouteName : 'LoadingStack',
    // initialRouteName : 'ApplicationStack',
    headerMode: 'none'
    });

    const LoadingStack = StackNavigator({
    LoadingScreen: {
    screen: (props) => <LoadingScreen {...props} />
    }
    }, {
    headerMode: 'none'
    });

    const LoginStack = StackNavigator({
    Login: { screen: (props) => <Login {...props} /> },
    Guide: { screen: (props) => <Guide {...props} /> },
    ResetPassword: { screen: (props) => <ResetPassword {...props} /> }
    }, {
    initialRouteName: 'Guide',
    headerMode: 'none'
    });

    const RegistrationStack = StackNavigator({
    AskForSertificate: { screen: (props) => <AskForSertificate {...props} /> },
    RegistrationWOSert: { screen: (props) => <RegistrationWOSert {...props} /> },
    RegistrationStep1: { screen: (props) => <RegistrationStep1 {...props} /> },
    RegistrationStep2: { screen: (props) => <RegistrationStep2 {...props} /> },
    RegistrationStep3: { screen: (props) => <RegistrationStep3 {...props} /> },
    Loading: { screen: (props) => <Loading {...props} /> }
    }, {
    initialRouteName : 'AskForSertificate',
    headerMode: 'none'
    });


    const ApplicationStack = StackNavigator({
    Main: {
    screen: (props) => <Main {...props} />,
    navigationOptions: {
    header: (props) => (
    <Header
    image='logo'
    rightStyle={{ top: 23 }}
    left={
    <LeftButton
    width={28}
    height={28}
    image='settings_icon'
    onPress={() => {
    goTo(props, 'Settings');
    }} />
    }
    right={<Days />}
    />
    )
    }
    },
    Chat: {
    screen: (props) => <Chat {...props} />,
    navigationOptions: {
    header: ({ navigation }) => (
    <Header
    title='Чат с консультантом'
    right={
    <RightButton
    title='Закрыть'
    onPress={() => {
    navigation.goBack();
    }} />
    }
    />
    )
    }
    },
    Tasks: {
    screen: (props) => <Tasks {...props} />,
    navigationOptions: {
    header: ({ navigation }) => (
    <Header
    title='Обращения'
    rightStyle={{ top: 23 }}
    left={
    <LeftButton
    width={14}
    height={22}
    image='back_icon'
    onPress={() => {
    navigation.goBack();
    }} />
    }
    right={<Days />}
    />
    )
    }
    },
    // Deal: {
    // screen: (props) => <Deal {...props} />
    // },
    DealsWithDocuments: {
    screen: (props) => <DealsWithDocuments {...props} />
    },
    Profile: {
    screen: (props) => <Profile {...props} />
    },
    Options: {
    screen: (props) => <Options {...props} />
    },
    // Option: {
    // screen: (props) => <Option {...props} />
    // },
    Progress: {
    screen: (props) => <Progress {...props} />
    },
    Quizes: {
    screen: (props) => <Quizes {...props} />
    },
    // Quiz: {
    // screen: (props) => <Quiz {...props} />
    // },
    Settings: {
    screen: (props) => <Settings {...props} />,
    navigationOptions: {
    header: ({ navigation }) => (
    <Header
    title='Настройки'
    right={
    <RightButton
    title='Закрыть'
    onPress={() => {
    navigation.goBack();
    }} />
    }
    />
    )
    }
    },
    PasswordSettings: {
    screen: (props) => <PasswordSettings {...props} />,
    navigationOptions: {
    header: ({ navigation }) => (
    <Header
    title='Настройки аккаунта'
    right={
    <RightButton
    title='Закрыть'
    onPress={() => {
    navigation.goBack();
    }} />
    }
    />
    )
    }
    },
    ProfileSettings: {
    screen: (props) => <ProfileSettings {...props} />,
    navigationOptions: {
    header: ({ navigation }) => (
    <Header
    title='Мой профиль'
    right={
    <RightButton
    title='Закрыть'
    onPress={() => {
    navigation.goBack();
    }} />
    }
    />
    )
    }
    },
    SecuritySettings: {
    screen: (props) => <SecuritySettings {...props} />,
    navigationOptions: {
    header: ({ navigation }) => (
    <Header
    title='Настройки аккаунта'
    right={
    <RightButton
    title='Закрыть'
    onPress={() => {
    navigation.goBack();
    }} />
    }
    />
    )
    }
    },
    CallSettings: {
    screen: (props) => <CallSettings {...props} />,
    navigationOptions: {
    header: ({ navigation }) => (
    <Header
    title='Настройки аккаунта'
    right={
    <RightButton
    title='Закрыть'
    onPress={() => {
    navigation.goBack();
    }} />
    }
    />
    )
    }
    },
    SertificateSettings: {
    screen: (props) => <SertificateSettings {...props} />,
    navigationOptions: {
    header: ({ navigation }) => (
    <Header
    title='Настройки аккаунта'
    right={
    <RightButton
    title='Закрыть'
    onPress={() => {
    navigation.goBack();
    }} />
    }
    />
    )
    }
    }
    }, {
    initialRouteName : 'Main'
    // initialRouteName : 'ProfileSettings'
    });


    export default AppNavigator;