Changed tab order and stacks

This commit is contained in:
Arnaud Vergnet 2020-04-21 12:59:36 +02:00
parent 3b977bdf64
commit 77cc5d8746
5 changed files with 93 additions and 93 deletions

View file

@ -37,22 +37,6 @@ class ActionsDashBoardItem extends React.Component<Props> {
onPress={() => this.props.navigation.navigate("amicale-home")} onPress={() => this.props.navigation.navigate("amicale-home")}
style={styles.list} style={styles.list}
/> />
<List.Item
title={"STUDENT WEBSITES"}
description={"TROP COOL"}
left={props => <List.Icon {...props} icon="web"/>}
right={props => <List.Icon {...props} icon="chevron-right"/>}
onPress={() => this.props.navigation.navigate("websites-home")}
style={styles.list}
/>
<List.Item
title={"SERVICES INSA"}
description={"TROP BIEN"}
left={props => <List.Icon {...props} icon="star"/>}
right={props => <List.Icon {...props} icon="chevron-right"/>}
onPress={() => this.props.navigation.navigate("insa-home")}
style={styles.list}
/>
</Card> </Card>
); );
} }

View file

@ -18,9 +18,9 @@ type State = {
} }
const TAB_ICONS = { const TAB_ICONS = {
planning: 'calendar-range',
proxiwash: 'tshirt-crew', proxiwash: 'tshirt-crew',
proximo: 'cart', students: 'account-circle',
insa: 'book',
planex: 'clock', planex: 'clock',
}; };

View file

@ -51,6 +51,7 @@ const screenTransition = Platform.OS === 'ios' ? TransitionPresets.SlideFromRigh
function createScreenCollapsibleStack( function createScreenCollapsibleStack(
name: string, name: string,
Stack: any,
component: any, component: any,
title: string, title: string,
useNativeDriver?: boolean, useNativeDriver?: boolean,
@ -58,7 +59,7 @@ function createScreenCollapsibleStack(
const {colors} = useTheme(); const {colors} = useTheme();
const screenOptions = options != null ? options : {}; const screenOptions = options != null ? options : {};
return createCollapsibleStack( return createCollapsibleStack(
<HomeStack.Screen <Stack.Screen
name={name} name={name}
component={component} component={component}
options={{ options={{
@ -76,29 +77,41 @@ function createScreenCollapsibleStack(
) )
} }
function getWebsiteStack(name: string, component: any, title: string) { function getWebsiteStack(name: string, Stack: any, component: any, title: string) {
return createScreenCollapsibleStack(name, component, title, false); return createScreenCollapsibleStack(name, Stack, component, title, false);
} }
const ProximoStack = createStackNavigator(); const StudentsStack = createStackNavigator();
function ProximoStackComponent() { function StudentsStackComponent() {
return ( return (
<ProximoStack.Navigator <StudentsStack.Navigator
initialRouteName="index" initialRouteName="index"
headerMode={"screen"} headerMode={"screen"}
screenOptions={defaultScreenOptions} screenOptions={defaultScreenOptions}
> >
{createScreenCollapsibleStack("index", ProximoMainScreen, "Proximo")} <StudentsStack.Screen
name="index"
component={WebsitesHomeScreen}
options={{
title: "WEBSITES HOME",
}}
/>
{getWebsiteStack("amicale-website", StudentsStack, AmicaleWebsiteScreen, "Amicale")}
{getWebsiteStack("elus-etudiants", StudentsStack, ElusEtudiantsWebsiteScreen, "Élus Étudiants")}
{getWebsiteStack("wiketud", StudentsStack, WiketudWebsiteScreen, "Wiketud")}
{getWebsiteStack("tutorinsa", StudentsStack, TutorInsaWebsiteScreen, "Tutor'INSA")}
{createScreenCollapsibleStack("proximo", StudentsStack, ProximoMainScreen, "Proximo")}
{createScreenCollapsibleStack( {createScreenCollapsibleStack(
"proximo-list", "proximo-list",
StudentsStack,
ProximoListScreen, ProximoListScreen,
i18n.t('screens.proximoArticles'), i18n.t('screens.proximoArticles'),
true, true,
{...screenTransition}, {...screenTransition},
)} )}
<ProximoStack.Screen <StudentsStack.Screen
name="proximo-about" name="proximo-about"
component={ProximoAboutScreen} component={ProximoAboutScreen}
options={{ options={{
@ -106,7 +119,22 @@ function ProximoStackComponent() {
...modalTransition, ...modalTransition,
}} }}
/> />
</ProximoStack.Navigator> <StudentsStack.Screen
name="planning"
component={PlanningScreen}
options={{
title: i18n.t('screens.planning'),
}}
/>
<StudentsStack.Screen
name="planning-information"
component={PlanningDisplayScreen}
options={{
title: i18n.t('screens.planningDisplayScreen'),
...modalTransition,
}}
/>
</StudentsStack.Navigator>
); );
} }
@ -119,7 +147,7 @@ function ProxiwashStackComponent() {
headerMode={"screen"} headerMode={"screen"}
screenOptions={defaultScreenOptions} screenOptions={defaultScreenOptions}
> >
{createScreenCollapsibleStack("index", ProxiwashScreen, i18n.t('screens.proxiwash'))} {createScreenCollapsibleStack("index", ProxiwashStack, ProxiwashScreen, i18n.t('screens.proxiwash'))}
<ProxiwashStack.Screen <ProxiwashStack.Screen
name="proxiwash-about" name="proxiwash-about"
component={ProxiwashAboutScreen} component={ProxiwashAboutScreen}
@ -132,31 +160,26 @@ function ProxiwashStackComponent() {
); );
} }
const PlanningStack = createStackNavigator(); const InsaStack = createStackNavigator();
function PlanningStackComponent() { function InsaStackComponent() {
return ( return (
<PlanningStack.Navigator <InsaStack.Navigator
initialRouteName="index" initialRouteName="index"
headerMode={"screen"} headerMode={"screen"}
screenOptions={defaultScreenOptions} screenOptions={defaultScreenOptions}
> >
<PlanningStack.Screen <InsaStack.Screen
name="index" name="index"
component={PlanningScreen} component={InsaHomeScreen}
options={{ options={{
title: i18n.t('screens.planning'), title: "INSA HOME",
}} }}
/> />
<PlanningStack.Screen {getWebsiteStack("available-rooms", InsaStack, AvailableRoomScreen, i18n.t('screens.availableRooms'))}
name="planning-information" {getWebsiteStack("bib", InsaStack, BibScreen, i18n.t('screens.bib'))}
component={PlanningDisplayScreen} {createScreenCollapsibleStack("self-menu", InsaStack, SelfMenuScreen, i18n.t('screens.menuSelf'))}
options={{ </InsaStack.Navigator>
title: i18n.t('screens.planningDisplayScreen'),
...modalTransition,
}}
/>
</PlanningStack.Navigator>
); );
} }
@ -190,14 +213,6 @@ function HomeStackComponent(initialRoute: string | null, defaultData: { [key: st
useNativeDriver: true, useNativeDriver: true,
} }
)} )}
<HomeStack.Screen
name="home-planning-information"
component={PlanningDisplayScreen}
options={{
title: i18n.t('screens.planningDisplayScreen'),
...modalTransition,
}}
/>
<HomeStack.Screen <HomeStack.Screen
name="feed-information" name="feed-information"
component={FeedItemScreen} component={FeedItemScreen}
@ -214,15 +229,14 @@ function HomeStackComponent(initialRoute: string | null, defaultData: { [key: st
...modalTransition, ...modalTransition,
}} }}
/> />
<HomeStack.Screen
name="home-planning-information"
{createScreenCollapsibleStack("self-menu", SelfMenuScreen, i18n.t('screens.menuSelf'))} component={PlanningDisplayScreen}
{getWebsiteStack("available-rooms", AvailableRoomScreen, i18n.t('screens.availableRooms'))} options={{
{getWebsiteStack("bib", BibScreen, i18n.t('screens.bib'))} title: i18n.t('screens.planningDisplayScreen'),
{getWebsiteStack("amicale-website", AmicaleWebsiteScreen, "Amicale")} ...modalTransition,
{getWebsiteStack("elus-etudiants", ElusEtudiantsWebsiteScreen, "Élus Étudiants")} }}
{getWebsiteStack("wiketud", WiketudWebsiteScreen, "Wiketud")} />
{getWebsiteStack("tutorinsa", TutorInsaWebsiteScreen, "Tutor'INSA")}
<HomeStack.Screen <HomeStack.Screen
name="tetris" name="tetris"
component={TetrisScreen} component={TetrisScreen}
@ -244,7 +258,7 @@ function HomeStackComponent(initialRoute: string | null, defaultData: { [key: st
title: i18n.t('screens.profile'), title: i18n.t('screens.profile'),
}} }}
/> />
{createScreenCollapsibleStack("club-list", ClubListScreen, i18n.t('clubs.clubList'))} {createScreenCollapsibleStack("club-list", HomeStack, ClubListScreen, i18n.t('clubs.clubList'))}
<HomeStack.Screen <HomeStack.Screen
name="club-information" name="club-information"
component={ClubDisplayScreen} component={ClubDisplayScreen}
@ -282,20 +296,6 @@ function HomeStackComponent(initialRoute: string | null, defaultData: { [key: st
title: "AMICALE HOME", title: "AMICALE HOME",
}} }}
/> />
<HomeStack.Screen
name="websites-home"
component={WebsitesHomeScreen}
options={{
title: "WEBSITES HOME",
}}
/>
<HomeStack.Screen
name="insa-home"
component={InsaHomeScreen}
options={{
title: "INSA HOME",
}}
/>
</HomeStack.Navigator> </HomeStack.Navigator>
); );
} }
@ -309,9 +309,10 @@ function PlanexStackComponent() {
headerMode={"screen"} headerMode={"screen"}
screenOptions={defaultScreenOptions} screenOptions={defaultScreenOptions}
> >
{getWebsiteStack("index", PlanexScreen, "Planex")} {getWebsiteStack("index", PlanexStack, PlanexScreen, "Planex")}
{createScreenCollapsibleStack( {createScreenCollapsibleStack(
"group-select", "group-select",
PlanexStack,
GroupSelectionScreen, GroupSelectionScreen,
"GROUP SELECT", "GROUP SELECT",
true, true,
@ -348,26 +349,28 @@ export default class TabNavigator extends React.Component<Props> {
tabBar={props => <CustomTabBar {...props} />} tabBar={props => <CustomTabBar {...props} />}
> >
<Tab.Screen <Tab.Screen
name="proximo" name="proxiwash"
option component={ProxiwashStackComponent}
component={ProximoStackComponent} options={{title: i18n.t('screens.proxiwash')}}
options={{title: i18n.t('screens.proximo')}}
/> />
<Tab.Screen <Tab.Screen
name="planning" name="students"
component={PlanningStackComponent} option
options={{title: i18n.t('screens.planning')}} component={StudentsStackComponent}
options={{title: "ETUDIANTS"}}
/> />
<Tab.Screen <Tab.Screen
name="home" name="home"
component={this.createHomeStackComponent} component={this.createHomeStackComponent}
options={{title: i18n.t('screens.home')}} options={{title: i18n.t('screens.home')}}
/> />
<Tab.Screen <Tab.Screen
name="proxiwash" name="insa"
component={ProxiwashStackComponent} component={InsaStackComponent}
options={{title: i18n.t('screens.proxiwash')}} options={{title: "INSA"}}
/> />
<Tab.Screen <Tab.Screen
name="planex" name="planex"
component={PlanexStackComponent} component={PlanexStackComponent}

View file

@ -103,11 +103,13 @@ class HomeScreen extends React.Component<Props> {
colors: Object; colors: Object;
fabRef: { current: null | AnimatedFAB }; fabRef: { current: null | AnimatedFAB };
currentNewFeed: Array<feedItem>;
constructor(props) { constructor(props) {
super(props); super(props);
this.colors = props.theme.colors; this.colors = props.theme.colors;
this.fabRef = React.createRef(); this.fabRef = React.createRef();
this.currentNewFeed = [];
} }
/** /**
@ -174,12 +176,10 @@ class HomeScreen extends React.Component<Props> {
*/ */
createDataset = (fetchedData: rawDashboard) => { createDataset = (fetchedData: rawDashboard) => {
// fetchedData = DATA; // fetchedData = DATA;
let newsData = []; let dashboardData;
let dashboardData = []; if (fetchedData.news_feed != null) {
if (fetchedData.news_feed != null) this.currentNewFeed = fetchedData.news_feed.data;
newsData = fetchedData.news_feed.data; }
else
newsData = [];
if (fetchedData.dashboard != null) if (fetchedData.dashboard != null)
dashboardData = this.generateDashboardDataset(fetchedData.dashboard); dashboardData = this.generateDashboardDataset(fetchedData.dashboard);
else else
@ -192,7 +192,7 @@ class HomeScreen extends React.Component<Props> {
}, },
{ {
title: i18n.t('homeScreen.newsFeed'), title: i18n.t('homeScreen.newsFeed'),
data: newsData, data: this.currentNewFeed,
id: SECTIONS_ID[1] id: SECTIONS_ID[1]
} }
]; ];
@ -256,6 +256,7 @@ class HomeScreen extends React.Component<Props> {
id: 'event', id: 'event',
content: dashboardData == null ? [] : dashboardData.today_events content: dashboardData == null ? [] : dashboardData.today_events
}, },
]; ];
} }

View file

@ -51,6 +51,18 @@ class WebsitesHomeScreen extends React.Component<Props, State> {
> >
WIKETUD WIKETUD
</Button> </Button>
<Button
icon={"information"}
onPress={() => nav.navigate("proximo")}
>
PROXIMO
</Button>
<Button
icon={"information"}
onPress={() => nav.navigate("planning")}
>
PLANNING
</Button>
</ScrollView> </ScrollView>
); );
} }