8 Commits

Author SHA1 Message Date
  Arnaud Vergnet 09942b2fc5 Merge branch 'French_language' of leban/application-amicale into master 3 years ago
  Gérald L 9b26d045b3 Fix typos - Missing spaces 3 years ago
  Arnaud Vergnet f5c043dd7d Bump version code 3 years ago
  Arnaud Vergnet ea7321eb9d Fix planning management to match new api 3 years ago
  Arnaud Vergnet dafd454a42 Fix locale 3 years ago
  Arnaud Vergnet 0dae9c08b5 Improve mascot size 3 years ago
  Arnaud Vergnet d38f11d45f Fix mascot size on thinner displays 3 years ago
  Arnaud Vergnet 5a98f5506a Improve translation and start/feedback screen 3 years ago

+ 1
- 1
android/app/build.gradle View File

@@ -148,7 +148,7 @@ android {
148 148
         applicationId 'fr.amicaleinsat.application'
149 149
         minSdkVersion rootProject.ext.minSdkVersion
150 150
         targetSdkVersion rootProject.ext.targetSdkVersion
151
-        versionCode 41
151
+        versionCode 42
152 152
         versionName "4.0.1"
153 153
         missingDimensionStrategy 'react-native-camera', 'general'
154 154
     }

+ 16
- 16
locales/en.json View File

@@ -128,7 +128,7 @@
128 128
       "noGroupSelected": "No group selected. Please select your group using the big beautiful red button bellow.",
129 129
       "favorites": "Favorites",
130 130
       "mascotDialog": {
131
-        "title": "Skipping classes is bad",
131
+        "title": "Don't skip class",
132 132
         "message": "Here is Planex! You can set your class and your crush's to favorites in order to find them back easily!\n\nIf you mainly use Campus for Planex, go to the settings to make the app directly start on it!",
133 133
         "ok": "Settings",
134 134
         "cancel": "Later"
@@ -354,15 +354,15 @@
354 354
       "libs": "Libraries used"
355 355
     },
356 356
     "feedback": {
357
-      "title": "Feedback",
358
-      "bugs": "Report Bugs",
359
-      "bugsSubtitle": "Did you find a bug? Let us know!",
360
-      "bugsDescription": "Reporting bugs helps us make the app better. To do so, use one of the buttons below and be as precise as possible when describing your problem!",
361
-      "feedbackSubtitle": "Let us know what you think!",
362
-      "feedbackDescription": "Do you have a feature you want to be added/changed/removed, want to give your opinion on the app or simply chat with the dev? Use one of the links below!",
363
-      "contactMeans": "Using Gitea is recommended, to use it simply login with your INSA account.",
364
-      "homeButtonTitle": "Feedback/Bug report",
365
-      "homeButtonSubtitle": "Contact the devs"
357
+      "title": "Contribute",
358
+      "feedback": "Contact the dev",
359
+      "feedbackSubtitle": "A student like you!",
360
+      "feedbackDescription": "Feedback or bugs, you are always welcome.\nChoose your preferred way from the buttons bellow.",
361
+      "contribute": "Contribute to the project",
362
+      "contributeSubtitle": "With a possible \"implication citoyenne\"!",
363
+      "contributeDescription": "Everyone can help: communication, design or coding! You are free to contribute as you like.\nYou can find bellow a link to Trello for project organization, and a link to the source code on GitEtud.",
364
+      "homeButtonTitle": "Contribute to the project",
365
+      "homeButtonSubtitle": "Your help is important"
366 366
     },
367 367
     "game": {
368 368
       "title": "So Awesome Game",
@@ -413,16 +413,16 @@
413 413
       "text": "You can do much more with CAMPUS, but I can't explain everything here. Explore the app to find out!"
414 414
     },
415 415
     "slideDone": {
416
-      "title": "Your feedback is valuable!",
417
-      "text": "This app is the work of one student (with some help here and there), so your feedback is much appreciated!"
416
+      "title": "Contribute to the project!",
417
+      "text": "This app is the work of one student, so your feedback and your help are welcome!\nEveryone can help: communication, design or coding!"
418 418
     },
419 419
     "updateSlide0": {
420
-      "title": "New in this update!",
421
-      "text": "Hello you! I'm here to help you around the app."
420
+      "title": "Hi you!",
421
+      "text": "I'm new here and I will help you around the app. My thing is to give you lots of tips and tricks."
422 422
     },
423 423
     "updateSlide1": {
424
-      "title": "Contribute!",
425
-      "text": "Everyone is free to contribute to the project, from reporting bugs to implementing new features"
424
+      "title": "Contribute to the project!",
425
+      "text": "This app is the work of one student, so your feedback and your help are welcome!\nEveryone can help: communication, design or coding!"
426 426
     },
427 427
     "aprilFoolsSlide": {
428 428
       "title": "New in this update!",

+ 15
- 15
locales/fr.json View File

@@ -50,7 +50,7 @@
50 50
       "paymentMethods": "Moyens de Paiement",
51 51
       "paymentMethodsDescription": "Toute monnaie jusqu'à 10€.\nCarte bancaire acceptée.",
52 52
       "washerProcedure": "Déposer le linge dans le tambour sans le tasser et en respectant les charges.\n\nFermer la porte de l'appareil.\n\nSélectionner un programme avec l'une des quatre touches de programme favori standard.\n\nAprès avoir payé à la centrale de commande, appuyer sur le bouton marqué START du lave-linge.\n\nDès que le programme est terminé, l’afficheur indique 'Programme terminé', appuyer sur le bouton jaune d’ouverture du hublot pour récupérer le linge.",
53
-      "washerTips": "Programme blanc/couleur : 6kg de linge sec (textiles en coton, lin, linge de corps, draps, jeans,serviettes de toilettes).\n\nProgramme nonrepassable : 3,5 kg de linge sec (textiles en fibres synthétiques, cotonet polyester mélangés).\n\nProgramme fin 30°C : 2,5 kg de linge sec (textiles délicats en fibres synthétiques, rayonne).\n\nProgramme laine 30°C : 2,5 kg de linge sec (textiles en laine et lainages lavables).",
53
+      "washerTips": "Programme blanc/couleur : 6kg de linge sec (textiles en coton, lin, linge de corps, draps, jeans,serviettes de toilettes).\n\nProgramme non repassable : 3,5 kg de linge sec (textiles en fibres synthétiques, coton et polyester mélangés).\n\nProgramme fin 30°C : 2,5 kg de linge sec (textiles délicats en fibres synthétiques, rayonne).\n\nProgramme laine 30°C : 2,5 kg de linge sec (textiles en laine et lainages lavables).",
54 54
       "dryerProcedure": "Déposer le linge dans le tambour sans le tasser et en respectant les charges.\n\nFermer la porte de l'appareil.\n\nSélectionner un programme avec l'une des quatre touches de programme favori standard.\n\nAprès avoir payé à la centrale de commande, appuyer sur le bouton marqué START du lave-linge.",
55 55
       "dryerTips": "La durée conseillée est de 35 minutes pour 14kg de linge. Vous pouvez choisir une durée plus courte si le sèche-linge n'est pas chargé.",
56 56
       "procedure": "Procédure",
@@ -353,15 +353,15 @@
353 353
       "libs": "Librairies utilisées"
354 354
     },
355 355
     "feedback": {
356
-      "title": "Feedback",
357
-      "bugs": "Rapporter des Bugs",
358
-      "bugsSubtitle": "Tu as trouvé un bug ?",
359
-      "bugsDescription": "Rapporter les bugs m'aide à améliorer l'appli. Pour cela, merci d'utiliser un des boutons ci-dessous et de décrire ton problème le plus précisément possible !",
360
-      "feedbackSubtitle": "Dis moi ce que tu penses !",
361
-      "feedbackDescription": "Tu veux voir une fonctionnalité ajoutée/modifiée/supprimée ? Tu veux donner ton opinion sur l'appli ou simplement discuter avec le développeur (c'est moi coucou) ? Utilise un des liens ci-dessous !",
362
-      "contactMeans": "L'utilisation de Gitea est recommandée, pour l'utiliser, connecte toi avec tes identifiants INSA.",
363
-      "homeButtonTitle": "Feedback/Bugs",
364
-      "homeButtonSubtitle": "Contacte le développeur de l'appli"
356
+      "title": "Participer",
357
+      "feedback": "Contacte le développeur",
358
+      "feedbackSubtitle": "C'est un étudiant comme toi !",
359
+      "feedbackDescription": "Que ce soit pour donner ton avis ou rapporter des bugs, tu es le bienvenue.\nUtilise le moyen de ton choix parmi les boutons ci-dessous.",
360
+      "contribute": "Contribue au projet",
361
+      "contributeSubtitle": "Avec une possible implication citoyenne !",
362
+      "contributeDescription": "Il y en a pour tous les goûts : de la com', du design ou de la technique. Tu es libre de participer comme tu veux.\nTu trouveras ci-dessous un Trello de l'organisation du projet, ainsi que le code source sur GitEtud.",
363
+      "homeButtonTitle": "Participer au projet",
364
+      "homeButtonSubtitle": "Ton aide compte"
365 365
     },
366 366
     "game": {
367 367
       "title": "Jeu trop ouf",
@@ -412,16 +412,16 @@
412 412
       "text": "Tu peux faire bien plus avec CAMPUS, mais je n'ai pas le temps de tout dire ici. Balade toi sur l'appli pour tout découvrir !"
413 413
     },
414 414
     "slideDone": {
415
-      "title": "Ton avis compte !",
416
-      "text": "Cette appli à été réalisée par un seul étudiant (avec un peu d'aide par-ci par-là), donc tes retours sont les bienvenus !"
415
+      "title": "Participe au projet !",
416
+      "text": "Cette appli à été réalisée par un seul étudiant, donc tes retours et ton aide sont les bienvenus !\nIl y en a pour tous les goûts : de la com', du design ou de la technique !"
417 417
     },
418 418
     "updateSlide0": {
419
-      "title": "Nouveau dans cette mise à jour !",
420
-      "text": "Coucou toi ! Je suis là pour t'aider trouver à utiliser l'appli."
419
+      "title": "Coucou toi !",
420
+      "text": "Je suis le petit nouveau qui t'accompagnera sur l'appli. Mon dada c'est de te donner plein d'astuces et d'infos."
421 421
     },
422 422
     "updateSlide1": {
423 423
       "title": "Participe au projet !",
424
-      "text": "Tout le monde peut participer, que ce soit pour trouver des bugs ou ajouter des nouvelles fonctionnalités."
424
+      "text": "Cette appli à été réalisée par un seul étudiant, donc tes retours et ton aide sont les bienvenus !\nIl y en a pour tous les goûts : de la com', du design ou de la technique !"
425 425
     },
426 426
     "aprilFoolsSlide": {
427 427
       "title": "Nouveau dans cette mise à jour !",

+ 5
- 11
src/components/Home/PreviewEventDashboardItem.js View File

@@ -4,12 +4,12 @@ import * as React from 'react';
4 4
 import {StyleSheet, View} from 'react-native';
5 5
 import i18n from 'i18n-js';
6 6
 import {Avatar, Button, Card, TouchableRipple} from 'react-native-paper';
7
-import {getFormattedEventTime, isDescriptionEmpty} from '../../utils/Planning';
7
+import {getTimeOnlyString, isDescriptionEmpty} from '../../utils/Planning';
8 8
 import CustomHTML from '../Overrides/CustomHTML';
9
-import type {EventType} from '../../screens/Home/HomeScreen';
9
+import type {PlanningEventType} from '../../utils/Planning';
10 10
 
11 11
 type PropsType = {
12
-  event?: EventType | null,
12
+  event?: PlanningEventType | null,
13 13
   clickAction: () => void,
14 14
 };
15 15
 
@@ -62,19 +62,13 @@ class PreviewEventDashboardItem extends React.Component<PropsType> {
62 62
               {hasImage ? (
63 63
                 <Card.Title
64 64
                   title={event.title}
65
-                  subtitle={getFormattedEventTime(
66
-                    event.date_begin,
67
-                    event.date_end,
68
-                  )}
65
+                  subtitle={getTimeOnlyString(event.date_begin)}
69 66
                   left={getImage}
70 67
                 />
71 68
               ) : (
72 69
                 <Card.Title
73 70
                   title={event.title}
74
-                  subtitle={getFormattedEventTime(
75
-                    event.date_begin,
76
-                    event.date_end,
77
-                  )}
71
+                  subtitle={getTimeOnlyString(event.date_begin)}
78 72
                 />
79 73
               )}
80 74
               {!isEmpty ? (

+ 1
- 1
src/components/Intro/MascotIntroEnd.js View File

@@ -24,7 +24,7 @@ class MascotIntroEnd extends React.Component<null> {
24 24
         <Mascot
25 25
           style={{
26 26
             ...styles.center,
27
-            height: '80%',
27
+            width: '80%',
28 28
           }}
29 29
           emotion={MASCOT_STYLE.COOL}
30 30
           animated

+ 1
- 1
src/components/Intro/MascotIntroWelcome.js View File

@@ -26,7 +26,7 @@ class MascotIntroWelcome extends React.Component<null> {
26 26
         <Mascot
27 27
           style={{
28 28
             ...styles.center,
29
-            height: '80%',
29
+            width: '80%',
30 30
           }}
31 31
           emotion={MASCOT_STYLE.NORMAL}
32 32
           animated

+ 3
- 14
src/screens/Home/HomeScreen.js View File

@@ -28,6 +28,7 @@ import MascotPopup from '../../components/Mascot/MascotPopup';
28 28
 import DashboardManager from '../../managers/DashboardManager';
29 29
 import type {ServiceItemType} from '../../managers/ServicesManager';
30 30
 import {getDisplayEvent, getFutureEvents} from '../../utils/Home';
31
+import type {PlanningEventType} from '../../utils/Planning';
31 32
 // import DATA from "../dashboard_data.json";
32 33
 
33 34
 const DATA_URL =
@@ -49,24 +50,12 @@ export type FeedItemType = {
49 50
   page_id: string,
50 51
 };
51 52
 
52
-export type EventType = {
53
-  id: number,
54
-  title: string,
55
-  logo: string | null,
56
-  date_begin: string,
57
-  date_end: string,
58
-  description: string,
59
-  club: string,
60
-  category_id: number,
61
-  url: string,
62
-};
63
-
64 53
 export type FullDashboardType = {
65 54
   today_menu: Array<{[key: string]: {...}}>,
66 55
   proximo_articles: number,
67 56
   available_dryers: number,
68 57
   available_washers: number,
69
-  today_events: Array<EventType>,
58
+  today_events: Array<PlanningEventType>,
70 59
   available_tutorials: number,
71 60
 };
72 61
 
@@ -193,7 +182,7 @@ class HomeScreen extends React.Component<PropsType, StateType> {
193 182
    * @param content
194 183
    * @return {*}
195 184
    */
196
-  getDashboardEvent(content: Array<EventType>): React.Node {
185
+  getDashboardEvent(content: Array<PlanningEventType>): React.Node {
197 186
     const futureEvents = getFutureEvents(content);
198 187
     const displayEvent = getDisplayEvent(futureEvents);
199 188
     // const clickPreviewAction = () =>

+ 102
- 69
src/screens/Other/FeedbackScreen.js View File

@@ -3,118 +3,151 @@
3 3
 import * as React from 'react';
4 4
 import {Avatar, Button, Card, Paragraph, withTheme} from 'react-native-paper';
5 5
 import i18n from 'i18n-js';
6
-import {Linking} from 'react-native';
7
-import type {CustomThemeType} from '../../managers/ThemeManager';
6
+import {Linking, View} from 'react-native';
8 7
 import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
9 8
 import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
10 9
 
11
-type PropsType = {
12
-  theme: CustomThemeType,
13
-};
14
-
15 10
 const links = {
16
-  bugsMail: `mailto:app@amicale-insat.fr?subject=[BUG] Application CAMPUS
17
-&body=Coucou Arnaud ça bug c'est nul,\n\n
18
-Informations sur ton système si tu sais (iOS ou Android, modèle du tel, version):\n\n\n
19
-Nature du problème :\n\n\n
20
-Étapes pour reproduire ce pb :\n\n\n\n
21
-Stp corrige le pb, bien cordialement.`,
22
-  bugsGit:
23
-    'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/issues/new',
11
+  bugsGit: 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/',
12
+  trello: 'https://trello.com/b/RMej49Uq/application-campus-insa',
24 13
   facebook: 'https://www.facebook.com/campus.insat',
25 14
   feedbackMail: `mailto:app@amicale-insat.fr?subject=[FEEDBACK] Application CAMPUS
26 15
 &body=Coucou Arnaud j'ai du feedback\n\n\n\nBien cordialement.`,
27 16
   feedbackDiscord: 'https://discord.gg/W8MeTec',
28 17
 };
29 18
 
30
-class FeedbackScreen extends React.Component<PropsType> {
19
+class FeedbackScreen extends React.Component<null> {
31 20
   /**
32 21
    * Gets link buttons
33 22
    *
34
-   * @param isBug True if buttons should redirect to bug report methods
35 23
    * @returns {*}
36 24
    */
37
-  static getButtons(isBug: boolean): React.Node {
25
+  static getButtons(isFeedback: boolean): React.Node {
38 26
     return (
39 27
       <Card.Actions
40 28
         style={{
41 29
           flex: 1,
42 30
           flexWrap: 'wrap',
43 31
         }}>
44
-        <Button
45
-          icon="email"
46
-          mode="contained"
47
-          style={{
48
-            marginLeft: 'auto',
49
-            marginTop: 5,
50
-          }}
51
-          onPress={() => {
52
-            Linking.openURL(isBug ? links.bugsMail : links.feedbackMail);
53
-          }}>
54
-          MAIL
55
-        </Button>
56
-        <Button
57
-          icon={isBug ? 'git' : 'discord'}
58
-          mode="contained"
59
-          color={isBug ? '#609927' : '#7289da'}
60
-          style={{
61
-            marginLeft: 'auto',
62
-            marginTop: 5,
63
-          }}
64
-          onPress={() => {
65
-            Linking.openURL(isBug ? links.bugsGit : links.feedbackDiscord);
66
-          }}>
67
-          {isBug ? 'GITEA' : 'Discord'}
68
-        </Button>
69
-        <Button
70
-          icon="facebook"
71
-          mode="contained"
72
-          color="#2e88fe"
73
-          style={{
74
-            marginLeft: 'auto',
75
-            marginTop: 5,
76
-          }}
77
-          onPress={() => {
78
-            Linking.openURL(links.facebook);
79
-          }}>
80
-          Facebook
81
-        </Button>
32
+        {isFeedback ? (
33
+          <View
34
+            style={{
35
+              flex: 1,
36
+              flexWrap: 'wrap',
37
+              flexDirection: 'row',
38
+              width: '100%',
39
+            }}>
40
+            <Button
41
+              icon="email"
42
+              mode="contained"
43
+              style={{
44
+                marginLeft: 'auto',
45
+                marginRight: 'auto',
46
+                marginTop: 5,
47
+              }}
48
+              onPress={() => {
49
+                Linking.openURL(links.feedbackMail);
50
+              }}>
51
+              MAIL
52
+            </Button>
53
+            <Button
54
+              icon="facebook"
55
+              mode="contained"
56
+              color="#2e88fe"
57
+              style={{
58
+                marginLeft: 'auto',
59
+                marginRight: 'auto',
60
+                marginTop: 5,
61
+              }}
62
+              onPress={() => {
63
+                Linking.openURL(links.facebook);
64
+              }}>
65
+              Facebook
66
+            </Button>
67
+            <Button
68
+              icon="discord"
69
+              mode="contained"
70
+              color="#7289da"
71
+              style={{
72
+                marginLeft: 'auto',
73
+                marginRight: 'auto',
74
+                marginTop: 5,
75
+              }}
76
+              onPress={() => {
77
+                Linking.openURL(links.feedbackDiscord);
78
+              }}>
79
+              Discord
80
+            </Button>
81
+          </View>
82
+        ) : (
83
+          <View
84
+            style={{
85
+              flex: 1,
86
+              flexWrap: 'wrap',
87
+              flexDirection: 'row',
88
+              width: '100%',
89
+            }}>
90
+            <Button
91
+              icon="git"
92
+              mode="contained"
93
+              color="#609927"
94
+              style={{
95
+                marginLeft: 'auto',
96
+                marginRight: 'auto',
97
+                marginTop: 5,
98
+              }}
99
+              onPress={() => {
100
+                Linking.openURL(links.bugsGit);
101
+              }}>
102
+              GITETUD
103
+            </Button>
104
+            <Button
105
+              icon="calendar"
106
+              mode="contained"
107
+              color="#026AA7"
108
+              style={{
109
+                marginLeft: 'auto',
110
+                marginRight: 'auto',
111
+                marginTop: 5,
112
+              }}
113
+              onPress={() => {
114
+                Linking.openURL(links.trello);
115
+              }}>
116
+              TRELLO
117
+            </Button>
118
+          </View>
119
+        )}
82 120
       </Card.Actions>
83 121
     );
84 122
   }
85 123
 
86 124
   render(): React.Node {
87
-    const {theme} = this.props;
88 125
     return (
89 126
       <CollapsibleScrollView style={{padding: 5}}>
90 127
         <Card>
91 128
           <Card.Title
92
-            title={i18n.t('screens.feedback.bugs')}
93
-            subtitle={i18n.t('screens.feedback.bugsSubtitle')}
129
+            title={i18n.t('screens.feedback.feedback')}
130
+            subtitle={i18n.t('screens.feedback.feedbackSubtitle')}
94 131
             left={(iconProps: CardTitleIconPropsType): React.Node => (
95
-              <Avatar.Icon size={iconProps.size} icon="bug" />
132
+              <Avatar.Icon size={iconProps.size} icon="comment" />
96 133
             )}
97 134
           />
98 135
           <Card.Content>
99
-            <Paragraph>{i18n.t('screens.feedback.bugsDescription')}</Paragraph>
100
-            <Paragraph style={{color: theme.colors.primary}}>
101
-              {i18n.t('screens.feedback.contactMeans')}
136
+            <Paragraph>
137
+              {i18n.t('screens.feedback.feedbackDescription')}
102 138
             </Paragraph>
103 139
           </Card.Content>
104 140
           {FeedbackScreen.getButtons(true)}
105
-        </Card>
106
-
107
-        <Card style={{marginTop: 20, marginBottom: 10}}>
108 141
           <Card.Title
109
-            title={i18n.t('screens.feedback.title')}
110
-            subtitle={i18n.t('screens.feedback.feedbackSubtitle')}
142
+            title={i18n.t('screens.feedback.contribute')}
143
+            subtitle={i18n.t('screens.feedback.contributeSubtitle')}
111 144
             left={(iconProps: CardTitleIconPropsType): React.Node => (
112
-              <Avatar.Icon size={iconProps.size} icon="comment" />
145
+              <Avatar.Icon size={iconProps.size} icon="handshake" />
113 146
             )}
114 147
           />
115 148
           <Card.Content>
116 149
             <Paragraph>
117
-              {i18n.t('screens.feedback.feedbackDescription')}
150
+              {i18n.t('screens.feedback.contributeDescription')}
118 151
             </Paragraph>
119 152
           </Card.Content>
120 153
           {FeedbackScreen.getButtons(false)}

+ 3
- 6
src/screens/Planning/PlanningDisplayScreen.js View File

@@ -5,7 +5,7 @@ import {View} from 'react-native';
5 5
 import {Card} from 'react-native-paper';
6 6
 import i18n from 'i18n-js';
7 7
 import {StackNavigationProp} from '@react-navigation/stack';
8
-import {getDateOnlyString, getFormattedEventTime} from '../../utils/Planning';
8
+import {getDateOnlyString, getTimeOnlyString} from '../../utils/Planning';
9 9
 import DateManager from '../../managers/DateManager';
10 10
 import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen';
11 11
 import {apiRequest, ERROR_TYPE} from '../../utils/WebData';
@@ -96,12 +96,9 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
96 96
     const {navigation} = this.props;
97 97
     const {displayData} = this;
98 98
     if (displayData == null) return null;
99
-    let subtitle = getFormattedEventTime(
100
-      displayData.date_begin,
101
-      displayData.date_end,
102
-    );
99
+    let subtitle = getTimeOnlyString(displayData.date_begin);
103 100
     const dateString = getDateOnlyString(displayData.date_begin);
104
-    if (dateString !== null)
101
+    if (dateString !== null && subtitle != null)
105 102
       subtitle += ` | ${DateManager.getInstance().getTranslatedDate(
106 103
         dateString,
107 104
       )}`;

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

@@ -12,7 +12,7 @@ import {
12 12
   generateEventAgenda,
13 13
   getCurrentDateString,
14 14
   getDateOnlyString,
15
-  getFormattedEventTime,
15
+  getTimeOnlyString,
16 16
 } from '../../utils/Planning';
17 17
 import CustomAgenda from '../../components/Overrides/CustomAgenda';
18 18
 import {MASCOT_STYLE} from '../../components/Mascot/Mascot';
@@ -198,7 +198,7 @@ class PlanningScreen extends React.Component<PropsType, StateType> {
198 198
           <Divider />
199 199
           <List.Item
200 200
             title={item.title}
201
-            description={getFormattedEventTime(item.date_begin, item.date_end)}
201
+            description={getTimeOnlyString(item.date_begin)}
202 202
             left={(): React.Node => (
203 203
               <Avatar.Image
204 204
                 source={{uri: item.logo}}
@@ -215,7 +215,7 @@ class PlanningScreen extends React.Component<PropsType, StateType> {
215 215
         <Divider />
216 216
         <List.Item
217 217
           title={item.title}
218
-          description={getFormattedEventTime(item.date_begin, item.date_end)}
218
+          description={getTimeOnlyString(item.date_begin)}
219 219
           onPress={onPress}
220 220
         />
221 221
       </View>

+ 16
- 59
src/utils/Home.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import {stringToDate} from './Planning';
4
-import type {EventType} from '../screens/Home/HomeScreen';
4
+import type {PlanningEventType} from './Planning';
5 5
 
6 6
 /**
7 7
  * Gets the time limit depending on the current day:
@@ -21,20 +21,6 @@ export function getTodayEventTimeLimit(): Date {
21 21
 }
22 22
 
23 23
 /**
24
- * Gets the duration (in milliseconds) of an event
25
- *
26
- * @param event {EventType}
27
- * @return {number} The number of milliseconds
28
- */
29
-export function getEventDuration(event: EventType): number {
30
-  const start = stringToDate(event.date_begin);
31
-  const end = stringToDate(event.date_end);
32
-  let duration = 0;
33
-  if (start != null && end != null) duration = end - start;
34
-  return duration;
35
-}
36
-
37
-/**
38 24
  * Gets events starting after the limit
39 25
  *
40 26
  * @param events
@@ -42,11 +28,11 @@ export function getEventDuration(event: EventType): number {
42 28
  * @return {Array<Object>}
43 29
  */
44 30
 export function getEventsAfterLimit(
45
-  events: Array<EventType>,
31
+  events: Array<PlanningEventType>,
46 32
   limit: Date,
47
-): Array<EventType> {
33
+): Array<PlanningEventType> {
48 34
   const validEvents = [];
49
-  events.forEach((event: EventType) => {
35
+  events.forEach((event: PlanningEventType) => {
50 36
     const startDate = stringToDate(event.date_begin);
51 37
     if (startDate != null && startDate >= limit) {
52 38
       validEvents.push(event);
@@ -56,43 +42,18 @@ export function getEventsAfterLimit(
56 42
 }
57 43
 
58 44
 /**
59
- * Gets the event with the longest duration in the given array.
60
- * If all events have the same duration, return the first in the array.
61
- *
62
- * @param events
63
- */
64
-export function getLongestEvent(events: Array<EventType>): EventType {
65
-  let longestEvent = events[0];
66
-  let longestTime = 0;
67
-  events.forEach((event: EventType) => {
68
-    const time = getEventDuration(event);
69
-    if (time > longestTime) {
70
-      longestTime = time;
71
-      longestEvent = event;
72
-    }
73
-  });
74
-  return longestEvent;
75
-}
76
-
77
-/**
78 45
  * Gets events that have not yet ended/started
79 46
  *
80 47
  * @param events
81 48
  */
82
-export function getFutureEvents(events: Array<EventType>): Array<EventType> {
49
+export function getFutureEvents(
50
+  events: Array<PlanningEventType>,
51
+): Array<PlanningEventType> {
83 52
   const validEvents = [];
84 53
   const now = new Date();
85
-  events.forEach((event: EventType) => {
54
+  events.forEach((event: PlanningEventType) => {
86 55
     const startDate = stringToDate(event.date_begin);
87
-    const endDate = stringToDate(event.date_end);
88
-    if (startDate != null) {
89
-      if (startDate > now) validEvents.push(event);
90
-      else if (endDate != null) {
91
-        if (endDate > now || endDate < startDate)
92
-          // Display event if it ends the following day
93
-          validEvents.push(event);
94
-      }
95
-    }
56
+    if (startDate != null && startDate > now) validEvents.push(event);
96 57
   });
97 58
   return validEvents;
98 59
 }
@@ -101,23 +62,19 @@ export function getFutureEvents(events: Array<EventType>): Array<EventType> {
101 62
  * Gets the event to display in the preview
102 63
  *
103 64
  * @param events
104
- * @return {EventType | null}
65
+ * @return {PlanningEventType | null}
105 66
  */
106
-export function getDisplayEvent(events: Array<EventType>): EventType | null {
67
+export function getDisplayEvent(
68
+  events: Array<PlanningEventType>,
69
+): PlanningEventType | null {
107 70
   let displayEvent = null;
108 71
   if (events.length > 1) {
109 72
     const eventsAfterLimit = getEventsAfterLimit(
110 73
       events,
111 74
       getTodayEventTimeLimit(),
112 75
     );
113
-    if (eventsAfterLimit.length > 0) {
114
-      if (eventsAfterLimit.length === 1) [displayEvent] = eventsAfterLimit;
115
-      else displayEvent = getLongestEvent(events);
116
-    } else {
117
-      displayEvent = getLongestEvent(events);
118
-    }
119
-  } else if (events.length === 1) {
120
-    [displayEvent] = events;
121
-  }
76
+    if (eventsAfterLimit.length > 0) [displayEvent] = eventsAfterLimit;
77
+    else [displayEvent] = events;
78
+  } else if (events.length === 1) [displayEvent] = events;
122 79
   return displayEvent;
123 80
 }

+ 3
- 47
src/utils/Planning.js View File

@@ -3,13 +3,13 @@
3 3
 export type PlanningEventType = {
4 4
   id: number,
5 5
   title: string,
6
-  logo: string,
7 6
   date_begin: string,
8
-  date_end: string,
9
-  description: string,
10 7
   club: string,
11 8
   category_id: number,
9
+  description: string,
10
+  place: string,
12 11
   url: string,
12
+  logo: string | null,
13 13
 };
14 14
 
15 15
 // Regex used to check date string validity
@@ -121,50 +121,6 @@ export function getTimeOnlyString(dateString: string): string | null {
121 121
 }
122 122
 
123 123
 /**
124
- * Returns a string corresponding to the event start and end times in the following format:
125
- *
126
- * HH:MM - HH:MM
127
- *
128
- * If the end date is not specified or is equal to start time, only start time will be shown.
129
- *
130
- * If the end date is not on the same day, 23:59 will be shown as end time
131
- *
132
- * @param start Start time in YYYY-MM-DD HH:MM:SS format
133
- * @param end End time in YYYY-MM-DD HH:MM:SS format
134
- * @return {string} Formatted string or "/ - /" on error
135
- */
136
-export function getFormattedEventTime(start: string, end: string): string {
137
-  let formattedStr = '/ - /';
138
-  const startDate = stringToDate(start);
139
-  const endDate = stringToDate(end);
140
-
141
-  if (
142
-    startDate !== null &&
143
-    endDate !== null &&
144
-    startDate.getTime() !== endDate.getTime()
145
-  ) {
146
-    formattedStr = `${String(startDate.getHours()).padStart(2, '0')}:${String(
147
-      startDate.getMinutes(),
148
-    ).padStart(2, '0')} - `;
149
-    if (
150
-      endDate.getFullYear() > startDate.getFullYear() ||
151
-      endDate.getMonth() > startDate.getMonth() ||
152
-      endDate.getDate() > startDate.getDate()
153
-    )
154
-      formattedStr += '23:59';
155
-    else
156
-      formattedStr += `${String(endDate.getHours()).padStart(2, '0')}:${String(
157
-        endDate.getMinutes(),
158
-      ).padStart(2, '0')}`;
159
-  } else if (startDate !== null)
160
-    formattedStr = `${String(startDate.getHours()).padStart(2, '0')}:${String(
161
-      startDate.getMinutes(),
162
-    ).padStart(2, '0')}`;
163
-
164
-  return formattedStr;
165
-}
166
-
167
-/**
168 124
  * Checks if the given description can be considered empty.
169 125
  * <br>
170 126
  * An empty description is composed only of whitespace, <b>br</b> or <b>p</b> tags

Loading…
Cancel
Save