forked from vergnet/application-amicale
Merge branch 'april-fools' into dev
This commit is contained in:
commit
a9fcbfe719
9 changed files with 150 additions and 21 deletions
17
App.js
17
App.js
|
@ -12,6 +12,7 @@ import {createStackNavigator} from '@react-navigation/stack';
|
||||||
import DrawerNavigator from './navigation/DrawerNavigator';
|
import DrawerNavigator from './navigation/DrawerNavigator';
|
||||||
import NotificationsManager from "./utils/NotificationsManager";
|
import NotificationsManager from "./utils/NotificationsManager";
|
||||||
import {Provider as PaperProvider} from 'react-native-paper';
|
import {Provider as PaperProvider} from 'react-native-paper';
|
||||||
|
import AprilFoolsManager from "./utils/AprilFoolsManager";
|
||||||
|
|
||||||
type Props = {};
|
type Props = {};
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ type State = {
|
||||||
isLoading: boolean,
|
isLoading: boolean,
|
||||||
showIntro: boolean,
|
showIntro: boolean,
|
||||||
showUpdate: boolean,
|
showUpdate: boolean,
|
||||||
|
showAprilFools: boolean,
|
||||||
currentTheme: ?Object,
|
currentTheme: ?Object,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,6 +32,7 @@ export default class App extends React.Component<Props, State> {
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
showIntro: true,
|
showIntro: true,
|
||||||
showUpdate: true,
|
showUpdate: true,
|
||||||
|
showAprilFools: false,
|
||||||
currentTheme: null,
|
currentTheme: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,9 +71,11 @@ export default class App extends React.Component<Props, State> {
|
||||||
this.setState({
|
this.setState({
|
||||||
showIntro: false,
|
showIntro: false,
|
||||||
showUpdate: false,
|
showUpdate: false,
|
||||||
|
showAprilFools: false,
|
||||||
});
|
});
|
||||||
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showIntro.key, '0');
|
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showIntro.key, '0');
|
||||||
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showUpdate5.key, '0');
|
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showUpdate5.key, '0');
|
||||||
|
AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.showAprilFoolsStart.key, '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
|
@ -96,7 +101,8 @@ export default class App extends React.Component<Props, State> {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
currentTheme: ThemeManager.getCurrentTheme(),
|
currentTheme: ThemeManager.getCurrentTheme(),
|
||||||
showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1',
|
showIntro: AsyncStorageManager.getInstance().preferences.showIntro.current === '1',
|
||||||
showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate5.current === '1'
|
showUpdate: AsyncStorageManager.getInstance().preferences.showUpdate5.current === '1',
|
||||||
|
showAprilFools: AprilFoolsManager.getInstance().isAprilFoolsEnabled() && AsyncStorageManager.getInstance().preferences.showAprilFoolsStart.current === '1',
|
||||||
});
|
});
|
||||||
// Status bar goes dark if set too fast
|
// Status bar goes dark if set too fast
|
||||||
setTimeout(this.setupStatusBar, 1000);
|
setTimeout(this.setupStatusBar, 1000);
|
||||||
|
@ -109,9 +115,12 @@ export default class App extends React.Component<Props, State> {
|
||||||
render() {
|
render() {
|
||||||
if (this.state.isLoading) {
|
if (this.state.isLoading) {
|
||||||
return null;
|
return null;
|
||||||
} else if (this.state.showIntro || this.state.showUpdate) {
|
} else if (this.state.showIntro || this.state.showUpdate || this.state.showAprilFools) {
|
||||||
return <CustomIntroSlider onDone={this.onIntroDone}
|
return <CustomIntroSlider
|
||||||
isUpdate={this.state.showUpdate && !this.state.showIntro}/>;
|
onDone={this.onIntroDone}
|
||||||
|
isUpdate={this.state.showUpdate && !this.state.showIntro}
|
||||||
|
isAprilFools={this.state.showAprilFools && !this.state.showIntro}
|
||||||
|
/>;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -39,13 +39,15 @@ const styles = StyleSheet.create({
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onDone: Function,
|
onDone: Function,
|
||||||
isUpdate: boolean
|
isUpdate: boolean,
|
||||||
|
isAprilFools: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class CustomIntroSlider extends React.Component<Props> {
|
export default class CustomIntroSlider extends React.Component<Props> {
|
||||||
|
|
||||||
introSlides: Array<Object>;
|
introSlides: Array<Object>;
|
||||||
updateSlides: Array<Object>;
|
updateSlides: Array<Object>;
|
||||||
|
aprilFoolsSlides: Array<Object>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -108,7 +110,16 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
||||||
icon: 'email',
|
icon: 'email',
|
||||||
colors: ['#e01928', '#be1522'],
|
colors: ['#e01928', '#be1522'],
|
||||||
},
|
},
|
||||||
]
|
];
|
||||||
|
this.aprilFoolsSlides = [
|
||||||
|
{
|
||||||
|
key: '1',
|
||||||
|
title: i18n.t('intro.aprilFoolsSlide.title'),
|
||||||
|
text: i18n.t('intro.aprilFoolsSlide.text'),
|
||||||
|
icon: 'information',
|
||||||
|
colors: ['#e01928', '#be1522'],
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,10 +155,15 @@ export default class CustomIntroSlider extends React.Component<Props> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let slides = this.introSlides;
|
||||||
|
if (this.props.isUpdate)
|
||||||
|
slides = this.updateSlides;
|
||||||
|
else if (this.props.isAprilFools)
|
||||||
|
slides = this.aprilFoolsSlides;
|
||||||
return (
|
return (
|
||||||
<AppIntroSlider
|
<AppIntroSlider
|
||||||
renderItem={CustomIntroSlider.getIntroRenderItem}
|
renderItem={CustomIntroSlider.getIntroRenderItem}
|
||||||
slides={this.props.isUpdate ? this.updateSlides : this.introSlides}
|
slides={slides}
|
||||||
onDone={this.props.onDone}
|
onDone={this.props.onDone}
|
||||||
bottomButton
|
bottomButton
|
||||||
showSkipButton
|
showSkipButton
|
||||||
|
|
|
@ -8,6 +8,7 @@ import WebDataManager from "../utils/WebDataManager";
|
||||||
import PlanningEventManager from '../utils/PlanningEventManager';
|
import PlanningEventManager from '../utils/PlanningEventManager';
|
||||||
import {Avatar, Divider, List} from 'react-native-paper';
|
import {Avatar, Divider, List} from 'react-native-paper';
|
||||||
import CustomAgenda from "../components/CustomAgenda";
|
import CustomAgenda from "../components/CustomAgenda";
|
||||||
|
import AprilFoolsManager from "../utils/AprilFoolsManager";
|
||||||
|
|
||||||
LocaleConfig.locales['fr'] = {
|
LocaleConfig.locales['fr'] = {
|
||||||
monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
|
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]));
|
this.pushEventInOrder(agendaItems, eventList[i], PlanningEventManager.getEventStartDate(eventList[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
|
||||||
|
agendaItems["2020-04-01"].push(AprilFoolsManager.getFakeEvent());
|
||||||
this.setState({agendaItems: agendaItems})
|
this.setState({agendaItems: agendaItems})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ import {View} from 'react-native';
|
||||||
import ThemeManager from "../utils/ThemeManager";
|
import ThemeManager from "../utils/ThemeManager";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import WebSectionList from "../components/WebSectionList";
|
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";
|
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
|
// fetched data is an array here
|
||||||
for (let i = 0; i < fetchedData.length; i++) {
|
for (let i = 0; i < fetchedData.length; i++) {
|
||||||
result.push(
|
result.push(
|
||||||
|
|
|
@ -52,6 +52,10 @@
|
||||||
"title": "New in this update!",
|
"title": "New in this update!",
|
||||||
"text": "Never miss an email anymore! Acces your INSA webmail from the app using the left menu.\nPlanex has also seen some improvements!\n\nSome of your remarks where taken into account for this update, more to come.\nThanks for your feedback on the survey! "
|
"text": "Never miss an email anymore! Acces your INSA webmail from the app using the left menu.\nPlanex has also seen some improvements!\n\nSome of your remarks where taken into account for this update, more to come.\nThanks for your feedback on the survey! "
|
||||||
},
|
},
|
||||||
|
"aprilFoolsSlide": {
|
||||||
|
"title": "New in this update!",
|
||||||
|
"text": "We heard you, you don't like the new design and colors, so we changed them!\nLove."
|
||||||
|
},
|
||||||
"buttons": {
|
"buttons": {
|
||||||
"next": "Next",
|
"next": "Next",
|
||||||
"skip": "Skip",
|
"skip": "Skip",
|
||||||
|
|
|
@ -52,6 +52,10 @@
|
||||||
"title": "Nouveau dans cette mise à jour !",
|
"title": "Nouveau dans cette mise à jour !",
|
||||||
"text": "Ne ratez plus jamais un email ! Accédez à vos mails INSA depuis le menu à gauche.\nPlanex a aussi été un peu amélioré !\n\nUne partie de vos remarques ont été prises en compte pour cette mise à jour, d'autres sont à venir.\nMerci pour votre retour lors du sondage !"
|
"text": "Ne ratez plus jamais un email ! Accédez à vos mails INSA depuis le menu à gauche.\nPlanex a aussi été un peu amélioré !\n\nUne partie de vos remarques ont été prises en compte pour cette mise à jour, d'autres sont à venir.\nMerci pour votre retour lors du sondage !"
|
||||||
},
|
},
|
||||||
|
"aprilFoolsSlide": {
|
||||||
|
"title": "Nouveau dans cette mise à jour !",
|
||||||
|
"text": "Nous vous avons entendu, vous n'aimez pas le nouveau design et couleurs, alors on les as changés !\nLa bise."
|
||||||
|
},
|
||||||
"buttons": {
|
"buttons": {
|
||||||
"next": "Suivant",
|
"next": "Suivant",
|
||||||
"skip": "Passer",
|
"skip": "Passer",
|
||||||
|
|
77
utils/AprilFoolsManager.js
Normal file
77
utils/AprilFoolsManager.js
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
// @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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getAprilFoolsTheme(currentTheme : Object) {
|
||||||
|
return {
|
||||||
|
...currentTheme,
|
||||||
|
colors: {
|
||||||
|
...currentTheme.colors,
|
||||||
|
primary: '#bebe03',
|
||||||
|
accent: '#bebe03',
|
||||||
|
background: '#5b3e02',
|
||||||
|
tabBackground: "#5b3e02",
|
||||||
|
card: "#5b3e02",
|
||||||
|
surface: "#5b3e02",
|
||||||
|
dividerBackground: '#362201',
|
||||||
|
textDisabled: '#b9b9b9',
|
||||||
|
|
||||||
|
// Calendar/Agenda
|
||||||
|
agendaBackgroundColor: '#5b3e02',
|
||||||
|
agendaDayTextColor: '#6d6d6d',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
isAprilFoolsEnabled() {
|
||||||
|
return this.aprilFoolsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
|
@ -74,6 +74,11 @@ export default class AsyncStorageManager {
|
||||||
default: '1',
|
default: '1',
|
||||||
current: '',
|
current: '',
|
||||||
},
|
},
|
||||||
|
showAprilFoolsStart: {
|
||||||
|
key: 'showAprilFoolsStart',
|
||||||
|
default: '1',
|
||||||
|
current: '',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import AsyncStorageManager from "./AsyncStorageManager";
|
import AsyncStorageManager from "./AsyncStorageManager";
|
||||||
// import {DarkTheme as NavDarkTheme, DefaultTheme as NavDefaultTheme} from '@react-navigation/native';
|
|
||||||
import {DarkTheme, DefaultTheme} from 'react-native-paper';
|
import {DarkTheme, DefaultTheme} from 'react-native-paper';
|
||||||
|
import AprilFoolsManager from "./AprilFoolsManager";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singleton class used to manage themes
|
* Singleton class used to manage themes
|
||||||
*/
|
*/
|
||||||
|
@ -114,6 +115,13 @@ export default class ThemeManager {
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
static getCurrentTheme(): Object {
|
static getCurrentTheme(): Object {
|
||||||
|
if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
|
||||||
|
return AprilFoolsManager.getAprilFoolsTheme(ThemeManager.getBaseTheme());
|
||||||
|
else
|
||||||
|
return ThemeManager.getBaseTheme()
|
||||||
|
}
|
||||||
|
|
||||||
|
static getBaseTheme() {
|
||||||
if (ThemeManager.getNightMode())
|
if (ThemeManager.getNightMode())
|
||||||
return ThemeManager.getDarkTheme();
|
return ThemeManager.getDarkTheme();
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue