/*
* Copyright (c) 2019 - 2020 Arnaud Vergnet.
*
* This file is part of Campus INSAT.
*
* Campus INSAT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Campus INSAT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Campus INSAT. If not, see .
*/
import * as React from 'react';
import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Title, useTheme } from 'react-native-paper';
import { StyleSheet } from 'react-native';
import i18n from 'i18n-js';
import { View } from 'react-native-animatable';
import HomeScreen from '../screens/Home/HomeScreen';
import PlanningScreen from '../screens/Planning/PlanningScreen';
import PlanningDisplayScreen from '../screens/Planning/PlanningDisplayScreen';
import ProxiwashScreen from '../screens/Proxiwash/ProxiwashScreen';
import ProxiwashAboutScreen from '../screens/Proxiwash/ProxiwashAboutScreen';
import PlanexScreen from '../screens/Planex/PlanexScreen';
import AsyncStorageManager from '../managers/AsyncStorageManager';
import ClubDisplayScreen from '../screens/Amicale/Clubs/ClubDisplayScreen';
import ScannerScreen from '../screens/Home/ScannerScreen';
import FeedItemScreen from '../screens/Home/FeedItemScreen';
import GroupSelectionScreen from '../screens/Planex/GroupSelectionScreen';
import CustomTabBar from '../components/Tabbar/CustomTabBar';
import WebsitesHomeScreen from '../screens/Services/ServicesScreen';
import ServicesSectionScreen from '../screens/Services/ServicesSectionScreen';
import AmicaleContactScreen from '../screens/Amicale/AmicaleContactScreen';
import Mascot, { MASCOT_STYLE } from '../components/Mascot/Mascot';
const styles = StyleSheet.create({
header: {
flexDirection: 'row',
},
mascot: {
width: 50,
},
title: {
marginLeft: 10,
marginTop: 'auto',
marginBottom: 'auto',
},
});
const ServicesStack = createStackNavigator();
function ServicesStackComponent() {
return (
);
}
const ProxiwashStack = createStackNavigator();
function ProxiwashStackComponent() {
return (
);
}
const PlanningStack = createStackNavigator();
function PlanningStackComponent() {
return (
);
}
const HomeStack = createStackNavigator();
function HomeStackComponent(
initialRoute: string | null,
defaultData: { [key: string]: string }
) {
let params;
if (initialRoute) {
params = { data: defaultData, nextScreen: initialRoute, shouldOpen: true };
}
const { colors } = useTheme();
return (
(
{headerProps.children}
),
}}
initialParams={params}
/>
);
}
const PlanexStack = createStackNavigator();
function PlanexStackComponent() {
return (
);
}
const Tab = createBottomTabNavigator();
type PropsType = {
defaultHomeRoute: string | null;
defaultHomeData: { [key: string]: string };
};
const ICONS: {
[key: string]: {
normal: string;
focused: string;
};
} = {
services: {
normal: 'account-circle-outline',
focused: 'account-circle',
},
proxiwash: {
normal: 'tshirt-crew-outline',
focused: 'tshirt-crew',
},
home: {
normal: '',
focused: '',
},
planning: {
normal: 'calendar-range-outline',
focused: 'calendar-range',
},
planex: {
normal: 'clock-outline',
focused: 'clock',
},
};
export default class TabNavigator extends React.Component {
defaultRoute: string;
createHomeStackComponent: () => any;
constructor(props: PropsType) {
super(props);
this.defaultRoute = 'home';
if (!props.defaultHomeRoute) {
this.defaultRoute = AsyncStorageManager.getString(
AsyncStorageManager.PREFERENCES.defaultStartScreen.key
).toLowerCase();
}
this.createHomeStackComponent = () =>
HomeStackComponent(props.defaultHomeRoute, props.defaultHomeData);
}
render() {
const LABELS: {
[key: string]: string;
} = {
services: i18n.t('screens.services.title'),
proxiwash: i18n.t('screens.proxiwash.title'),
home: i18n.t('screens.home.title'),
planning: i18n.t('screens.planning.title'),
planex: i18n.t('screens.planex.title'),
};
return (
(
)}
>
);
}
}