Browse Source

Allow to open app with links to clubs and events

Arnaud Vergnet 4 years ago
parent
commit
41b9194d98

+ 67
- 4
App.js View File

5
 import LocaleManager from './src/managers/LocaleManager';
5
 import LocaleManager from './src/managers/LocaleManager';
6
 import AsyncStorageManager from "./src/managers/AsyncStorageManager";
6
 import AsyncStorageManager from "./src/managers/AsyncStorageManager";
7
 import CustomIntroSlider from "./src/components/Custom/CustomIntroSlider";
7
 import CustomIntroSlider from "./src/components/Custom/CustomIntroSlider";
8
-import {SplashScreen} from 'expo';
8
+import {Linking, SplashScreen} from 'expo';
9
 import ThemeManager from './src/managers/ThemeManager';
9
 import ThemeManager from './src/managers/ThemeManager';
10
 import {NavigationContainer} from '@react-navigation/native';
10
 import {NavigationContainer} from '@react-navigation/native';
11
 import {createStackNavigator} from '@react-navigation/stack';
11
 import {createStackNavigator} from '@react-navigation/stack';
41
     onIntroDone: Function;
41
     onIntroDone: Function;
42
     onUpdateTheme: Function;
42
     onUpdateTheme: Function;
43
 
43
 
44
+    navigatorRef: Object;
45
+
46
+    defaultRoute: Array<string>;
47
+    defaultData: Object;
48
+
49
+    createDrawerNavigator: Function;
50
+
44
     constructor() {
51
     constructor() {
45
         super();
52
         super();
46
         LocaleManager.initTranslations();
53
         LocaleManager.initTranslations();
47
         this.onIntroDone = this.onIntroDone.bind(this);
54
         this.onIntroDone = this.onIntroDone.bind(this);
48
         this.onUpdateTheme = this.onUpdateTheme.bind(this);
55
         this.onUpdateTheme = this.onUpdateTheme.bind(this);
49
         SplashScreen.preventAutoHide();
56
         SplashScreen.preventAutoHide();
57
+        this.navigatorRef = React.createRef();
58
+        this.defaultRoute = [];
59
+        this.defaultData = {};
60
+        // this.defaultRoute = ["main", "home", "club-information"];
61
+        // this.defaultData = {clubId: 0};
62
+        this.handleUrls();
63
+    }
64
+
65
+    handleUrls() {
66
+        console.log(Linking.makeUrl('main/home/club-information', {clubId: 1}));
67
+        Linking.addEventListener('url', this.onUrl);
68
+        Linking.parseInitialURLAsync().then(this.onParsedUrl);
69
+    }
70
+
71
+    onUrl = (url: string) => {
72
+        this.onParsedUrl(Linking.parse(url));
73
+    };
74
+
75
+    onParsedUrl = ({path, queryParams}: Object) => {
76
+        if (path !== null) {
77
+            let pathArray = path.split('/');
78
+            if (this.isClubInformationLink(pathArray))
79
+                this.handleClubInformationUrl(queryParams);
80
+            else if (this.isPlanningInformationLink(pathArray))
81
+                this.handlePlanningInformationUrl(queryParams);
82
+        }
83
+    };
84
+
85
+    isClubInformationLink(pathArray: Array<string>) {
86
+        return pathArray[0] === "main" && pathArray[1] === "home" && pathArray[2] === "club-information";
87
+    }
88
+
89
+    isPlanningInformationLink(pathArray: Array<string>) {
90
+        return pathArray[0] === "main" && pathArray[1] === "home" && pathArray[2] === "planning-information";
91
+    }
92
+
93
+    handleClubInformationUrl(params: Object) {
94
+        if (params !== undefined && params.clubId !== undefined) {
95
+            let id = parseInt(params.clubId);
96
+            if (!isNaN(id)) {
97
+                this.defaultRoute = ["main", "home", "club-information"];
98
+                this.defaultData = {clubId: id};
99
+            }
100
+        }
101
+    }
102
+
103
+    handlePlanningInformationUrl(params: Object) {
104
+        if (params !== undefined && params.eventId !== undefined) {
105
+            let id = parseInt(params.eventId);
106
+            if (!isNaN(id)) {
107
+                this.defaultRoute = ["main", "home", "planning-information"];
108
+                this.defaultData = {eventId: id};
109
+            }
110
+        }
50
     }
111
     }
51
 
112
 
52
     /**
113
     /**
92
         await initExpoToken();
153
         await initExpoToken();
93
         try {
154
         try {
94
             await ConnectionManager.getInstance().recoverLogin();
155
             await ConnectionManager.getInstance().recoverLogin();
95
-        } catch (e) {}
156
+        } catch (e) {
157
+        }
96
 
158
 
159
+        this.createDrawerNavigator = () => <DrawerNavigator defaultPath={this.defaultRoute} defaultData={this.defaultData}/>;
97
         this.onLoadFinished();
160
         this.onLoadFinished();
98
     }
161
     }
99
 
162
 
130
         } else {
193
         } else {
131
             return (
194
             return (
132
                 <PaperProvider theme={this.state.currentTheme}>
195
                 <PaperProvider theme={this.state.currentTheme}>
133
-                    <NavigationContainer theme={this.state.currentTheme}>
196
+                    <NavigationContainer theme={this.state.currentTheme} ref={this.navigatorRef}>
134
                         <Stack.Navigator headerMode="none">
197
                         <Stack.Navigator headerMode="none">
135
-                            <Stack.Screen name="Root" component={DrawerNavigator}/>
198
+                            <Stack.Screen name="Root" component={this.createDrawerNavigator}/>
136
                         </Stack.Navigator>
199
                         </Stack.Navigator>
137
                     </NavigationContainer>
200
                     </NavigationContainer>
138
                 </PaperProvider>
201
                 </PaperProvider>

+ 1
- 0
app.json View File

3
     "name": "Campus",
3
     "name": "Campus",
4
     "description": "Application mobile compatible Android et iOS pour l'Amicale INSA Toulouse. Grâce à cette application, vous avez facilement accès aux news du campus, aux emplois du temps, à l'état de la laverie, et bien d'autres services ! Ceci est une version Beta, Toutes les fonctionnalités ne sont pas encore implémentées, et il est possible de rencontrer quelques bugs.",
4
     "description": "Application mobile compatible Android et iOS pour l'Amicale INSA Toulouse. Grâce à cette application, vous avez facilement accès aux news du campus, aux emplois du temps, à l'état de la laverie, et bien d'autres services ! Ceci est une version Beta, Toutes les fonctionnalités ne sont pas encore implémentées, et il est possible de rencontrer quelques bugs.",
5
     "slug": "application-amicale",
5
     "slug": "application-amicale",
6
+    "scheme": "campus-insat",
6
     "privacy": "public",
7
     "privacy": "public",
7
     "platforms": [
8
     "platforms": [
8
       "ios",
9
       "ios",

+ 1
- 1
src/components/Amicale/AuthenticatedScreen.js View File

73
         if (this.errorCode === ERROR_TYPE.BAD_TOKEN) { // Token expired, logout user
73
         if (this.errorCode === ERROR_TYPE.BAD_TOKEN) { // Token expired, logout user
74
             this.connectionManager.disconnect()
74
             this.connectionManager.disconnect()
75
                 .then(() => {
75
                 .then(() => {
76
-                    this.props.navigation.navigate("LoginScreen");
76
+                    this.props.navigation.navigate("login");
77
                 });
77
                 });
78
         } else if (this.allRequestsFinished())
78
         } else if (this.allRequestsFinished())
79
             this.setState({loading: false});
79
             this.setState({loading: false});

+ 1
- 1
src/components/Amicale/LogoutDialog.js View File

19
                 .then(() => {
19
                 .then(() => {
20
                     this.props.navigation.reset({
20
                     this.props.navigation.reset({
21
                         index: 0,
21
                         index: 0,
22
-                        routes: [{name: 'Main'}],
22
+                        routes: [{name: 'main'}],
23
                     });
23
                     });
24
                     this.props.onDismiss();
24
                     this.props.onDismiss();
25
                     resolve();
25
                     resolve();

+ 1
- 1
src/components/Home/ActionsDashboardItem.js View File

21
 
21
 
22
     openDrawer = () => this.props.navigation.openDrawer();
22
     openDrawer = () => this.props.navigation.openDrawer();
23
 
23
 
24
-    gotToSettings = () => this.props.navigation.navigate("SettingsScreen");
24
+    gotToSettings = () => this.props.navigation.navigate("settings");
25
 
25
 
26
     render() {
26
     render() {
27
         return (
27
         return (

+ 17
- 17
src/components/Sidebar/Sidebar.js View File

40
         const mainData = [
40
         const mainData = [
41
             {
41
             {
42
                 name: i18n.t('screens.home'),
42
                 name: i18n.t('screens.home'),
43
-                route: "Main",
43
+                route: "main",
44
                 icon: "home",
44
                 icon: "home",
45
             },
45
             },
46
         ];
46
         ];
47
         const amicaleData = [
47
         const amicaleData = [
48
             {
48
             {
49
                 name: i18n.t('screens.login'),
49
                 name: i18n.t('screens.login'),
50
-                route: "LoginScreen",
50
+                route: "login",
51
                 icon: "login",
51
                 icon: "login",
52
                 onlyWhenLoggedOut: true,
52
                 onlyWhenLoggedOut: true,
53
                 shouldEmphasis: true,
53
                 shouldEmphasis: true,
54
             },
54
             },
55
             {
55
             {
56
                 name: i18n.t('screens.profile'),
56
                 name: i18n.t('screens.profile'),
57
-                route: "ProfileScreen",
57
+                route: "profile",
58
                 icon: "account",
58
                 icon: "account",
59
                 onlyWhenLoggedIn: true,
59
                 onlyWhenLoggedIn: true,
60
             },
60
             },
61
             {
61
             {
62
                 name: i18n.t('clubs.clubList'),
62
                 name: i18n.t('clubs.clubList'),
63
-                route: "ClubListScreen",
63
+                route: "club-list",
64
                 icon: "account-group",
64
                 icon: "account-group",
65
                 onlyWhenLoggedIn: true,
65
                 onlyWhenLoggedIn: true,
66
             },
66
             },
67
             {
67
             {
68
                 name: i18n.t('screens.vote'),
68
                 name: i18n.t('screens.vote'),
69
-                route: "VoteScreen",
69
+                route: "vote",
70
                 icon: "vote",
70
                 icon: "vote",
71
                 onlyWhenLoggedIn: true,
71
                 onlyWhenLoggedIn: true,
72
             },
72
             },
81
         const servicesData = [
81
         const servicesData = [
82
             {
82
             {
83
                 name: i18n.t('screens.menuSelf'),
83
                 name: i18n.t('screens.menuSelf'),
84
-                route: "SelfMenuScreen",
84
+                route: "self-menu",
85
                 icon: "silverware-fork-knife",
85
                 icon: "silverware-fork-knife",
86
             },
86
             },
87
             {
87
             {
88
                 name: i18n.t('screens.availableRooms'),
88
                 name: i18n.t('screens.availableRooms'),
89
-                route: "AvailableRoomScreen",
89
+                route: "available-rooms",
90
                 icon: "calendar-check",
90
                 icon: "calendar-check",
91
             },
91
             },
92
             {
92
             {
93
                 name: i18n.t('screens.bib'),
93
                 name: i18n.t('screens.bib'),
94
-                route: "BibScreen",
94
+                route: "bib",
95
                 icon: "book",
95
                 icon: "book",
96
             },
96
             },
97
             {
97
             {
98
                 name: i18n.t('screens.bluemind'),
98
                 name: i18n.t('screens.bluemind'),
99
-                route: "BlueMindScreen",
99
+                route: "bluemind",
100
                 link: "https://etud-mel.insa-toulouse.fr/webmail/",
100
                 link: "https://etud-mel.insa-toulouse.fr/webmail/",
101
                 icon: "email",
101
                 icon: "email",
102
             },
102
             },
103
             {
103
             {
104
                 name: i18n.t('screens.ent'),
104
                 name: i18n.t('screens.ent'),
105
-                route: "EntScreen",
105
+                route: "ent",
106
                 link: "https://ent.insa-toulouse.fr/",
106
                 link: "https://ent.insa-toulouse.fr/",
107
                 icon: "notebook",
107
                 icon: "notebook",
108
             },
108
             },
110
         const websitesData = [
110
         const websitesData = [
111
             {
111
             {
112
                 name: "Amicale",
112
                 name: "Amicale",
113
-                route: "AmicaleScreen",
113
+                route: "amicale",
114
                 link: "https://amicale-insat.fr/",
114
                 link: "https://amicale-insat.fr/",
115
                 icon: "alpha-a-box",
115
                 icon: "alpha-a-box",
116
             },
116
             },
117
             {
117
             {
118
                 name: "Élus Étudiants",
118
                 name: "Élus Étudiants",
119
-                route: "ElusEtudScreen",
119
+                route: "elus-etudiants",
120
                 link: "https://etud.insa-toulouse.fr/~eeinsat/",
120
                 link: "https://etud.insa-toulouse.fr/~eeinsat/",
121
                 icon: "alpha-e-box",
121
                 icon: "alpha-e-box",
122
             },
122
             },
123
             {
123
             {
124
                 name: "Wiketud",
124
                 name: "Wiketud",
125
-                route: "WiketudScreen",
125
+                route: "wiketud",
126
                 link: "https://wiki.etud.insa-toulouse.fr",
126
                 link: "https://wiki.etud.insa-toulouse.fr",
127
                 icon: "wikipedia",
127
                 icon: "wikipedia",
128
             },
128
             },
129
             {
129
             {
130
                 name: "Tutor'INSA",
130
                 name: "Tutor'INSA",
131
-                route: "TutorInsaScreen",
131
+                route: "tutor-insa",
132
                 link: "https://www.etud.insa-toulouse.fr/~tutorinsa/",
132
                 link: "https://www.etud.insa-toulouse.fr/~tutorinsa/",
133
                 icon: "school",
133
                 icon: "school",
134
             },
134
             },
136
         const othersData = [
136
         const othersData = [
137
             {
137
             {
138
                 name: i18n.t('screens.settings'),
138
                 name: i18n.t('screens.settings'),
139
-                route: "SettingsScreen",
139
+                route: "settings",
140
                 icon: "settings",
140
                 icon: "settings",
141
             },
141
             },
142
             {
142
             {
143
                 name: i18n.t('screens.about'),
143
                 name: i18n.t('screens.about'),
144
-                route: "AboutScreen",
144
+                route: "about",
145
                 icon: "information",
145
                 icon: "information",
146
             },
146
             },
147
         ];
147
         ];
229
         return (
229
         return (
230
             <View style={{height: '100%'}}>
230
             <View style={{height: '100%'}}>
231
                 <TouchableRipple
231
                 <TouchableRipple
232
-                    onPress={() => this.props.navigation.navigate("TetrisScreen")}
232
+                    onPress={() => this.props.navigation.navigate("tetris")}
233
                 >
233
                 >
234
                     <Image
234
                     <Image
235
                         source={require("../../../assets/drawer-cover.png")}
235
                         source={require("../../../assets/drawer-cover.png")}

+ 1
- 1
src/managers/AsyncStorageManager.js View File

61
         },
61
         },
62
         defaultStartScreen: {
62
         defaultStartScreen: {
63
             key: 'defaultStartScreen',
63
             key: 'defaultStartScreen',
64
-            default: 'Home',
64
+            default: 'home',
65
             current: '',
65
             current: '',
66
         },
66
         },
67
         proxiwashShowBanner: {
67
         proxiwashShowBanner: {

+ 107
- 80
src/navigation/DrawerNavigator.js View File

39
 function AboutStackComponent() {
39
 function AboutStackComponent() {
40
     return (
40
     return (
41
         <AboutStack.Navigator
41
         <AboutStack.Navigator
42
-            initialRouteName="AboutScreen"
42
+            initialRouteName="index"
43
             headerMode="float"
43
             headerMode="float"
44
             screenOptions={defaultScreenOptions}
44
             screenOptions={defaultScreenOptions}
45
         >
45
         >
46
             <AboutStack.Screen
46
             <AboutStack.Screen
47
-                name="AboutScreen"
47
+                name="index"
48
                 component={AboutScreen}
48
                 component={AboutScreen}
49
                 options={({navigation}) => {
49
                 options={({navigation}) => {
50
                     const openDrawer = getDrawerButton.bind(this, navigation);
50
                     const openDrawer = getDrawerButton.bind(this, navigation);
55
                 }}
55
                 }}
56
             />
56
             />
57
             <AboutStack.Screen
57
             <AboutStack.Screen
58
-                name="AboutDependenciesScreen"
58
+                name="dependencies"
59
                 component={AboutDependenciesScreen}
59
                 component={AboutDependenciesScreen}
60
                 options={{
60
                 options={{
61
                     title: i18n.t('aboutScreen.libs')
61
                     title: i18n.t('aboutScreen.libs')
62
                 }}
62
                 }}
63
             />
63
             />
64
             <AboutStack.Screen
64
             <AboutStack.Screen
65
-                name="DebugScreen"
65
+                name="debug"
66
                 component={DebugScreen}
66
                 component={DebugScreen}
67
                 options={{
67
                 options={{
68
                     title: i18n.t('aboutScreen.debug')
68
                     title: i18n.t('aboutScreen.debug')
77
 function SettingsStackComponent() {
77
 function SettingsStackComponent() {
78
     return (
78
     return (
79
         <SettingsStack.Navigator
79
         <SettingsStack.Navigator
80
-            initialRouteName="SettingsScreen"
80
+            initialRouteName="index"
81
             headerMode="float"
81
             headerMode="float"
82
             screenOptions={defaultScreenOptions}
82
             screenOptions={defaultScreenOptions}
83
         >
83
         >
84
             <SettingsStack.Screen
84
             <SettingsStack.Screen
85
-                name="SettingsScreen"
85
+                name="index"
86
                 component={SettingsScreen}
86
                 component={SettingsScreen}
87
                 options={({navigation}) => {
87
                 options={({navigation}) => {
88
                     const openDrawer = getDrawerButton.bind(this, navigation);
88
                     const openDrawer = getDrawerButton.bind(this, navigation);
101
 function SelfMenuStackComponent() {
101
 function SelfMenuStackComponent() {
102
     return (
102
     return (
103
         <SelfMenuStack.Navigator
103
         <SelfMenuStack.Navigator
104
-            initialRouteName="SelfMenuScreen"
104
+            initialRouteName="index"
105
             headerMode="float"
105
             headerMode="float"
106
             screenOptions={defaultScreenOptions}
106
             screenOptions={defaultScreenOptions}
107
         >
107
         >
108
             <SelfMenuStack.Screen
108
             <SelfMenuStack.Screen
109
-                name="SelfMenuScreen"
109
+                name="index"
110
                 component={SelfMenuScreen}
110
                 component={SelfMenuScreen}
111
                 options={({navigation}) => {
111
                 options={({navigation}) => {
112
                     const openDrawer = getDrawerButton.bind(this, navigation);
112
                     const openDrawer = getDrawerButton.bind(this, navigation);
125
 function AvailableRoomStackComponent() {
125
 function AvailableRoomStackComponent() {
126
     return (
126
     return (
127
         <AvailableRoomStack.Navigator
127
         <AvailableRoomStack.Navigator
128
-            initialRouteName="AvailableRoomScreen"
128
+            initialRouteName="index"
129
             headerMode="float"
129
             headerMode="float"
130
             screenOptions={defaultScreenOptions}
130
             screenOptions={defaultScreenOptions}
131
         >
131
         >
132
             <AvailableRoomStack.Screen
132
             <AvailableRoomStack.Screen
133
-                name="AvailableRoomScreen"
133
+                name="index"
134
                 component={AvailableRoomScreen}
134
                 component={AvailableRoomScreen}
135
                 options={({navigation}) => {
135
                 options={({navigation}) => {
136
                     const openDrawer = getDrawerButton.bind(this, navigation);
136
                     const openDrawer = getDrawerButton.bind(this, navigation);
149
 function BibStackComponent() {
149
 function BibStackComponent() {
150
     return (
150
     return (
151
         <BibStack.Navigator
151
         <BibStack.Navigator
152
-            initialRouteName="BibScreen"
152
+            initialRouteName="index"
153
             headerMode="float"
153
             headerMode="float"
154
             screenOptions={defaultScreenOptions}
154
             screenOptions={defaultScreenOptions}
155
         >
155
         >
156
             <BibStack.Screen
156
             <BibStack.Screen
157
-                name="BibScreen"
157
+                name="index"
158
                 component={BibScreen}
158
                 component={BibScreen}
159
                 options={({navigation}) => {
159
                 options={({navigation}) => {
160
                     const openDrawer = getDrawerButton.bind(this, navigation);
160
                     const openDrawer = getDrawerButton.bind(this, navigation);
173
 function TetrisStackComponent() {
173
 function TetrisStackComponent() {
174
     return (
174
     return (
175
         <TetrisStack.Navigator
175
         <TetrisStack.Navigator
176
-            initialRouteName="TetrisScreen"
176
+            initialRouteName="index"
177
             headerMode="float"
177
             headerMode="float"
178
             screenOptions={defaultScreenOptions}
178
             screenOptions={defaultScreenOptions}
179
         >
179
         >
180
             <TetrisStack.Screen
180
             <TetrisStack.Screen
181
-                name="TetrisScreen"
181
+                name="index"
182
                 component={TetrisScreen}
182
                 component={TetrisScreen}
183
                 options={({navigation}) => {
183
                 options={({navigation}) => {
184
                     const openDrawer = getDrawerButton.bind(this, navigation);
184
                     const openDrawer = getDrawerButton.bind(this, navigation);
197
 function LoginStackComponent() {
197
 function LoginStackComponent() {
198
     return (
198
     return (
199
         <LoginStack.Navigator
199
         <LoginStack.Navigator
200
-            initialRouteName="LoginScreen"
200
+            initialRouteName="index"
201
             headerMode="float"
201
             headerMode="float"
202
             screenOptions={defaultScreenOptions}
202
             screenOptions={defaultScreenOptions}
203
         >
203
         >
204
             <LoginStack.Screen
204
             <LoginStack.Screen
205
-                name="LoginScreen"
205
+                name="index"
206
                 component={LoginScreen}
206
                 component={LoginScreen}
207
                 options={({navigation}) => {
207
                 options={({navigation}) => {
208
                     const openDrawer = getDrawerButton.bind(this, navigation);
208
                     const openDrawer = getDrawerButton.bind(this, navigation);
221
 function ProfileStackComponent() {
221
 function ProfileStackComponent() {
222
     return (
222
     return (
223
         <ProfileStack.Navigator
223
         <ProfileStack.Navigator
224
-            initialRouteName="ProfileScreen"
224
+            initialRouteName="index"
225
             headerMode="float"
225
             headerMode="float"
226
             screenOptions={defaultScreenOptions}
226
             screenOptions={defaultScreenOptions}
227
         >
227
         >
228
             <ProfileStack.Screen
228
             <ProfileStack.Screen
229
-                name="ProfileScreen"
229
+                name="index"
230
                 component={ProfileScreen}
230
                 component={ProfileScreen}
231
                 options={({navigation}) => {
231
                 options={({navigation}) => {
232
                     const openDrawer = getDrawerButton.bind(this, navigation);
232
                     const openDrawer = getDrawerButton.bind(this, navigation);
246
 function VoteStackComponent() {
246
 function VoteStackComponent() {
247
     return (
247
     return (
248
         <VoteStack.Navigator
248
         <VoteStack.Navigator
249
-            initialRouteName="VoteScreen"
249
+            initialRouteName="index"
250
             headerMode="float"
250
             headerMode="float"
251
             screenOptions={defaultScreenOptions}
251
             screenOptions={defaultScreenOptions}
252
         >
252
         >
253
             <VoteStack.Screen
253
             <VoteStack.Screen
254
-                name="VoteScreen"
254
+                name="index"
255
                 component={VoteScreen}
255
                 component={VoteScreen}
256
                 options={({navigation}) => {
256
                 options={({navigation}) => {
257
                     const openDrawer = getDrawerButton.bind(this, navigation);
257
                     const openDrawer = getDrawerButton.bind(this, navigation);
270
 function ClubStackComponent() {
270
 function ClubStackComponent() {
271
     return (
271
     return (
272
         <ClubStack.Navigator
272
         <ClubStack.Navigator
273
-            initialRouteName="ClubListScreen"
273
+            initialRouteName={"index"}
274
             headerMode="float"
274
             headerMode="float"
275
             screenOptions={defaultScreenOptions}
275
             screenOptions={defaultScreenOptions}
276
         >
276
         >
277
             <ClubStack.Screen
277
             <ClubStack.Screen
278
-                name="ClubListScreen"
278
+                name="index"
279
                 component={ClubListScreen}
279
                 component={ClubListScreen}
280
                 options={({navigation}) => {
280
                 options={({navigation}) => {
281
                     const openDrawer = getDrawerButton.bind(this, navigation);
281
                     const openDrawer = getDrawerButton.bind(this, navigation);
286
                 }}
286
                 }}
287
             />
287
             />
288
             <ClubStack.Screen
288
             <ClubStack.Screen
289
-                name="ClubDisplayScreen"
289
+                name="club-information"
290
                 component={ClubDisplayScreen}
290
                 component={ClubDisplayScreen}
291
                 options={({navigation}) => {
291
                 options={({navigation}) => {
292
                     return {
292
                     return {
296
                 }}
296
                 }}
297
             />
297
             />
298
             <ClubStack.Screen
298
             <ClubStack.Screen
299
-                name="ClubAboutScreen"
299
+                name="club-about"
300
                 component={ClubAboutScreen}
300
                 component={ClubAboutScreen}
301
                 options={({navigation}) => {
301
                 options={({navigation}) => {
302
                     return {
302
                     return {
316
     return <Sidebar {...props}/>
316
     return <Sidebar {...props}/>
317
 }
317
 }
318
 
318
 
319
-export default function DrawerNavigator() {
320
-    return (
321
-        <Drawer.Navigator
322
-            initialRouteName={'Main'}
323
-            headerMode={'float'}
324
-            backBehavior={'initialRoute'}
325
-            drawerType={'front'}
326
-            drawerContent={(props) => getDrawerContent(props)}
327
-            screenOptions={defaultScreenOptions}
328
-        >
329
-            <Drawer.Screen
330
-                name="Main"
331
-                component={TabNavigator}
319
+type Props = {
320
+    defaultPath: Array<string>,
321
+    defaultData: Object
322
+}
323
+
324
+
325
+export default class DrawerNavigator extends React.Component<Props> {
326
+
327
+    defaultRoute: string;
328
+    defaultSubRoute: string | null;
329
+
330
+    createTabNavigator: Object;
331
+
332
+    constructor(props: Object) {
333
+        super(props);
334
+        this.defaultRoute = 'Main';
335
+        this.defaultSubRoute = null;
336
+
337
+        if (props.defaultPath.length > 0)
338
+            this.defaultRoute = props.defaultPath[0];
339
+        if (props.defaultPath.length > 1)
340
+            this.defaultSubRoute = props.defaultPath[1];
341
+
342
+        this.createTabNavigator = () => <TabNavigator defaultPath={props.defaultPath} defaultData={props.defaultData}/>
343
+    }
344
+
345
+    render() {
346
+        return (
347
+            <Drawer.Navigator
348
+                initialRouteName={this.defaultRoute}
349
+                headerMode={'float'}
350
+                backBehavior={'initialRoute'}
351
+                drawerType={'front'}
352
+                drawerContent={(props) => getDrawerContent(props)}
353
+                screenOptions={defaultScreenOptions}
332
             >
354
             >
333
-            </Drawer.Screen>
334
-            <Drawer.Screen
335
-                name="SettingsScreen"
336
-                component={SettingsStackComponent}
337
-            />
338
-            <Drawer.Screen
339
-                name="AboutScreen"
340
-                component={AboutStackComponent}
341
-            />
342
-            <Drawer.Screen
343
-                name="SelfMenuScreen"
344
-                component={SelfMenuStackComponent}
345
-            />
346
-            <Drawer.Screen
347
-                name="AvailableRoomScreen"
348
-                component={AvailableRoomStackComponent}
349
-            />
350
-            <Drawer.Screen
351
-                name="BibScreen"
352
-                component={BibStackComponent}
353
-            />
354
-            <Drawer.Screen
355
-                name="TetrisScreen"
356
-                component={TetrisStackComponent}
357
-            />
358
-            <Drawer.Screen
359
-                name="LoginScreen"
360
-                component={LoginStackComponent}
361
-            />
362
-            <Drawer.Screen
363
-                name="ProfileScreen"
364
-                component={ProfileStackComponent}
365
-            />
366
-            <Drawer.Screen
367
-                name="ClubListScreen"
368
-                component={ClubStackComponent}
369
-            />
370
-            <Drawer.Screen
371
-                name="VoteScreen"
372
-                component={VoteStackComponent}
373
-            />
374
-        </Drawer.Navigator>
375
-    );
355
+                <Drawer.Screen
356
+                    name="main"
357
+                    component={this.createTabNavigator}
358
+                >
359
+                </Drawer.Screen>
360
+                <Drawer.Screen
361
+                    name="settings"
362
+                    component={SettingsStackComponent}
363
+                />
364
+                <Drawer.Screen
365
+                    name="about"
366
+                    component={AboutStackComponent}
367
+                />
368
+                <Drawer.Screen
369
+                    name="self-menu"
370
+                    component={SelfMenuStackComponent}
371
+                />
372
+                <Drawer.Screen
373
+                    name="available-rooms"
374
+                    component={AvailableRoomStackComponent}
375
+                />
376
+                <Drawer.Screen
377
+                    name="bib"
378
+                    component={BibStackComponent}
379
+                />
380
+                <Drawer.Screen
381
+                    name="tetris"
382
+                    component={TetrisStackComponent}
383
+                />
384
+                <Drawer.Screen
385
+                    name="login"
386
+                    component={LoginStackComponent}
387
+                />
388
+                <Drawer.Screen
389
+                    name="profile"
390
+                    component={ProfileStackComponent}
391
+                />
392
+                <Drawer.Screen
393
+                    name="club-list"
394
+                    component={ClubStackComponent}
395
+                />
396
+                <Drawer.Screen
397
+                    name="vote"
398
+                    component={VoteStackComponent}
399
+                />
400
+            </Drawer.Navigator>
401
+        );
402
+    }
376
 }
403
 }

+ 98
- 61
src/navigation/MainTabNavigator.js View File

16
 import HeaderButton from "../components/Custom/HeaderButton";
16
 import HeaderButton from "../components/Custom/HeaderButton";
17
 import {withTheme} from 'react-native-paper';
17
 import {withTheme} from 'react-native-paper';
18
 import i18n from "i18n-js";
18
 import i18n from "i18n-js";
19
+import ClubDisplayScreen from "../screens/Amicale/Clubs/ClubDisplayScreen";
19
 
20
 
20
 
21
 
21
 const TAB_ICONS = {
22
 const TAB_ICONS = {
22
-    Home: 'triangle',
23
-    Planning: 'calendar-range',
24
-    Proxiwash: 'tshirt-crew',
25
-    Proximo: 'cart',
26
-    Planex: 'clock',
23
+    home: 'triangle',
24
+    planning: 'calendar-range',
25
+    proxiwash: 'tshirt-crew',
26
+    proximo: 'cart',
27
+    planex: 'clock',
27
 };
28
 };
28
 
29
 
29
 const defaultScreenOptions = {
30
 const defaultScreenOptions = {
43
 function ProximoStackComponent() {
44
 function ProximoStackComponent() {
44
     return (
45
     return (
45
         <ProximoStack.Navigator
46
         <ProximoStack.Navigator
46
-            initialRouteName="ProximoMainScreen"
47
+            initialRouteName="index"
47
             headerMode="float"
48
             headerMode="float"
48
             screenOptions={defaultScreenOptions}
49
             screenOptions={defaultScreenOptions}
49
         >
50
         >
50
             <ProximoStack.Screen
51
             <ProximoStack.Screen
51
-                name="ProximoMainScreen"
52
+                name="index"
52
                 options={({navigation}) => {
53
                 options={({navigation}) => {
53
                     const openDrawer = getDrawerButton.bind(this, navigation);
54
                     const openDrawer = getDrawerButton.bind(this, navigation);
54
                     return {
55
                     return {
59
                 component={ProximoMainScreen}
60
                 component={ProximoMainScreen}
60
             />
61
             />
61
             <ProximoStack.Screen
62
             <ProximoStack.Screen
62
-                name="ProximoListScreen"
63
+                name="proximo-list"
63
                 options={{
64
                 options={{
64
                     title: 'Articles'
65
                     title: 'Articles'
65
                 }}
66
                 }}
66
                 component={ProximoListScreen}
67
                 component={ProximoListScreen}
67
             />
68
             />
68
             <ProximoStack.Screen
69
             <ProximoStack.Screen
69
-                name="ProximoAboutScreen"
70
+                name="proximo-about"
70
                 component={ProximoAboutScreen}
71
                 component={ProximoAboutScreen}
71
                 options={{
72
                 options={{
72
                     title: 'Proximo',
73
                     title: 'Proximo',
82
 function ProxiwashStackComponent() {
83
 function ProxiwashStackComponent() {
83
     return (
84
     return (
84
         <ProxiwashStack.Navigator
85
         <ProxiwashStack.Navigator
85
-            initialRouteName="ProxiwashScreen"
86
+            initialRouteName="index"
86
             headerMode='float'
87
             headerMode='float'
87
             screenOptions={defaultScreenOptions}
88
             screenOptions={defaultScreenOptions}
88
         >
89
         >
89
             <ProxiwashStack.Screen
90
             <ProxiwashStack.Screen
90
-                name="ProxiwashScreen"
91
+                name="index"
91
                 component={ProxiwashScreen}
92
                 component={ProxiwashScreen}
92
                 options={({navigation}) => {
93
                 options={({navigation}) => {
93
                     const openDrawer = getDrawerButton.bind(this, navigation);
94
                     const openDrawer = getDrawerButton.bind(this, navigation);
98
                 }}
99
                 }}
99
             />
100
             />
100
             <ProxiwashStack.Screen
101
             <ProxiwashStack.Screen
101
-                name="ProxiwashAboutScreen"
102
+                name="proxiwash-about"
102
                 component={ProxiwashAboutScreen}
103
                 component={ProxiwashAboutScreen}
103
                 options={{
104
                 options={{
104
                     title: 'Proxiwash',
105
                     title: 'Proxiwash',
114
 function PlanningStackComponent() {
115
 function PlanningStackComponent() {
115
     return (
116
     return (
116
         <PlanningStack.Navigator
117
         <PlanningStack.Navigator
117
-            initialRouteName="PlanningScreen"
118
+            initialRouteName="index"
118
             headerMode='float'
119
             headerMode='float'
119
             screenOptions={defaultScreenOptions}
120
             screenOptions={defaultScreenOptions}
120
         >
121
         >
121
             <PlanningStack.Screen
122
             <PlanningStack.Screen
122
-                name="PlanningScreen"
123
+                name="index"
123
                 component={PlanningScreen}
124
                 component={PlanningScreen}
124
                 options={({navigation}) => {
125
                 options={({navigation}) => {
125
                     const openDrawer = getDrawerButton.bind(this, navigation);
126
                     const openDrawer = getDrawerButton.bind(this, navigation);
130
                 }}
131
                 }}
131
             />
132
             />
132
             <PlanningStack.Screen
133
             <PlanningStack.Screen
133
-                name="PlanningDisplayScreen"
134
+                name="planning-information"
134
                 component={PlanningDisplayScreen}
135
                 component={PlanningDisplayScreen}
135
                 options={{
136
                 options={{
136
                     title: 'Details',
137
                     title: 'Details',
143
 
144
 
144
 const HomeStack = createStackNavigator();
145
 const HomeStack = createStackNavigator();
145
 
146
 
146
-function HomeStackComponent() {
147
+function HomeStackComponent(initialRoute: string | null, defaultData: Object) {
147
     return (
148
     return (
148
         <HomeStack.Navigator
149
         <HomeStack.Navigator
149
-            initialRouteName="HomeScreen"
150
+            initialRouteName={"index"}
150
             headerMode="float"
151
             headerMode="float"
151
             screenOptions={defaultScreenOptions}
152
             screenOptions={defaultScreenOptions}
152
         >
153
         >
153
             <HomeStack.Screen
154
             <HomeStack.Screen
154
-                name="HomeScreen"
155
+                name="index"
155
                 component={HomeScreen}
156
                 component={HomeScreen}
156
                 options={({navigation}) => {
157
                 options={({navigation}) => {
157
                     const openDrawer = getDrawerButton.bind(this, navigation);
158
                     const openDrawer = getDrawerButton.bind(this, navigation);
160
                         headerLeft: openDrawer
161
                         headerLeft: openDrawer
161
                     };
162
                     };
162
                 }}
163
                 }}
164
+                initialParams={{data: defaultData, nextScreen: initialRoute}}
163
             />
165
             />
164
             <HomeStack.Screen
166
             <HomeStack.Screen
165
-                name="PlanningDisplayScreen"
167
+                name="planning-information"
166
                 component={PlanningDisplayScreen}
168
                 component={PlanningDisplayScreen}
167
                 options={{
169
                 options={{
168
                     title: 'Details',
170
                     title: 'Details',
169
                     ...TransitionPresets.ModalSlideFromBottomIOS,
171
                     ...TransitionPresets.ModalSlideFromBottomIOS,
170
                 }}
172
                 }}
171
             />
173
             />
174
+            <HomeStack.Screen
175
+                name="club-information"
176
+                component={ClubDisplayScreen}
177
+                options={({navigation}) => {
178
+                    return {
179
+                        title: "",
180
+                        ...TransitionPresets.ModalSlideFromBottomIOS,
181
+                    };
182
+                }}
183
+            />
172
         </HomeStack.Navigator>
184
         </HomeStack.Navigator>
173
     );
185
     );
174
 }
186
 }
178
 function PlanexStackComponent() {
190
 function PlanexStackComponent() {
179
     return (
191
     return (
180
         <PlanexStack.Navigator
192
         <PlanexStack.Navigator
181
-            initialRouteName="HomeScreen"
193
+            initialRouteName="index"
182
             headerMode="float"
194
             headerMode="float"
183
             screenOptions={defaultScreenOptions}
195
             screenOptions={defaultScreenOptions}
184
         >
196
         >
185
             <PlanexStack.Screen
197
             <PlanexStack.Screen
186
-                name="PlanexScreen"
198
+                name="index"
187
                 component={PlanexScreen}
199
                 component={PlanexScreen}
188
                 options={({navigation}) => {
200
                 options={({navigation}) => {
189
                     const openDrawer = getDrawerButton.bind(this, navigation);
201
                     const openDrawer = getDrawerButton.bind(this, navigation);
199
 
211
 
200
 const Tab = createMaterialBottomTabNavigator();
212
 const Tab = createMaterialBottomTabNavigator();
201
 
213
 
202
-function TabNavigator(props) {
203
-    const {colors} = props.theme;
204
-    return (
205
-        <Tab.Navigator
206
-            initialRouteName={AsyncStorageManager.getInstance().preferences.defaultStartScreen.current}
207
-            barStyle={{backgroundColor: colors.surface}}
208
-            screenOptions={({route}) => ({
209
-                tabBarIcon: ({focused, color, size}) => {
210
-                    let icon = TAB_ICONS[route.name];
211
-                    // tintColor is ignoring activeColor and inactiveColor for some reason
212
-                    icon = focused ? icon : icon + ('-outline');
213
-                    return <MaterialCommunityIcons name={icon} color={color} size={26}/>;
214
-                },
215
-            })}
216
-            activeColor={colors.primary}
217
-            inactiveColor={colors.tabIcon}
218
-        >
219
-            <Tab.Screen
220
-                name="Proximo"
221
-                component={ProximoStackComponent}
222
-            />
223
-            <Tab.Screen
224
-                name="Planning"
225
-                component={PlanningStackComponent}
226
-            />
227
-            <Tab.Screen
228
-                name="Home"
229
-                component={HomeStackComponent}
230
-                options={{title: i18n.t('screens.home')}}
231
-            />
232
-            <Tab.Screen
233
-                name="Proxiwash"
234
-                component={ProxiwashStackComponent}
235
-            />
236
-            <Tab.Screen
237
-                name="Planex"
238
-                component={PlanexStackComponent}
239
-            />
240
-        </Tab.Navigator>
241
-    );
214
+type Props = {
215
+    defaultPath: Array<string>,
216
+    defaultData: Object
217
+}
218
+
219
+class TabNavigator extends React.Component<Props>{
220
+
221
+    createHomeStackComponent: Object;
222
+    colors: Object;
223
+
224
+    constructor(props) {
225
+        super(props);
226
+        this.colors = props.theme.colors;
227
+        this.defaultRoute = AsyncStorageManager.getInstance().preferences.defaultStartScreen.current.toLowerCase();
228
+        this.defaultSubRoute = null;
229
+
230
+        if (props.defaultPath.length > 1)
231
+            this.defaultRoute = props.defaultPath[1];
232
+        if (props.defaultPath.length > 2)
233
+            this.defaultSubRoute = props.defaultPath[2];
234
+
235
+
236
+        this.createHomeStackComponent = () => HomeStackComponent(this.defaultSubRoute, props.defaultData);
237
+    }
238
+
239
+    render() {
240
+        return (
241
+            <Tab.Navigator
242
+                initialRouteName={this.defaultRoute}
243
+                barStyle={{backgroundColor: this.colors.surface}}
244
+                screenOptions={({route}) => ({
245
+                    tabBarIcon: ({focused, color, size}) => {
246
+                        let icon = TAB_ICONS[route.name];
247
+                        // tintColor is ignoring activeColor and inactiveColor for some reason
248
+                        icon = focused ? icon : icon + ('-outline');
249
+                        return <MaterialCommunityIcons name={icon} color={color} size={26}/>;
250
+                    },
251
+                })}
252
+                activeColor={this.colors.primary}
253
+                inactiveColor={this.colors.tabIcon}
254
+            >
255
+                <Tab.Screen
256
+                    name="proximo"
257
+                    component={ProximoStackComponent}
258
+                />
259
+                <Tab.Screen
260
+                    name="planning"
261
+                    component={PlanningStackComponent}
262
+                />
263
+                <Tab.Screen
264
+                    name="home"
265
+                    component={this.createHomeStackComponent}
266
+                    options={{title: i18n.t('screens.home')}}
267
+                />
268
+                <Tab.Screen
269
+                    name="proxiwash"
270
+                    component={ProxiwashStackComponent}
271
+                />
272
+                <Tab.Screen
273
+                    name="planex"
274
+                    component={PlanexStackComponent}
275
+                />
276
+            </Tab.Navigator>
277
+        );
278
+    }
242
 }
279
 }
243
 
280
 
244
 export default withTheme(TabNavigator);
281
 export default withTheme(TabNavigator);

+ 2
- 2
src/screens/About/AboutScreen.js View File

101
             showChevron: true
101
             showChevron: true
102
         },
102
         },
103
         {
103
         {
104
-            onPressCallback: () => this.props.navigation.navigate('DebugScreen'),
104
+            onPressCallback: () => this.props.navigation.navigate('debug'),
105
             icon: 'bug-check',
105
             icon: 'bug-check',
106
             text: i18n.t('aboutScreen.debug'),
106
             text: i18n.t('aboutScreen.debug'),
107
             showChevron: true,
107
             showChevron: true,
165
             showChevron: true
165
             showChevron: true
166
         },
166
         },
167
         {
167
         {
168
-            onPressCallback: () => this.props.navigation.navigate('AboutDependenciesScreen'),
168
+            onPressCallback: () => this.props.navigation.navigate('dependencies'),
169
             icon: 'developer-board',
169
             icon: 'developer-board',
170
             text: i18n.t('aboutScreen.libs'),
170
             text: i18n.t('aboutScreen.libs'),
171
             showChevron: true
171
             showChevron: true

+ 73
- 14
src/screens/Amicale/Clubs/ClubDisplayScreen.js View File

7
 import {Avatar, Card, Chip, Paragraph, withTheme} from 'react-native-paper';
7
 import {Avatar, Card, Chip, Paragraph, withTheme} from 'react-native-paper';
8
 import ImageModal from 'react-native-image-modal';
8
 import ImageModal from 'react-native-image-modal';
9
 import i18n from "i18n-js";
9
 import i18n from "i18n-js";
10
+import AuthenticatedScreen from "../../../components/Amicale/AuthenticatedScreen";
10
 
11
 
11
 type Props = {
12
 type Props = {
12
     navigation: Object,
13
     navigation: Object,
21
     Linking.openURL(link).catch((err) => console.error('Error opening link', err));
22
     Linking.openURL(link).catch((err) => console.error('Error opening link', err));
22
 }
23
 }
23
 
24
 
25
+const FakeClub = {
26
+    "category": [
27
+        3,
28
+        6,
29
+    ],
30
+    "description": "<p class=\"ql-align-justify\">Les 100 Tours de l’INSA reviennent en force pour une cinquième édition les 5 et 6 juin prochain&nbsp;!</p><p class=\"ql-align-justify\"><br></p><p class=\"ql-align-justify\">Prépare-toi pour le plus gros évènement de l’année sur le campus de notre belle école qui nous réunit tous autour d’activités folles&nbsp;pour fêter la fin de l’année dans la bonne humeur !</p><p class=\"ql-align-justify\">L’éco-festival tournera autour d’une grande course par équipe qui nous vaut ce doux nom de 100 tours. Ce sera le moment de défier tes potes pour tenter de remporter de nombreux lots, et surtout l’admiration de tous. Mais cela ne s’arrête pas là, puisque tu pourras aussi participer à des activités à sensation, divers ateliers, et de quoi chiller avec tes potes en écoutant de la bonne musique. Tu pourras ensuite enchaîner sur LA soirée de l’année, rythmée par des artistes sur-motivés&nbsp;!</p><p class=\"ql-align-justify\"><br></p><p class=\"ql-align-justify\">Tu es bien entendu le bienvenu si l’envie te prend de rejoindre l’équipe et de nous aider à organiser cet évènement du turfu&nbsp;!</p><p class=\"ql-align-justify\"><br></p><p class=\"ql-align-justify\">La team 100 Tours</p><p class=\"ql-align-justify\"><br></p><p>Contact&nbsp;: <a href=\"mailto:100Tours@amicale-insat.fr\" target=\"_blank\">100tours@amicale-insat.fr</a></p><p>Facebook&nbsp;: Les 100 Tours de l’INSA</p><p>Instagram&nbsp;: 100tours.insatoulouse</p>",
31
+    "id": 110,
32
+    "logo": "https://www.amicale-insat.fr/storage/clubLogos/2cca8885dd3bdf902124f038b548962b.jpeg",
33
+    "name": "100 Tours",
34
+    "responsibles": [
35
+        "Juliette Duval",
36
+        "Emilie Cuminal",
37
+        "Maxime Doré",
38
+    ],
39
+};
40
+
24
 /**
41
 /**
25
  * Class defining a planning event information page.
42
  * Class defining a planning event information page.
43
+ * If called with data and categories navigation parameters, will use those to display the data.
44
+ * If called with clubId parameter, will fetch the information on the server
26
  */
45
  */
27
 class ClubDisplayScreen extends React.Component<Props, State> {
46
 class ClubDisplayScreen extends React.Component<Props, State> {
28
 
47
 
29
-    displayData = this.props.route.params['data'];
30
-    categories = this.props.route.params['categories'];
48
+    displayData: Object;
49
+    categories: Object | null;
50
+    clubId: number;
51
+
52
+    shouldFetchData: boolean;
31
 
53
 
32
     colors: Object;
54
     colors: Object;
33
 
55
 
38
     constructor(props) {
60
     constructor(props) {
39
         super(props);
61
         super(props);
40
         this.colors = props.theme.colors;
62
         this.colors = props.theme.colors;
63
+
64
+        if (this.props.route.params.data !== undefined && this.props.route.params.categories !== undefined) {
65
+            this.displayData = this.props.route.params.data;
66
+            this.categories = this.props.route.params.categories;
67
+            this.clubId = this.props.route.params.data.id;
68
+            this.shouldFetchData = false;
69
+        } else {
70
+            this.displayData = {};
71
+            this.categories = null;
72
+            this.clubId = this.props.route.params.clubId;
73
+            this.shouldFetchData = true;
74
+            console.log(this.clubId);
75
+        }
41
     }
76
     }
42
 
77
 
43
     componentDidMount(): * {
78
     componentDidMount(): * {
45
     }
80
     }
46
 
81
 
47
     getCategoryName(id: number) {
82
     getCategoryName(id: number) {
48
-        for (let i = 0; i < this.categories.length; i++) {
49
-            if (id === this.categories[i].id)
50
-                return this.categories[i].name;
83
+        if (this.categories !== null) {
84
+            for (let i = 0; i < this.categories.length; i++) {
85
+                if (id === this.categories[i].id)
86
+                    return this.categories[i].name;
87
+            }
51
         }
88
         }
52
         return "";
89
         return "";
53
     }
90
     }
54
 
91
 
55
     getCategoriesRender(categories: Array<number | null>) {
92
     getCategoriesRender(categories: Array<number | null>) {
93
+        if (this.categories === null)
94
+            return null;
95
+
56
         let final = [];
96
         let final = [];
57
         for (let i = 0; i < categories.length; i++) {
97
         for (let i = 0; i < categories.length; i++) {
58
-            if (categories[i] !== null) {
98
+            let cat = categories[i];
99
+            if (cat !== null) {
59
                 final.push(
100
                 final.push(
60
                     <Chip
101
                     <Chip
61
                         style={{marginRight: 5}}
102
                         style={{marginRight: 5}}
62
                         key={i.toString()}>
103
                         key={i.toString()}>
63
-                        {this.getCategoryName(categories[i])}
104
+                        {this.getCategoryName(cat)}
64
                     </Chip>
105
                     </Chip>
65
                 );
106
                 );
66
             }
107
             }
92
         );
133
         );
93
     }
134
     }
94
 
135
 
95
-    render() {
136
+    getScreen = (data: Object) => {
137
+        data = FakeClub;
138
+
96
         return (
139
         return (
97
             <ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
140
             <ScrollView style={{paddingLeft: 5, paddingRight: 5}}>
98
-                {this.getCategoriesRender(this.displayData.category)}
99
-                {this.displayData.logo !== null ?
141
+                {this.getCategoriesRender(data.category)}
142
+                {data.logo !== null ?
100
                     <View style={{
143
                     <View style={{
101
                         marginLeft: 'auto',
144
                         marginLeft: 'auto',
102
                         marginRight: 'auto',
145
                         marginRight: 'auto',
111
                                 height: 300,
154
                                 height: 300,
112
                             }}
155
                             }}
113
                             source={{
156
                             source={{
114
-                                uri: this.displayData.logo,
157
+                                uri: data.logo,
115
                             }}
158
                             }}
116
                         /></View>
159
                         /></View>
117
                     : <View/>}
160
                     : <View/>}
118
 
161
 
119
-                {this.displayData.description !== null ?
162
+                {data.description !== null ?
120
                     // Surround description with div to allow text styling if the description is not html
163
                     // Surround description with div to allow text styling if the description is not html
121
                     <Card.Content>
164
                     <Card.Content>
122
-                        <HTML html={"<div>" + this.displayData.description + "</div>"}
165
+                        <HTML html={"<div>" + data.description + "</div>"}
123
                               tagsStyles={{
166
                               tagsStyles={{
124
                                   p: {color: this.colors.text,},
167
                                   p: {color: this.colors.text,},
125
                                   div: {color: this.colors.text}
168
                                   div: {color: this.colors.text}
127
                               onLinkPress={openWebLink}/>
170
                               onLinkPress={openWebLink}/>
128
                     </Card.Content>
171
                     </Card.Content>
129
                     : <View/>}
172
                     : <View/>}
130
-                {this.getManagersRender(this.displayData.responsibles)}
173
+                {this.getManagersRender(data.responsibles)}
131
             </ScrollView>
174
             </ScrollView>
132
         );
175
         );
176
+    };
177
+
178
+    render() {
179
+        if (this.shouldFetchData)
180
+            return <AuthenticatedScreen
181
+                {...this.props}
182
+                links={[
183
+                    {
184
+                        link: 'clubs/list/' + this.clubId,
185
+                        mandatory: false,
186
+                    }
187
+                ]}
188
+                renderFunction={this.getScreen}
189
+            />;
190
+        else
191
+            return this.getScreen(this.displayData);
133
     }
192
     }
134
 }
193
 }
135
 
194
 

+ 2
- 2
src/screens/Amicale/Clubs/ClubListScreen.js View File

71
      * @return {*}
71
      * @return {*}
72
      */
72
      */
73
     getHeaderButtons = () => {
73
     getHeaderButtons = () => {
74
-        const onPress = () => this.props.navigation.navigate("ClubAboutScreen");
74
+        const onPress = () => this.props.navigation.navigate("club-about");
75
         return <HeaderButton icon={'information'} onPress={onPress}/>;
75
         return <HeaderButton icon={'information'} onPress={onPress}/>;
76
     };
76
     };
77
 
77
 
186
      * @param item The article pressed
186
      * @param item The article pressed
187
      */
187
      */
188
     onListItemPress(item: Object) {
188
     onListItemPress(item: Object) {
189
-        this.props.navigation.navigate("ClubDisplayScreen", {data: item, categories: this.categories});
189
+        this.props.navigation.navigate("club-information", {data: item, categories: this.categories});
190
     }
190
     }
191
 
191
 
192
     render() {
192
     render() {

+ 1
- 1
src/screens/Amicale/LoginScreen.js View File

63
 
63
 
64
     hideErrorDialog = () => this.setState({dialogVisible: false});
64
     hideErrorDialog = () => this.setState({dialogVisible: false});
65
 
65
 
66
-    handleSuccess = () => this.props.navigation.navigate('ProfileScreen');
66
+    handleSuccess = () => this.props.navigation.navigate('profile');
67
 
67
 
68
     onResetPasswordClick = () => openBrowser(RESET_PASSWORD_LINK, this.colors.primary);
68
     onResetPasswordClick = () => openBrowser(RESET_PASSWORD_LINK, this.colors.primary);
69
 
69
 

+ 11
- 7
src/screens/HomeScreen.js View File

29
 
29
 
30
 type Props = {
30
 type Props = {
31
     navigation: Object,
31
     navigation: Object,
32
+    route: Object,
32
     theme: Object,
33
     theme: Object,
33
 }
34
 }
34
 
35
 
51
         this.colors = props.theme.colors;
52
         this.colors = props.theme.colors;
52
 
53
 
53
         this.isLoggedIn = null;
54
         this.isLoggedIn = null;
55
+        if (this.props.route.params.nextScreen !== undefined && this.props.route.params.nextScreen !== null) {
56
+            this.props.navigation.navigate(this.props.route.params.nextScreen, this.props.route.params.data);
57
+        }
54
     }
58
     }
55
 
59
 
56
     /**
60
     /**
80
 
84
 
81
     getHeaderButton = () => {
85
     getHeaderButton = () => {
82
         const screen = this.isLoggedIn
86
         const screen = this.isLoggedIn
83
-            ? "ProfileScreen"
84
-            : "LoginScreen";
87
+            ? "profile"
88
+            : "login";
85
         const icon = this.isLoggedIn
89
         const icon = this.isLoggedIn
86
             ? "account"
90
             ? "account"
87
             : "login";
91
             : "login";
93
         />;
97
         />;
94
     };
98
     };
95
 
99
 
96
-    onProxiwashClick = () => this.props.navigation.navigate('Proxiwash');
100
+    onProxiwashClick = () => this.props.navigation.navigate('proxiwash');
97
 
101
 
98
     onTutorInsaClick = () => openBrowser("https://www.etud.insa-toulouse.fr/~tutorinsa/", this.colors.primary);
102
     onTutorInsaClick = () => openBrowser("https://www.etud.insa-toulouse.fr/~tutorinsa/", this.colors.primary);
99
 
103
 
100
-    onProximoClick = () => this.props.navigation.navigate('Proximo');
104
+    onProximoClick = () => this.props.navigation.navigate('proximo');
101
 
105
 
102
-    onMenuClick = () => this.props.navigation.navigate('SelfMenuScreen');
106
+    onMenuClick = () => this.props.navigation.navigate('self-menu');
103
 
107
 
104
     /**
108
     /**
105
      * Creates the dataset to be used in the FlatList
109
      * Creates the dataset to be used in the FlatList
338
             subtitle = i18n.t('homeScreen.dashboard.todayEventsSubtitleNA');
342
             subtitle = i18n.t('homeScreen.dashboard.todayEventsSubtitleNA');
339
 
343
 
340
         let displayEvent = this.getDisplayEvent(futureEvents);
344
         let displayEvent = this.getDisplayEvent(futureEvents);
341
-        const clickContainerAction = () => this.props.navigation.navigate('Planning');
342
-        const clickPreviewAction = () => this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent});
345
+        const clickContainerAction = () => this.props.navigation.navigate('planning');
346
+        const clickPreviewAction = () => this.props.navigation.navigate('planning-information', {data: displayEvent});
343
 
347
 
344
         return (
348
         return (
345
             <DashboardItem
349
             <DashboardItem

+ 27
- 11
src/screens/Planning/PlanningDisplayScreen.js View File

15
 };
15
 };
16
 
16
 
17
 type State = {
17
 type State = {
18
-    imageModalVisible: boolean,
19
 };
18
 };
20
 
19
 
21
 function openWebLink(event, link) {
20
 function openWebLink(event, link) {
22
     Linking.openURL(link).catch((err) => console.error('Error opening link', err));
21
     Linking.openURL(link).catch((err) => console.error('Error opening link', err));
23
 }
22
 }
24
 
23
 
24
+const FAKE_EVENT = {
25
+    "id": 142,
26
+    "title": "Soir\u00e9e Impact'INSA",
27
+    "logo": null,
28
+    "date_begin": "2020-04-22 19:00",
29
+    "date_end": "2020-04-22 00:00",
30
+    "description": "<p>R\u00e9servation salle de boom + PK pour la soir\u00e9e Impact'Insa<\/p>",
31
+    "club": "Impact Insa",
32
+    "category_id": 10,
33
+    "url": "https:\/\/www.amicale-insat.fr\/event\/142\/view"
34
+};
35
+
25
 /**
36
 /**
26
  * Class defining a planning event information page.
37
  * Class defining a planning event information page.
27
  */
38
  */
28
 class PlanningDisplayScreen extends React.Component<Props, State> {
39
 class PlanningDisplayScreen extends React.Component<Props, State> {
29
 
40
 
30
-    displayData = this.props.route.params['data'];
41
+    displayData: Object;
42
+    shouldFetchData: boolean;
43
+    eventId: number;
31
 
44
 
32
     colors: Object;
45
     colors: Object;
33
 
46
 
34
     state = {
47
     state = {
35
-        imageModalVisible: false,
48
+
36
     };
49
     };
37
 
50
 
38
     constructor(props) {
51
     constructor(props) {
39
         super(props);
52
         super(props);
40
         this.colors = props.theme.colors;
53
         this.colors = props.theme.colors;
41
-    }
42
 
54
 
43
-    showImageModal = () => {
44
-        this.setState({imageModalVisible: true});
45
-    };
46
-
47
-    hideImageModal = () => {
48
-        this.setState({imageModalVisible: false});
49
-    };
55
+        if (this.props.route.params.data !== undefined) {
56
+            this.displayData = this.props.route.params.data;
57
+            this.eventId = this.props.route.params.data.eventId;
58
+            this.shouldFetchData = false;
59
+        } else {
60
+            this.displayData = FAKE_EVENT;
61
+            this.eventId = this.props.route.params.eventId;
62
+            this.shouldFetchData = true;
63
+            console.log(this.eventId);
64
+        }
65
+    }
50
 
66
 
51
     render() {
67
     render() {
52
         // console.log("rendering planningDisplayScreen");
68
         // console.log("rendering planningDisplayScreen");

+ 1
- 1
src/screens/Planning/PlanningScreen.js View File

185
      * @return {*}
185
      * @return {*}
186
      */
186
      */
187
     getRenderItem(item: eventObject) {
187
     getRenderItem(item: eventObject) {
188
-        const onPress = this.props.navigation.navigate.bind(this, 'PlanningDisplayScreen', {data: item});
188
+        const onPress = this.props.navigation.navigate.bind(this, 'planning-information', {data: item});
189
         if (item.logo !== null) {
189
         if (item.logo !== null) {
190
             return (
190
             return (
191
                 <View>
191
                 <View>

+ 3
- 3
src/screens/Proximo/ProximoMainScreen.js View File

95
                     this.getAvailableArticles(this.articles, undefined) : []
95
                     this.getAvailableArticles(this.articles, undefined) : []
96
             },
96
             },
97
         };
97
         };
98
-        this.props.navigation.navigate('ProximoListScreen', searchScreenData);
98
+        this.props.navigation.navigate('proximo-list', searchScreenData);
99
     }
99
     }
100
 
100
 
101
     /**
101
     /**
103
      * This will open the ProximoAboutScreen
103
      * This will open the ProximoAboutScreen
104
      */
104
      */
105
     onPressAboutBtn() {
105
     onPressAboutBtn() {
106
-        this.props.navigation.navigate('ProximoAboutScreen');
106
+        this.props.navigation.navigate('proximo-about');
107
     }
107
     }
108
 
108
 
109
     /**
109
     /**
212
             data: item,
212
             data: item,
213
         };
213
         };
214
         const subtitle = item.data.length + " " + (item.data.length > 1 ? i18n.t('proximoScreen.articles') : i18n.t('proximoScreen.article'));
214
         const subtitle = item.data.length + " " + (item.data.length > 1 ? i18n.t('proximoScreen.articles') : i18n.t('proximoScreen.article'));
215
-        const onPress = this.props.navigation.navigate.bind(this, 'ProximoListScreen', dataToSend);
215
+        const onPress = this.props.navigation.navigate.bind(this, 'proximo-list', dataToSend);
216
         if (item.data.length > 0) {
216
         if (item.data.length > 0) {
217
             return (
217
             return (
218
                 <List.Item
218
                 <List.Item

+ 1
- 1
src/screens/Proxiwash/ProxiwashScreen.js View File

143
      * This will open the ProxiwashAboutScreen.
143
      * This will open the ProxiwashAboutScreen.
144
      */
144
      */
145
     onAboutPress() {
145
     onAboutPress() {
146
-        this.props.navigation.navigate('ProxiwashAboutScreen');
146
+        this.props.navigation.navigate('proxiwash-about');
147
     }
147
     }
148
 
148
 
149
     /**
149
     /**

+ 1
- 1
src/screens/Websites/PlanexScreen.js View File

134
      */
134
      */
135
     onGoToSettings() {
135
     onGoToSettings() {
136
         this.onHideBanner();
136
         this.onHideBanner();
137
-        this.props.navigation.navigate('SettingsScreen');
137
+        this.props.navigation.navigate('settings');
138
     }
138
     }
139
 
139
 
140
     render() {
140
     render() {

Loading…
Cancel
Save