forked from vergnet/application-amicale
Added basic april fools functionality
This commit is contained in:
parent
b625ac7255
commit
9e90c9d8f3
4 changed files with 105 additions and 14 deletions
|
@ -8,6 +8,7 @@ import WebDataManager from "../utils/WebDataManager";
|
|||
import PlanningEventManager from '../utils/PlanningEventManager';
|
||||
import {Avatar, Divider, List} from 'react-native-paper';
|
||||
import CustomAgenda from "../components/CustomAgenda";
|
||||
import AprilFoolsManager from "../utils/AprilFoolsManager";
|
||||
|
||||
LocaleConfig.locales['fr'] = {
|
||||
monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
|
||||
|
@ -209,6 +210,8 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
|||
this.pushEventInOrder(agendaItems, eventList[i], PlanningEventManager.getEventStartDate(eventList[i]));
|
||||
}
|
||||
}
|
||||
if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
|
||||
agendaItems["2020-04-01"].push(AprilFoolsManager.getFakeEvent());
|
||||
this.setState({agendaItems: agendaItems})
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ import {View} from 'react-native';
|
|||
import ThemeManager from "../utils/ThemeManager";
|
||||
import i18n from "i18n-js";
|
||||
import WebSectionList from "../components/WebSectionList";
|
||||
import {Card, Text, Title} from 'react-native-paper';
|
||||
import {Card, Text} from 'react-native-paper';
|
||||
import AprilFoolsManager from "../utils/AprilFoolsManager";
|
||||
|
||||
const DATA_URL = "https://etud.insa-toulouse.fr/~amicale_app/menu/menu_data.json";
|
||||
|
||||
|
@ -72,6 +73,8 @@ export default class SelfMenuScreen extends React.Component<Props> {
|
|||
}
|
||||
];
|
||||
}
|
||||
if (AprilFoolsManager.getInstance().isAprilFoolsEnabled() && fetchedData.length > 0)
|
||||
fetchedData[0].meal[0].foodcategory = AprilFoolsManager.getFakeMenuItem(fetchedData[0].meal[0].foodcategory);
|
||||
// fetched data is an array here
|
||||
for (let i = 0; i < fetchedData.length; i++) {
|
||||
result.push(
|
||||
|
@ -125,18 +128,18 @@ export default class SelfMenuScreen extends React.Component<Props> {
|
|||
flex: 0,
|
||||
margin: 10,
|
||||
}}>
|
||||
<Card.Title
|
||||
title={item.name}
|
||||
/>
|
||||
<View style={{
|
||||
width: '80%',
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: ThemeManager.getCurrentThemeVariables().primary,
|
||||
marginTop: 10,
|
||||
marginBottom: 5,
|
||||
}}/>
|
||||
<Card.Title
|
||||
title={item.name}
|
||||
/>
|
||||
<View style={{
|
||||
width: '80%',
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: ThemeManager.getCurrentThemeVariables().primary,
|
||||
marginTop: 10,
|
||||
marginBottom: 5,
|
||||
}}/>
|
||||
<Card.Content>
|
||||
{item.dishes.map((object) =>
|
||||
<View>
|
||||
|
|
56
utils/AprilFoolsManager.js
Normal file
56
utils/AprilFoolsManager.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
// @flow
|
||||
|
||||
/**
|
||||
* Singleton class used to manage themes
|
||||
*/
|
||||
export default class AprilFoolsManager {
|
||||
|
||||
static instance: AprilFoolsManager | null = null;
|
||||
|
||||
aprilFoolsEnabled: boolean;
|
||||
|
||||
constructor() {
|
||||
let today = new Date();
|
||||
this.aprilFoolsEnabled = (today.getDate() === 1 && today.getMonth() === 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this class instance or create one if none is found
|
||||
* @returns {ThemeManager}
|
||||
*/
|
||||
static getInstance(): AprilFoolsManager {
|
||||
return AprilFoolsManager.instance === null ?
|
||||
AprilFoolsManager.instance = new AprilFoolsManager() :
|
||||
AprilFoolsManager.instance;
|
||||
}
|
||||
|
||||
static getFakeEvent() {
|
||||
return {
|
||||
category_id: 1,
|
||||
club: "Coucou",
|
||||
date_begin: "2020-04-01 20:30:00",
|
||||
date_end: "2020-04-01 23:59:00",
|
||||
description: "Trop génial",
|
||||
id: "-1",
|
||||
logo: null,
|
||||
title: "Super event trop whoaou",
|
||||
url: null
|
||||
};
|
||||
}
|
||||
|
||||
static getFakeMenuItem(menu: Object) {
|
||||
if (menu[1]["dishes"].length >= 3) {
|
||||
menu[1]["dishes"].splice(0, 0, {name: "Truc à la con"});
|
||||
menu[1]["dishes"].splice(2, 0, {name: "Autre truc à la con"});
|
||||
} else {
|
||||
menu[1]["dishes"].push({name: "Truc à la con"});
|
||||
menu[1]["dishes"].push({name: "Autre truc à la con"});
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
isAprilFoolsEnabled() {
|
||||
return this.aprilFoolsEnabled;
|
||||
}
|
||||
|
||||
};
|
|
@ -1,8 +1,9 @@
|
|||
// @flow
|
||||
|
||||
import AsyncStorageManager from "./AsyncStorageManager";
|
||||
// import {DarkTheme as NavDarkTheme, DefaultTheme as NavDefaultTheme} from '@react-navigation/native';
|
||||
import {DarkTheme, DefaultTheme} from 'react-native-paper';
|
||||
import AprilFoolsManager from "./AprilFoolsManager";
|
||||
|
||||
/**
|
||||
* Singleton class used to manage themes
|
||||
*/
|
||||
|
@ -92,6 +93,27 @@ export default class ThemeManager {
|
|||
};
|
||||
}
|
||||
|
||||
static getAprilFoolsTheme() {
|
||||
return {
|
||||
...ThemeManager.getBaseTheme(),
|
||||
colors: {
|
||||
...ThemeManager.getBaseTheme().colors,
|
||||
primary: '#bebe03',
|
||||
accent: '#bebe03',
|
||||
background: '#5b3e02',
|
||||
tabBackground: "#5b3e02",
|
||||
card: "#5b3e02",
|
||||
surface: "#5b3e02",
|
||||
dividerBackground: '#362201',
|
||||
textDisabled: '#b9b9b9',
|
||||
|
||||
// Calendar/Agenda
|
||||
agendaBackgroundColor: '#5b3e02',
|
||||
agendaDayTextColor: '#6d6d6d',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this class instance or create one if none is found
|
||||
* @returns {ThemeManager}
|
||||
|
@ -114,6 +136,13 @@ export default class ThemeManager {
|
|||
* @returns {Object}
|
||||
*/
|
||||
static getCurrentTheme(): Object {
|
||||
if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
|
||||
return ThemeManager.getAprilFoolsTheme();
|
||||
else
|
||||
ThemeManager.getBaseTheme()
|
||||
}
|
||||
|
||||
static getBaseTheme() {
|
||||
if (ThemeManager.getNightMode())
|
||||
return ThemeManager.getDarkTheme();
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue