diff --git a/screens/HomeScreen.js b/screens/HomeScreen.js
index 88bc9af..37b3220 100644
--- a/screens/HomeScreen.js
+++ b/screens/HomeScreen.js
@@ -2,13 +2,16 @@
import * as React from 'react';
import {Image, Linking, TouchableOpacity, View} from 'react-native';
-import {Body, Button, Card, CardItem, Left, Right, Text, Thumbnail, H1, H3} from 'native-base';
+import {Body, Button, Card, CardItem, Left, Right, Text, Thumbnail, H1, H3, Content} from 'native-base';
import i18n from "i18n-js";
import CustomMaterialIcon from '../components/CustomMaterialIcon';
import FetchedDataSectionList from "../components/FetchedDataSectionList";
import Autolink from 'react-native-autolink';
import ThemeManager from "../utils/ThemeManager";
import PlatformTouchable from "react-native-platform-touchable";
+import HTML from 'react-native-render-html';
+import {LinearGradient} from 'expo-linear-gradient';
+
const ICON_AMICALE = require('../assets/amicale.png');
const NAME_AMICALE = 'Amicale INSA Toulouse';
@@ -75,14 +78,36 @@ export default class HomeScreen extends FetchedDataSectionList {
}
generateDashboardDataset(dashboardData: Object) {
- let dataset = [];
+ let dataset = [
+ {
+ id: 'top',
+ content: {}
+ },
+ {
+ id: 'middle',
+ content: [{}, {}]
+ },
+ {
+ id: 'bottom',
+ content: {}
+ },
+
+ ];
for (let [key, value] of Object.entries(dashboardData)) {
- dataset.push(
- {
- id: key,
- data: value
- }
- )
+ switch (key) {
+ case 'today_events':
+ dataset[0]['content'] = value;
+ break;
+ case 'proximo_articles':
+ dataset[1]['content'][0] = {id: key, data: value};
+ break;
+ case 'today_menu':
+ dataset[1]['content'][1] = {id: key, data: value};
+ break;
+ case 'available_machines':
+ dataset[2]['content'] = value;
+ break;
+ }
}
return dataset
}
@@ -117,155 +142,383 @@ export default class HomeScreen extends FetchedDataSectionList {
}
}
- getDashboardItemData(item: Object) {
- let icon = '';
- let title = '';
- let subtitle;
- let clickAction;
- let isAvailable = false;
- let color = ThemeManager.getCurrentThemeVariables().disabledTextColor;
- switch (item['id']) {
- case 'today_events':
- icon = 'calendar-range';
- color = ThemeManager.getCurrentThemeVariables().planningColor;
- title = i18n.t('homeScreen.dashboard.todayEventsTitle');
- isAvailable = item['data'].length > 0;
- if (isAvailable) {
- subtitle =
-
- {item['data'].length}
- {i18n.t('homeScreen.dashboard.todayEventsSubtitle')}
- ;
- } else
- subtitle = i18n.t('homeScreen.dashboard.todayEventsSubtitleNA');
- clickAction = () => this.props.navigation.navigate('Planning');
- break;
- case 'proximo_articles':
- icon = 'shopping';
- color = ThemeManager.getCurrentThemeVariables().proximoColor;
- title = i18n.t('homeScreen.dashboard.proximoTitle');
- isAvailable = parseInt(item['data']) > 0;
- if (isAvailable) {
- subtitle =
-
- {item['data']}
- {i18n.t('homeScreen.dashboard.proximoSubtitle')}
- ;
- } else
- subtitle = i18n.t('homeScreen.dashboard.proximoSubtitleNA');
- clickAction = () => this.props.navigation.navigate('Proximo');
- break;
- case 'available_machines':
- icon = 'washing-machine';
- color = ThemeManager.getCurrentThemeVariables().proxiwashColor;
- title = i18n.t('homeScreen.dashboard.proxiwashTitle');
- isAvailable = parseInt(item['data']['dryers']) > 0 || parseInt(item['data']['washers']) > 0;
- if (isAvailable) {
- subtitle =
-
- 0 ?
- 'bold' :
- 'normal',
- color: parseInt(item['data']['dryers']) > 0 ?
- ThemeManager.getCurrentThemeVariables().textColor :
- ThemeManager.getCurrentThemeVariables().listNoteColor
- }}>
- {item['data']['dryers']}
-
- {i18n.t('homeScreen.dashboard.proxiwashSubtitle1')}
- 0 ?
- 'bold' :
- 'normal',
- color: parseInt(item['data']['washers']) > 0 ?
- ThemeManager.getCurrentThemeVariables().textColor :
- ThemeManager.getCurrentThemeVariables().listNoteColor
- }}>
- {item['data']['washers']}
-
- {i18n.t('homeScreen.dashboard.proxiwashSubtitle2')}
- ;
- } else
- subtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA');
- clickAction = () => this.props.navigation.navigate('Proxiwash');
- break;
- case 'today_menu':
- icon = 'silverware-fork-knife';
- color = ThemeManager.getCurrentThemeVariables().menuColor;
- title = i18n.t('homeScreen.dashboard.menuTitle');
- isAvailable = item['data'].length > 0;
- if (isAvailable) {
- subtitle = i18n.t('homeScreen.dashboard.menuSubtitle');
- } else
- subtitle = i18n.t('homeScreen.dashboard.menuSubtitleNA');
- clickAction = () => this.props.navigation.navigate('SelfMenuScreen');
- break;
+ getDashboardItem(item: Object) {
+ let content = item['content'];
+ if (item['id'] === 'top')
+ return this.getDashboardTopItem(content);
+ else if (item['id'] === 'middle')
+ return this.getDashboardMiddleItem(content);
+ else
+ return this.getDashboardBottomItem(content);
+ }
+
+ getDisplayEvent(events: Array