diff --git a/components/CustomIntroSlider.js b/components/CustomIntroSlider.js index 9ca2e50..47a467f 100644 --- a/components/CustomIntroSlider.js +++ b/components/CustomIntroSlider.js @@ -116,7 +116,7 @@ export default class CustomIntroSlider extends React.Component { key: '1', title: i18n.t('intro.aprilFoolsSlide.title'), text: i18n.t('intro.aprilFoolsSlide.text'), - icon: 'information', + icon: 'fish', colors: ['#e01928', '#be1522'], }, ]; diff --git a/components/SquareDashboardItem.js b/components/SquareDashboardItem.js index c071bce..da23cfb 100644 --- a/components/SquareDashboardItem.js +++ b/components/SquareDashboardItem.js @@ -1,54 +1,32 @@ import * as React from 'react'; -import {Card, Text, Title, withTheme} from 'react-native-paper'; +import {Badge, IconButton, withTheme} from 'react-native-paper'; import {View} from "react-native"; -import {MaterialCommunityIcons} from "@expo/vector-icons"; function SquareDashboardItem(props) { - const { colors } = props.theme; + const {colors} = props.theme; return ( - - - - - - - - {props.title} - - - {props.subtitle} - - - - + + + { + props.badgeNumber > 0 ? + {props.badgeNumber} : null + } + + ); } diff --git a/screens/HomeScreen.js b/screens/HomeScreen.js index 5cfd4be..be79447 100644 --- a/screens/HomeScreen.js +++ b/screens/HomeScreen.js @@ -1,14 +1,13 @@ // @flow import * as React from 'react'; -import {TouchableOpacity, View} from 'react-native'; +import {View} from 'react-native'; import i18n from "i18n-js"; -import Autolink from 'react-native-autolink'; import ThemeManager from "../utils/ThemeManager"; import DashboardItem from "../components/EventDashboardItem"; import * as WebBrowser from 'expo-web-browser'; import WebSectionList from "../components/WebSectionList"; -import {Avatar, Button, Card, Text} from 'react-native-paper'; +import {Text} from 'react-native-paper'; import FeedItem from "../components/FeedItem"; import SquareDashboardItem from "../components/SquareDashboardItem"; import PreviewEventDashboardItem from "../components/PreviewEventDashboardItem"; @@ -109,36 +108,32 @@ export default class HomeScreen extends React.Component { generateDashboardDataset(dashboardData: Object) { let dataset = [ + + { + id: 'middle', + content: [] + }, { id: 'event', content: undefined }, - { - id: 'middle', - content: [{}, {}] - }, - { - id: 'bottom', - content: [{}, {}] - }, - ]; for (let [key, value] of Object.entries(dashboardData)) { switch (key) { case 'today_events': - dataset[0]['content'] = value; + dataset[1]['content'] = value; break; case 'available_machines': - dataset[1]['content'][0] = {id: key, data: value}; + dataset[0]['content'][0] = {id: key, data: value}; break; case 'available_tutorials': - dataset[1]['content'][1] = {id: key, data: value}; + dataset[0]['content'][1] = {id: key, data: value}; break; case 'proximo_articles': - dataset[2]['content'][0] = {id: key, data: value}; + dataset[0]['content'][2] = {id: key, data: value}; break; case 'today_menu': - dataset[2]['content'][1] = {id: key, data: value}; + dataset[0]['content'][3] = {id: key, data: value}; break; } @@ -152,8 +147,6 @@ export default class HomeScreen extends React.Component { return this.getDashboardEventItem(content); else if (item['id'] === 'middle') return this.getDashboardMiddleItem(content); - else - return this.getDashboardBottomItem(content); } /** @@ -310,7 +303,8 @@ export default class HomeScreen extends React.Component { let displayEvent = this.getDisplayEvent(futureEvents); const clickContainerAction = () => this.props.navigation.navigate('Planning'); - const clickPreviewAction = () => this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent});; + const clickPreviewAction = () => this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent}); + return ( { } - getDashboardBottomItem(content: Array) { - let proximoData = content[0]['data']; - let menuData = content[1]['data']; - let proximoIcon = 'shopping'; - let proximoColor = ThemeManager.getCurrentThemeVariables().proximoColor; - let proximoTitle = i18n.t('homeScreen.dashboard.proximoTitle'); - let isProximoAvailable = parseInt(proximoData) > 0; - let proximoSubtitle; - if (isProximoAvailable) { - proximoSubtitle = - - {proximoData} - - { - proximoData > 1 ? - i18n.t('homeScreen.dashboard.proximoSubtitlePlural') : - i18n.t('homeScreen.dashboard.proximoSubtitle') - } - - ; - } else - proximoSubtitle = i18n.t('homeScreen.dashboard.proximoSubtitleNA'); - - - let menuIcon = 'silverware-fork-knife'; - let menuColor = ThemeManager.getCurrentThemeVariables().menuColor; - let menuTitle = i18n.t('homeScreen.dashboard.menuTitle'); - let isMenuAvailable = menuData.length > 0; - let menuSubtitle; - if (isMenuAvailable) { - menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitle'); - } else - menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitleNA'); - return ( - - - - - ); - } - - getDashboardMiddleItem(content: Array) { let proxiwashData = content[0]['data']; let tutorinsaData = content[1]['data']; - - let proxiwashIcon = 'washing-machine'; - let proxiwashColor = ThemeManager.getCurrentThemeVariables().proxiwashColor; - let proxiwashTitle = i18n.t('homeScreen.dashboard.proxiwashTitle'); - let proxiwashIsAvailable = parseInt(proxiwashData['dryers']) > 0 || parseInt(proxiwashData['washers']) > 0; - let proxiwashSubtitle; - let dryerColor = parseInt(proxiwashData['dryers']) > 0 ? - ThemeManager.getCurrentThemeVariables().text : - ThemeManager.getCurrentThemeVariables().textDisabled; - let washerColor = parseInt(proxiwashData['washers']) > 0 ? - ThemeManager.getCurrentThemeVariables().text : - ThemeManager.getCurrentThemeVariables().textDisabled; - let availableDryers = proxiwashData['dryers']; - let availableWashers = proxiwashData['washers']; - if (proxiwashIsAvailable) { - proxiwashSubtitle = - - 0 ? - 'bold' : - 'normal', - color: dryerColor - }}> - {availableDryers} - - - { - availableDryers > 1 ? - i18n.t('homeScreen.dashboard.proxiwashSubtitle1Plural') : - i18n.t('homeScreen.dashboard.proxiwashSubtitle1') - } - - {"\n"} - 0 ? - 'bold' : - 'normal', - color: washerColor - }}> - {availableWashers} - - - { - availableWashers > 1 ? - i18n.t('homeScreen.dashboard.proxiwashSubtitle2Plural') : - i18n.t('homeScreen.dashboard.proxiwashSubtitle2') - } - - ; - } else - proxiwashSubtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA'); - - let tutorinsaIcon = 'school'; - let tutorinsaColor = ThemeManager.getCurrentThemeVariables().tutorinsaColor; - let tutorinsaTitle = 'Tutor\'INSA'; - let tutorinsaIsAvailable = tutorinsaData > 0; - let tutorinsaSubtitle; - if (tutorinsaIsAvailable) { - tutorinsaSubtitle = - - {tutorinsaData} - - { - tutorinsaData > 1 ? - i18n.t('homeScreen.dashboard.tutorinsaSubtitlePlural') : - i18n.t('homeScreen.dashboard.tutorinsaSubtitle') - } - - ; - } else - tutorinsaSubtitle = i18n.t('homeScreen.dashboard.tutorinsaSubtitleNA'); - + let proximoData = content[2]['data']; + let menuData = content[3]['data']; return ( + isAvailable={parseInt(proxiwashData['washers']) > 0} + badgeNumber={proxiwashData['washers']} + /> 0} + badgeNumber={proxiwashData['dryers']} + /> + + isAvailable={tutorinsaData > 0} + badgeNumber={tutorinsaData} + /> + 0} + badgeNumber={parseInt(proximoData)} + /> + 0} + badgeNumber={0} + /> ); } diff --git a/utils/AprilFoolsManager.js b/utils/AprilFoolsManager.js index cf00f31..c2b97b0 100644 --- a/utils/AprilFoolsManager.js +++ b/utils/AprilFoolsManager.js @@ -25,32 +25,29 @@ export default class AprilFoolsManager { } static getFakeMenuItem(menu: Object) { - if (menu[1]["dishes"].length >= 3) { - menu[1]["dishes"].splice(0, 0, {name: "Coq au vin"}); - menu[1]["dishes"].splice(2, 0, {name: "Pave de loup"}); - } else { - menu[1]["dishes"].push({name: "Coq au vin"}); - menu[1]["dishes"].push({name: "Pave de loup"}); - } + menu[1]["dishes"].splice(2, 0, {name: "Coq au vin"}); + menu[1]["dishes"].splice(1, 0, {name: "Pave de loup"}); + menu[1]["dishes"].splice(0, 0, {name: "Béranger à point"}); + menu[1]["dishes"].splice(0, 0, {name: "Pieds d'Arnaud"}); return menu; } - static getAprilFoolsTheme(currentTheme : Object) { + static getAprilFoolsTheme(currentTheme: Object) { return { ...currentTheme, colors: { ...currentTheme.colors, primary: '#00be45', accent: '#00be45', - background: '#50005b', - tabBackground: "#50005b", - card: "#50005b", - surface: "#50005b", - dividerBackground: '#3e0047', + background: '#d02eee', + tabIcon: "#380d43", + card: "#eed639", + surface: "#eed639", + dividerBackground: '#c72ce4', textDisabled: '#b9b9b9', // Calendar/Agenda - agendaBackgroundColor: '#5b3e02', + agendaBackgroundColor: '#c72ce4', agendaDayTextColor: '#6d6d6d', }, }; diff --git a/utils/ThemeManager.js b/utils/ThemeManager.js index 3faaa40..91fd936 100644 --- a/utils/ThemeManager.js +++ b/utils/ThemeManager.js @@ -120,7 +120,7 @@ export default class ThemeManager { */ static getCurrentTheme(): Object { if (AprilFoolsManager.getInstance().isAprilFoolsEnabled()) - return AprilFoolsManager.getAprilFoolsTheme(ThemeManager.getDarkTheme()); + return AprilFoolsManager.getAprilFoolsTheme(ThemeManager.getWhiteTheme()); else return ThemeManager.getBaseTheme() }