forked from vergnet/application-amicale
Compare commits
8 commits
12c0a76667
...
09942b2fc5
Author | SHA1 | Date | |
---|---|---|---|
09942b2fc5 | |||
|
9b26d045b3 | ||
f5c043dd7d | |||
ea7321eb9d | |||
dafd454a42 | |||
0dae9c08b5 | |||
d38f11d45f | |||
5a98f5506a |
12 changed files with 174 additions and 248 deletions
|
@ -148,7 +148,7 @@ android {
|
|||
applicationId 'fr.amicaleinsat.application'
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 41
|
||||
versionCode 42
|
||||
versionName "4.0.1"
|
||||
missingDimensionStrategy 'react-native-camera', 'general'
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
"noGroupSelected": "No group selected. Please select your group using the big beautiful red button bellow.",
|
||||
"favorites": "Favorites",
|
||||
"mascotDialog": {
|
||||
"title": "Skipping classes is bad",
|
||||
"title": "Don't skip class",
|
||||
"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!",
|
||||
"ok": "Settings",
|
||||
"cancel": "Later"
|
||||
|
@ -354,15 +354,15 @@
|
|||
"libs": "Libraries used"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Feedback",
|
||||
"bugs": "Report Bugs",
|
||||
"bugsSubtitle": "Did you find a bug? Let us know!",
|
||||
"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!",
|
||||
"feedbackSubtitle": "Let us know what you think!",
|
||||
"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!",
|
||||
"contactMeans": "Using Gitea is recommended, to use it simply login with your INSA account.",
|
||||
"homeButtonTitle": "Feedback/Bug report",
|
||||
"homeButtonSubtitle": "Contact the devs"
|
||||
"title": "Contribute",
|
||||
"feedback": "Contact the dev",
|
||||
"feedbackSubtitle": "A student like you!",
|
||||
"feedbackDescription": "Feedback or bugs, you are always welcome.\nChoose your preferred way from the buttons bellow.",
|
||||
"contribute": "Contribute to the project",
|
||||
"contributeSubtitle": "With a possible \"implication citoyenne\"!",
|
||||
"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.",
|
||||
"homeButtonTitle": "Contribute to the project",
|
||||
"homeButtonSubtitle": "Your help is important"
|
||||
},
|
||||
"game": {
|
||||
"title": "So Awesome Game",
|
||||
|
@ -413,16 +413,16 @@
|
|||
"text": "You can do much more with CAMPUS, but I can't explain everything here. Explore the app to find out!"
|
||||
},
|
||||
"slideDone": {
|
||||
"title": "Your feedback is valuable!",
|
||||
"text": "This app is the work of one student (with some help here and there), so your feedback is much appreciated!"
|
||||
"title": "Contribute to the project!",
|
||||
"text": "This app is the work of one student, so your feedback and your help are welcome!\nEveryone can help: communication, design or coding!"
|
||||
},
|
||||
"updateSlide0": {
|
||||
"title": "New in this update!",
|
||||
"text": "Hello you! I'm here to help you around the app."
|
||||
"title": "Hi you!",
|
||||
"text": "I'm new here and I will help you around the app. My thing is to give you lots of tips and tricks."
|
||||
},
|
||||
"updateSlide1": {
|
||||
"title": "Contribute!",
|
||||
"text": "Everyone is free to contribute to the project, from reporting bugs to implementing new features"
|
||||
"title": "Contribute to the project!",
|
||||
"text": "This app is the work of one student, so your feedback and your help are welcome!\nEveryone can help: communication, design or coding!"
|
||||
},
|
||||
"aprilFoolsSlide": {
|
||||
"title": "New in this update!",
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
"paymentMethods": "Moyens de Paiement",
|
||||
"paymentMethodsDescription": "Toute monnaie jusqu'à 10€.\nCarte bancaire acceptée.",
|
||||
"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.",
|
||||
"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).",
|
||||
"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).",
|
||||
"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.",
|
||||
"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é.",
|
||||
"procedure": "Procédure",
|
||||
|
@ -353,15 +353,15 @@
|
|||
"libs": "Librairies utilisées"
|
||||
},
|
||||
"feedback": {
|
||||
"title": "Feedback",
|
||||
"bugs": "Rapporter des Bugs",
|
||||
"bugsSubtitle": "Tu as trouvé un bug ?",
|
||||
"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 !",
|
||||
"feedbackSubtitle": "Dis moi ce que tu penses !",
|
||||
"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 !",
|
||||
"contactMeans": "L'utilisation de Gitea est recommandée, pour l'utiliser, connecte toi avec tes identifiants INSA.",
|
||||
"homeButtonTitle": "Feedback/Bugs",
|
||||
"homeButtonSubtitle": "Contacte le développeur de l'appli"
|
||||
"title": "Participer",
|
||||
"feedback": "Contacte le développeur",
|
||||
"feedbackSubtitle": "C'est un étudiant comme toi !",
|
||||
"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.",
|
||||
"contribute": "Contribue au projet",
|
||||
"contributeSubtitle": "Avec une possible implication citoyenne !",
|
||||
"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.",
|
||||
"homeButtonTitle": "Participer au projet",
|
||||
"homeButtonSubtitle": "Ton aide compte"
|
||||
},
|
||||
"game": {
|
||||
"title": "Jeu trop ouf",
|
||||
|
@ -412,16 +412,16 @@
|
|||
"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 !"
|
||||
},
|
||||
"slideDone": {
|
||||
"title": "Ton avis compte !",
|
||||
"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 !"
|
||||
"title": "Participe au projet !",
|
||||
"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 !"
|
||||
},
|
||||
"updateSlide0": {
|
||||
"title": "Nouveau dans cette mise à jour !",
|
||||
"text": "Coucou toi ! Je suis là pour t'aider trouver à utiliser l'appli."
|
||||
"title": "Coucou toi !",
|
||||
"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."
|
||||
},
|
||||
"updateSlide1": {
|
||||
"title": "Participe au projet !",
|
||||
"text": "Tout le monde peut participer, que ce soit pour trouver des bugs ou ajouter des nouvelles fonctionnalités."
|
||||
"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 !"
|
||||
},
|
||||
"aprilFoolsSlide": {
|
||||
"title": "Nouveau dans cette mise à jour !",
|
||||
|
|
|
@ -4,12 +4,12 @@ import * as React from 'react';
|
|||
import {StyleSheet, View} from 'react-native';
|
||||
import i18n from 'i18n-js';
|
||||
import {Avatar, Button, Card, TouchableRipple} from 'react-native-paper';
|
||||
import {getFormattedEventTime, isDescriptionEmpty} from '../../utils/Planning';
|
||||
import {getTimeOnlyString, isDescriptionEmpty} from '../../utils/Planning';
|
||||
import CustomHTML from '../Overrides/CustomHTML';
|
||||
import type {EventType} from '../../screens/Home/HomeScreen';
|
||||
import type {PlanningEventType} from '../../utils/Planning';
|
||||
|
||||
type PropsType = {
|
||||
event?: EventType | null,
|
||||
event?: PlanningEventType | null,
|
||||
clickAction: () => void,
|
||||
};
|
||||
|
||||
|
@ -62,19 +62,13 @@ class PreviewEventDashboardItem extends React.Component<PropsType> {
|
|||
{hasImage ? (
|
||||
<Card.Title
|
||||
title={event.title}
|
||||
subtitle={getFormattedEventTime(
|
||||
event.date_begin,
|
||||
event.date_end,
|
||||
)}
|
||||
subtitle={getTimeOnlyString(event.date_begin)}
|
||||
left={getImage}
|
||||
/>
|
||||
) : (
|
||||
<Card.Title
|
||||
title={event.title}
|
||||
subtitle={getFormattedEventTime(
|
||||
event.date_begin,
|
||||
event.date_end,
|
||||
)}
|
||||
subtitle={getTimeOnlyString(event.date_begin)}
|
||||
/>
|
||||
)}
|
||||
{!isEmpty ? (
|
||||
|
|
|
@ -24,7 +24,7 @@ class MascotIntroEnd extends React.Component<null> {
|
|||
<Mascot
|
||||
style={{
|
||||
...styles.center,
|
||||
height: '80%',
|
||||
width: '80%',
|
||||
}}
|
||||
emotion={MASCOT_STYLE.COOL}
|
||||
animated
|
||||
|
|
|
@ -26,7 +26,7 @@ class MascotIntroWelcome extends React.Component<null> {
|
|||
<Mascot
|
||||
style={{
|
||||
...styles.center,
|
||||
height: '80%',
|
||||
width: '80%',
|
||||
}}
|
||||
emotion={MASCOT_STYLE.NORMAL}
|
||||
animated
|
||||
|
|
|
@ -28,6 +28,7 @@ import MascotPopup from '../../components/Mascot/MascotPopup';
|
|||
import DashboardManager from '../../managers/DashboardManager';
|
||||
import type {ServiceItemType} from '../../managers/ServicesManager';
|
||||
import {getDisplayEvent, getFutureEvents} from '../../utils/Home';
|
||||
import type {PlanningEventType} from '../../utils/Planning';
|
||||
// import DATA from "../dashboard_data.json";
|
||||
|
||||
const DATA_URL =
|
||||
|
@ -49,24 +50,12 @@ export type FeedItemType = {
|
|||
page_id: string,
|
||||
};
|
||||
|
||||
export type EventType = {
|
||||
id: number,
|
||||
title: string,
|
||||
logo: string | null,
|
||||
date_begin: string,
|
||||
date_end: string,
|
||||
description: string,
|
||||
club: string,
|
||||
category_id: number,
|
||||
url: string,
|
||||
};
|
||||
|
||||
export type FullDashboardType = {
|
||||
today_menu: Array<{[key: string]: {...}}>,
|
||||
proximo_articles: number,
|
||||
available_dryers: number,
|
||||
available_washers: number,
|
||||
today_events: Array<EventType>,
|
||||
today_events: Array<PlanningEventType>,
|
||||
available_tutorials: number,
|
||||
};
|
||||
|
||||
|
@ -193,7 +182,7 @@ class HomeScreen extends React.Component<PropsType, StateType> {
|
|||
* @param content
|
||||
* @return {*}
|
||||
*/
|
||||
getDashboardEvent(content: Array<EventType>): React.Node {
|
||||
getDashboardEvent(content: Array<PlanningEventType>): React.Node {
|
||||
const futureEvents = getFutureEvents(content);
|
||||
const displayEvent = getDisplayEvent(futureEvents);
|
||||
// const clickPreviewAction = () =>
|
||||
|
|
|
@ -3,110 +3,130 @@
|
|||
import * as React from 'react';
|
||||
import {Avatar, Button, Card, Paragraph, withTheme} from 'react-native-paper';
|
||||
import i18n from 'i18n-js';
|
||||
import {Linking} from 'react-native';
|
||||
import type {CustomThemeType} from '../../managers/ThemeManager';
|
||||
import {Linking, View} from 'react-native';
|
||||
import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
|
||||
import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
|
||||
|
||||
type PropsType = {
|
||||
theme: CustomThemeType,
|
||||
};
|
||||
|
||||
const links = {
|
||||
bugsMail: `mailto:app@amicale-insat.fr?subject=[BUG] Application CAMPUS
|
||||
&body=Coucou Arnaud ça bug c'est nul,\n\n
|
||||
Informations sur ton système si tu sais (iOS ou Android, modèle du tel, version):\n\n\n
|
||||
Nature du problème :\n\n\n
|
||||
Étapes pour reproduire ce pb :\n\n\n\n
|
||||
Stp corrige le pb, bien cordialement.`,
|
||||
bugsGit:
|
||||
'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/issues/new',
|
||||
bugsGit: 'https://git.etud.insa-toulouse.fr/vergnet/application-amicale/',
|
||||
trello: 'https://trello.com/b/RMej49Uq/application-campus-insa',
|
||||
facebook: 'https://www.facebook.com/campus.insat',
|
||||
feedbackMail: `mailto:app@amicale-insat.fr?subject=[FEEDBACK] Application CAMPUS
|
||||
&body=Coucou Arnaud j'ai du feedback\n\n\n\nBien cordialement.`,
|
||||
feedbackDiscord: 'https://discord.gg/W8MeTec',
|
||||
};
|
||||
|
||||
class FeedbackScreen extends React.Component<PropsType> {
|
||||
class FeedbackScreen extends React.Component<null> {
|
||||
/**
|
||||
* Gets link buttons
|
||||
*
|
||||
* @param isBug True if buttons should redirect to bug report methods
|
||||
* @returns {*}
|
||||
*/
|
||||
static getButtons(isBug: boolean): React.Node {
|
||||
static getButtons(isFeedback: boolean): React.Node {
|
||||
return (
|
||||
<Card.Actions
|
||||
style={{
|
||||
flex: 1,
|
||||
flexWrap: 'wrap',
|
||||
}}>
|
||||
<Button
|
||||
icon="email"
|
||||
mode="contained"
|
||||
style={{
|
||||
marginLeft: 'auto',
|
||||
marginTop: 5,
|
||||
}}
|
||||
onPress={() => {
|
||||
Linking.openURL(isBug ? links.bugsMail : links.feedbackMail);
|
||||
}}>
|
||||
MAIL
|
||||
</Button>
|
||||
<Button
|
||||
icon={isBug ? 'git' : 'discord'}
|
||||
mode="contained"
|
||||
color={isBug ? '#609927' : '#7289da'}
|
||||
style={{
|
||||
marginLeft: 'auto',
|
||||
marginTop: 5,
|
||||
}}
|
||||
onPress={() => {
|
||||
Linking.openURL(isBug ? links.bugsGit : links.feedbackDiscord);
|
||||
}}>
|
||||
{isBug ? 'GITEA' : 'Discord'}
|
||||
</Button>
|
||||
<Button
|
||||
icon="facebook"
|
||||
mode="contained"
|
||||
color="#2e88fe"
|
||||
style={{
|
||||
marginLeft: 'auto',
|
||||
marginTop: 5,
|
||||
}}
|
||||
onPress={() => {
|
||||
Linking.openURL(links.facebook);
|
||||
}}>
|
||||
Facebook
|
||||
</Button>
|
||||
{isFeedback ? (
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
flexWrap: 'wrap',
|
||||
flexDirection: 'row',
|
||||
width: '100%',
|
||||
}}>
|
||||
<Button
|
||||
icon="email"
|
||||
mode="contained"
|
||||
style={{
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
marginTop: 5,
|
||||
}}
|
||||
onPress={() => {
|
||||
Linking.openURL(links.feedbackMail);
|
||||
}}>
|
||||
MAIL
|
||||
</Button>
|
||||
<Button
|
||||
icon="facebook"
|
||||
mode="contained"
|
||||
color="#2e88fe"
|
||||
style={{
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
marginTop: 5,
|
||||
}}
|
||||
onPress={() => {
|
||||
Linking.openURL(links.facebook);
|
||||
}}>
|
||||
Facebook
|
||||
</Button>
|
||||
<Button
|
||||
icon="discord"
|
||||
mode="contained"
|
||||
color="#7289da"
|
||||
style={{
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
marginTop: 5,
|
||||
}}
|
||||
onPress={() => {
|
||||
Linking.openURL(links.feedbackDiscord);
|
||||
}}>
|
||||
Discord
|
||||
</Button>
|
||||
</View>
|
||||
) : (
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
flexWrap: 'wrap',
|
||||
flexDirection: 'row',
|
||||
width: '100%',
|
||||
}}>
|
||||
<Button
|
||||
icon="git"
|
||||
mode="contained"
|
||||
color="#609927"
|
||||
style={{
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
marginTop: 5,
|
||||
}}
|
||||
onPress={() => {
|
||||
Linking.openURL(links.bugsGit);
|
||||
}}>
|
||||
GITETUD
|
||||
</Button>
|
||||
<Button
|
||||
icon="calendar"
|
||||
mode="contained"
|
||||
color="#026AA7"
|
||||
style={{
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
marginTop: 5,
|
||||
}}
|
||||
onPress={() => {
|
||||
Linking.openURL(links.trello);
|
||||
}}>
|
||||
TRELLO
|
||||
</Button>
|
||||
</View>
|
||||
)}
|
||||
</Card.Actions>
|
||||
);
|
||||
}
|
||||
|
||||
render(): React.Node {
|
||||
const {theme} = this.props;
|
||||
return (
|
||||
<CollapsibleScrollView style={{padding: 5}}>
|
||||
<Card>
|
||||
<Card.Title
|
||||
title={i18n.t('screens.feedback.bugs')}
|
||||
subtitle={i18n.t('screens.feedback.bugsSubtitle')}
|
||||
left={(iconProps: CardTitleIconPropsType): React.Node => (
|
||||
<Avatar.Icon size={iconProps.size} icon="bug" />
|
||||
)}
|
||||
/>
|
||||
<Card.Content>
|
||||
<Paragraph>{i18n.t('screens.feedback.bugsDescription')}</Paragraph>
|
||||
<Paragraph style={{color: theme.colors.primary}}>
|
||||
{i18n.t('screens.feedback.contactMeans')}
|
||||
</Paragraph>
|
||||
</Card.Content>
|
||||
{FeedbackScreen.getButtons(true)}
|
||||
</Card>
|
||||
|
||||
<Card style={{marginTop: 20, marginBottom: 10}}>
|
||||
<Card.Title
|
||||
title={i18n.t('screens.feedback.title')}
|
||||
title={i18n.t('screens.feedback.feedback')}
|
||||
subtitle={i18n.t('screens.feedback.feedbackSubtitle')}
|
||||
left={(iconProps: CardTitleIconPropsType): React.Node => (
|
||||
<Avatar.Icon size={iconProps.size} icon="comment" />
|
||||
|
@ -117,6 +137,19 @@ class FeedbackScreen extends React.Component<PropsType> {
|
|||
{i18n.t('screens.feedback.feedbackDescription')}
|
||||
</Paragraph>
|
||||
</Card.Content>
|
||||
{FeedbackScreen.getButtons(true)}
|
||||
<Card.Title
|
||||
title={i18n.t('screens.feedback.contribute')}
|
||||
subtitle={i18n.t('screens.feedback.contributeSubtitle')}
|
||||
left={(iconProps: CardTitleIconPropsType): React.Node => (
|
||||
<Avatar.Icon size={iconProps.size} icon="handshake" />
|
||||
)}
|
||||
/>
|
||||
<Card.Content>
|
||||
<Paragraph>
|
||||
{i18n.t('screens.feedback.contributeDescription')}
|
||||
</Paragraph>
|
||||
</Card.Content>
|
||||
{FeedbackScreen.getButtons(false)}
|
||||
</Card>
|
||||
</CollapsibleScrollView>
|
||||
|
|
|
@ -5,7 +5,7 @@ import {View} from 'react-native';
|
|||
import {Card} from 'react-native-paper';
|
||||
import i18n from 'i18n-js';
|
||||
import {StackNavigationProp} from '@react-navigation/stack';
|
||||
import {getDateOnlyString, getFormattedEventTime} from '../../utils/Planning';
|
||||
import {getDateOnlyString, getTimeOnlyString} from '../../utils/Planning';
|
||||
import DateManager from '../../managers/DateManager';
|
||||
import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen';
|
||||
import {apiRequest, ERROR_TYPE} from '../../utils/WebData';
|
||||
|
@ -96,12 +96,9 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
|||
const {navigation} = this.props;
|
||||
const {displayData} = this;
|
||||
if (displayData == null) return null;
|
||||
let subtitle = getFormattedEventTime(
|
||||
displayData.date_begin,
|
||||
displayData.date_end,
|
||||
);
|
||||
let subtitle = getTimeOnlyString(displayData.date_begin);
|
||||
const dateString = getDateOnlyString(displayData.date_begin);
|
||||
if (dateString !== null)
|
||||
if (dateString !== null && subtitle != null)
|
||||
subtitle += ` | ${DateManager.getInstance().getTranslatedDate(
|
||||
dateString,
|
||||
)}`;
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
generateEventAgenda,
|
||||
getCurrentDateString,
|
||||
getDateOnlyString,
|
||||
getFormattedEventTime,
|
||||
getTimeOnlyString,
|
||||
} from '../../utils/Planning';
|
||||
import CustomAgenda from '../../components/Overrides/CustomAgenda';
|
||||
import {MASCOT_STYLE} from '../../components/Mascot/Mascot';
|
||||
|
@ -198,7 +198,7 @@ class PlanningScreen extends React.Component<PropsType, StateType> {
|
|||
<Divider />
|
||||
<List.Item
|
||||
title={item.title}
|
||||
description={getFormattedEventTime(item.date_begin, item.date_end)}
|
||||
description={getTimeOnlyString(item.date_begin)}
|
||||
left={(): React.Node => (
|
||||
<Avatar.Image
|
||||
source={{uri: item.logo}}
|
||||
|
@ -215,7 +215,7 @@ class PlanningScreen extends React.Component<PropsType, StateType> {
|
|||
<Divider />
|
||||
<List.Item
|
||||
title={item.title}
|
||||
description={getFormattedEventTime(item.date_begin, item.date_end)}
|
||||
description={getTimeOnlyString(item.date_begin)}
|
||||
onPress={onPress}
|
||||
/>
|
||||
</View>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
import {stringToDate} from './Planning';
|
||||
import type {EventType} from '../screens/Home/HomeScreen';
|
||||
import type {PlanningEventType} from './Planning';
|
||||
|
||||
/**
|
||||
* Gets the time limit depending on the current day:
|
||||
|
@ -20,20 +20,6 @@ export function getTodayEventTimeLimit(): Date {
|
|||
return now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the duration (in milliseconds) of an event
|
||||
*
|
||||
* @param event {EventType}
|
||||
* @return {number} The number of milliseconds
|
||||
*/
|
||||
export function getEventDuration(event: EventType): number {
|
||||
const start = stringToDate(event.date_begin);
|
||||
const end = stringToDate(event.date_end);
|
||||
let duration = 0;
|
||||
if (start != null && end != null) duration = end - start;
|
||||
return duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets events starting after the limit
|
||||
*
|
||||
|
@ -42,11 +28,11 @@ export function getEventDuration(event: EventType): number {
|
|||
* @return {Array<Object>}
|
||||
*/
|
||||
export function getEventsAfterLimit(
|
||||
events: Array<EventType>,
|
||||
events: Array<PlanningEventType>,
|
||||
limit: Date,
|
||||
): Array<EventType> {
|
||||
): Array<PlanningEventType> {
|
||||
const validEvents = [];
|
||||
events.forEach((event: EventType) => {
|
||||
events.forEach((event: PlanningEventType) => {
|
||||
const startDate = stringToDate(event.date_begin);
|
||||
if (startDate != null && startDate >= limit) {
|
||||
validEvents.push(event);
|
||||
|
@ -55,44 +41,19 @@ export function getEventsAfterLimit(
|
|||
return validEvents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the event with the longest duration in the given array.
|
||||
* If all events have the same duration, return the first in the array.
|
||||
*
|
||||
* @param events
|
||||
*/
|
||||
export function getLongestEvent(events: Array<EventType>): EventType {
|
||||
let longestEvent = events[0];
|
||||
let longestTime = 0;
|
||||
events.forEach((event: EventType) => {
|
||||
const time = getEventDuration(event);
|
||||
if (time > longestTime) {
|
||||
longestTime = time;
|
||||
longestEvent = event;
|
||||
}
|
||||
});
|
||||
return longestEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets events that have not yet ended/started
|
||||
*
|
||||
* @param events
|
||||
*/
|
||||
export function getFutureEvents(events: Array<EventType>): Array<EventType> {
|
||||
export function getFutureEvents(
|
||||
events: Array<PlanningEventType>,
|
||||
): Array<PlanningEventType> {
|
||||
const validEvents = [];
|
||||
const now = new Date();
|
||||
events.forEach((event: EventType) => {
|
||||
events.forEach((event: PlanningEventType) => {
|
||||
const startDate = stringToDate(event.date_begin);
|
||||
const endDate = stringToDate(event.date_end);
|
||||
if (startDate != null) {
|
||||
if (startDate > now) validEvents.push(event);
|
||||
else if (endDate != null) {
|
||||
if (endDate > now || endDate < startDate)
|
||||
// Display event if it ends the following day
|
||||
validEvents.push(event);
|
||||
}
|
||||
}
|
||||
if (startDate != null && startDate > now) validEvents.push(event);
|
||||
});
|
||||
return validEvents;
|
||||
}
|
||||
|
@ -101,23 +62,19 @@ export function getFutureEvents(events: Array<EventType>): Array<EventType> {
|
|||
* Gets the event to display in the preview
|
||||
*
|
||||
* @param events
|
||||
* @return {EventType | null}
|
||||
* @return {PlanningEventType | null}
|
||||
*/
|
||||
export function getDisplayEvent(events: Array<EventType>): EventType | null {
|
||||
export function getDisplayEvent(
|
||||
events: Array<PlanningEventType>,
|
||||
): PlanningEventType | null {
|
||||
let displayEvent = null;
|
||||
if (events.length > 1) {
|
||||
const eventsAfterLimit = getEventsAfterLimit(
|
||||
events,
|
||||
getTodayEventTimeLimit(),
|
||||
);
|
||||
if (eventsAfterLimit.length > 0) {
|
||||
if (eventsAfterLimit.length === 1) [displayEvent] = eventsAfterLimit;
|
||||
else displayEvent = getLongestEvent(events);
|
||||
} else {
|
||||
displayEvent = getLongestEvent(events);
|
||||
}
|
||||
} else if (events.length === 1) {
|
||||
[displayEvent] = events;
|
||||
}
|
||||
if (eventsAfterLimit.length > 0) [displayEvent] = eventsAfterLimit;
|
||||
else [displayEvent] = events;
|
||||
} else if (events.length === 1) [displayEvent] = events;
|
||||
return displayEvent;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
export type PlanningEventType = {
|
||||
id: number,
|
||||
title: string,
|
||||
logo: string,
|
||||
date_begin: string,
|
||||
date_end: string,
|
||||
description: string,
|
||||
club: string,
|
||||
category_id: number,
|
||||
description: string,
|
||||
place: string,
|
||||
url: string,
|
||||
logo: string | null,
|
||||
};
|
||||
|
||||
// Regex used to check date string validity
|
||||
|
@ -120,50 +120,6 @@ export function getTimeOnlyString(dateString: string): string | null {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string corresponding to the event start and end times in the following format:
|
||||
*
|
||||
* HH:MM - HH:MM
|
||||
*
|
||||
* If the end date is not specified or is equal to start time, only start time will be shown.
|
||||
*
|
||||
* If the end date is not on the same day, 23:59 will be shown as end time
|
||||
*
|
||||
* @param start Start time in YYYY-MM-DD HH:MM:SS format
|
||||
* @param end End time in YYYY-MM-DD HH:MM:SS format
|
||||
* @return {string} Formatted string or "/ - /" on error
|
||||
*/
|
||||
export function getFormattedEventTime(start: string, end: string): string {
|
||||
let formattedStr = '/ - /';
|
||||
const startDate = stringToDate(start);
|
||||
const endDate = stringToDate(end);
|
||||
|
||||
if (
|
||||
startDate !== null &&
|
||||
endDate !== null &&
|
||||
startDate.getTime() !== endDate.getTime()
|
||||
) {
|
||||
formattedStr = `${String(startDate.getHours()).padStart(2, '0')}:${String(
|
||||
startDate.getMinutes(),
|
||||
).padStart(2, '0')} - `;
|
||||
if (
|
||||
endDate.getFullYear() > startDate.getFullYear() ||
|
||||
endDate.getMonth() > startDate.getMonth() ||
|
||||
endDate.getDate() > startDate.getDate()
|
||||
)
|
||||
formattedStr += '23:59';
|
||||
else
|
||||
formattedStr += `${String(endDate.getHours()).padStart(2, '0')}:${String(
|
||||
endDate.getMinutes(),
|
||||
).padStart(2, '0')}`;
|
||||
} else if (startDate !== null)
|
||||
formattedStr = `${String(startDate.getHours()).padStart(2, '0')}:${String(
|
||||
startDate.getMinutes(),
|
||||
).padStart(2, '0')}`;
|
||||
|
||||
return formattedStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given description can be considered empty.
|
||||
* <br>
|
||||
|
|
Loading…
Reference in a new issue