application-amicale/navigation/DrawerNavigator.js

207 lines
6.2 KiB
JavaScript
Raw Normal View History

// @flow
2020-03-05 10:29:15 +01:00
import * as React from 'react';
import {createDrawerNavigator} from '@react-navigation/drawer';
import TabNavigator from './MainTabNavigator';
import SettingsScreen from '../screens/SettingsScreen';
import AboutScreen from '../screens/About/AboutScreen';
import AboutDependenciesScreen from '../screens/About/AboutDependenciesScreen';
import SelfMenuScreen from '../screens/SelfMenuScreen';
import AvailableRoomScreen from "../screens/Websites/AvailableRoomScreen";
2020-03-06 09:12:56 +01:00
import BibScreen from "../screens/Websites/BibScreen";
import DebugScreen from '../screens/DebugScreen';
import Sidebar from "../components/Sidebar";
2020-03-05 10:29:15 +01:00
import {createStackNavigator, TransitionPresets} from "@react-navigation/stack";
import HeaderButton from "../components/HeaderButton";
2020-03-06 09:12:56 +01:00
const defaultScreenOptions = {
gestureEnabled: true,
cardOverlayEnabled: true,
...TransitionPresets.SlideFromRightIOS,
};
function getDrawerButton(navigation: Object) {
return (
<HeaderButton icon={'menu'} onPress={navigation.openDrawer}/>
2020-03-06 09:12:56 +01:00
);
}
2020-03-05 10:29:15 +01:00
const AboutStack = createStackNavigator();
2020-03-05 10:29:15 +01:00
function AboutStackComponent() {
return (
<AboutStack.Navigator
initialRouteName="AboutScreen"
2020-03-06 09:12:56 +01:00
headerMode="float"
screenOptions={defaultScreenOptions}
2020-03-05 10:29:15 +01:00
>
<AboutStack.Screen
name="AboutScreen"
component={AboutScreen}
2020-03-06 09:12:56 +01:00
options={({navigation}) => {
const openDrawer = getDrawerButton.bind(this, navigation);
return {
title: 'About',
headerLeft: openDrawer
};
}}
2020-03-05 10:29:15 +01:00
/>
<AboutStack.Screen
name="AboutDependenciesScreen"
component={AboutDependenciesScreen}
2020-03-06 09:12:56 +01:00
options={{
title: 'Dependencies'
}}
2020-03-05 10:29:15 +01:00
/>
<AboutStack.Screen
name="DebugScreen"
component={DebugScreen}
2020-03-06 09:12:56 +01:00
options={{
title: 'Debug'
}}
2020-03-05 10:29:15 +01:00
/>
</AboutStack.Navigator>
);
}
2020-03-06 09:12:56 +01:00
const SettingsStack = createStackNavigator();
function SettingsStackComponent() {
return (
<SettingsStack.Navigator
initialRouteName="SettingsScreen"
headerMode="float"
screenOptions={defaultScreenOptions}
>
<SettingsStack.Screen
name="SettingsScreen"
component={SettingsScreen}
options={({navigation}) => {
const openDrawer = getDrawerButton.bind(this, navigation);
return {
title: 'Settings',
headerLeft: openDrawer
};
}}
/>
</SettingsStack.Navigator>
);
}
const SelfMenuStack = createStackNavigator();
function SelfMenuStackComponent() {
return (
<SelfMenuStack.Navigator
initialRouteName="SelfMenuScreen"
headerMode="float"
screenOptions={defaultScreenOptions}
>
<SelfMenuStack.Screen
name="SelfMenuScreen"
component={SelfMenuScreen}
options={({navigation}) => {
const openDrawer = getDrawerButton.bind(this, navigation);
return {
title: 'Menu RU',
headerLeft: openDrawer
};
}}
/>
</SelfMenuStack.Navigator>
);
}
const AvailableRoomStack = createStackNavigator();
function AvailableRoomStackComponent() {
return (
<AvailableRoomStack.Navigator
initialRouteName="AvailableRoomScreen"
headerMode="float"
screenOptions={defaultScreenOptions}
>
<AvailableRoomStack.Screen
name="AvailableRoomScreen"
component={AvailableRoomScreen}
options={({navigation}) => {
const openDrawer = getDrawerButton.bind(this, navigation);
return {
title: 'Available Rooms',
headerLeft: openDrawer
};
}}
/>
</AvailableRoomStack.Navigator>
);
}
const BibStack = createStackNavigator();
function BibStackComponent() {
return (
<BibStack.Navigator
initialRouteName="BibScreen"
headerMode="float"
screenOptions={defaultScreenOptions}
>
<BibStack.Screen
name="BibScreen"
component={BibScreen}
options={({navigation}) => {
const openDrawer = getDrawerButton.bind(this, navigation);
return {
title: 'Bib',
headerLeft: openDrawer
};
}}
/>
</BibStack.Navigator>
);
}
2020-03-05 10:29:15 +01:00
const Drawer = createDrawerNavigator();
function getDrawerContent(props) {
return <Sidebar {...props}/>
2020-02-04 19:42:40 +01:00
}
2020-03-05 10:29:15 +01:00
export default function DrawerNavigator() {
return (
<Drawer.Navigator
initialRouteName={'Main'}
2020-03-06 09:12:56 +01:00
headerMode={'float'}
backBehavior={'initialRoute'}
drawerType={'front'}
drawerContent={(props) => getDrawerContent(props)}
2020-03-06 09:12:56 +01:00
screenOptions={defaultScreenOptions}
2020-03-05 10:29:15 +01:00
>
<Drawer.Screen
name="Main"
component={TabNavigator}
>
</Drawer.Screen>
<Drawer.Screen
name="SettingsScreen"
2020-03-06 09:12:56 +01:00
component={SettingsStackComponent}
2020-03-05 10:29:15 +01:00
/>
<Drawer.Screen
name="AboutScreen"
component={AboutStackComponent}
/>
<Drawer.Screen
name="SelfMenuScreen"
2020-03-06 09:12:56 +01:00
component={SelfMenuStackComponent}
2020-03-05 10:29:15 +01:00
/>
<Drawer.Screen
name="AvailableRoomScreen"
2020-03-06 09:12:56 +01:00
component={AvailableRoomStackComponent}
2020-03-05 10:29:15 +01:00
/>
2020-03-06 09:12:56 +01:00
<Drawer.Screen
name="BibScreen"
component={BibStackComponent}
/>
2020-03-06 09:12:56 +01:00
</Drawer.Navigator>
);
}