forked from vergnet/application-amicale
Improved dashboard display
This commit is contained in:
parent
f806152370
commit
158973c74d
6 changed files with 135 additions and 27 deletions
|
@ -243,7 +243,7 @@ export default {
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
textColor: "#000",
|
textColor: "#000",
|
||||||
textDisabledColor: "#d9e1e8",
|
textDisabledColor: "#c1c1c1",
|
||||||
inverseTextColor: "#fff",
|
inverseTextColor: "#fff",
|
||||||
noteFontSize: 14,
|
noteFontSize: 14,
|
||||||
get defaultTextColor() {
|
get defaultTextColor() {
|
||||||
|
@ -273,6 +273,13 @@ export default {
|
||||||
proxiwashBrokenColor: "rgba(162,162,162,0.31)",
|
proxiwashBrokenColor: "rgba(162,162,162,0.31)",
|
||||||
proxiwashErrorColor: "rgba(204,7,0,0.31)",
|
proxiwashErrorColor: "rgba(204,7,0,0.31)",
|
||||||
|
|
||||||
|
// Screens
|
||||||
|
planningColor: '#d9b10a',
|
||||||
|
proximoColor: '#ec5904',
|
||||||
|
proxiwashColor: '#1fa5ee',
|
||||||
|
menuColor: '#e91314',
|
||||||
|
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
borderRadiusBase: platform === "ios" ? 5 : 2,
|
borderRadiusBase: platform === "ios" ? 5 : 2,
|
||||||
borderWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
|
borderWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
|
||||||
|
|
|
@ -244,7 +244,7 @@ export default {
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
textColor: "#ebebeb",
|
textColor: "#ebebeb",
|
||||||
textDisabledColor: "#3b3f42",
|
textDisabledColor: "#5b5b5b",
|
||||||
inverseTextColor: "#000",
|
inverseTextColor: "#000",
|
||||||
noteFontSize: 14,
|
noteFontSize: 14,
|
||||||
get defaultTextColor() {
|
get defaultTextColor() {
|
||||||
|
@ -274,6 +274,11 @@ export default {
|
||||||
proxiwashBrokenColor: "#000000",
|
proxiwashBrokenColor: "#000000",
|
||||||
proxiwashErrorColor: "rgba(213,8,0,0.57)",
|
proxiwashErrorColor: "rgba(213,8,0,0.57)",
|
||||||
|
|
||||||
|
// Screens
|
||||||
|
planningColor: '#d99e09',
|
||||||
|
proximoColor: '#ec5904',
|
||||||
|
proxiwashColor: '#1fa5ee',
|
||||||
|
menuColor: '#b81213',
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
borderRadiusBase: platform === "ios" ? 5 : 2,
|
borderRadiusBase: platform === "ios" ? 5 : 2,
|
||||||
|
|
|
@ -65,7 +65,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
id: SECTIONS_ID[0]
|
id: SECTIONS_ID[0]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'News Feed',
|
title: i18n.t('homeScreen.newsFeed'),
|
||||||
data: newsData,
|
data: newsData,
|
||||||
extraData: super.state,
|
extraData: super.state,
|
||||||
keyExtractor: this.getKeyExtractor,
|
keyExtractor: this.getKeyExtractor,
|
||||||
|
@ -120,45 +120,95 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
getDashboardItemData(item: Object) {
|
getDashboardItemData(item: Object) {
|
||||||
let icon = '';
|
let icon = '';
|
||||||
let title = '';
|
let title = '';
|
||||||
let subtitle = '';
|
let subtitle;
|
||||||
let clickAction;
|
let clickAction;
|
||||||
|
let isAvailable = false;
|
||||||
|
let color = ThemeManager.getCurrentThemeVariables().disabledTextColor;
|
||||||
switch (item['id']) {
|
switch (item['id']) {
|
||||||
case 'today_events':
|
case 'today_events':
|
||||||
icon = 'calendar-range';
|
icon = 'calendar-range';
|
||||||
title = 'Today\s events';
|
color = ThemeManager.getCurrentThemeVariables().planningColor;
|
||||||
if (item['data'].length === 0)
|
title = i18n.t('homeScreen.dashboard.todayEventsTitle');
|
||||||
subtitle = 'Pas d\'event ajd';
|
isAvailable = item['data'].length > 0;
|
||||||
else
|
if (isAvailable) {
|
||||||
subtitle = item['data'].length + ' events ajd';
|
subtitle =
|
||||||
|
<Text>
|
||||||
|
<Text style={{fontWeight: "bold"}}>{item['data'].length}</Text>
|
||||||
|
<Text>{i18n.t('homeScreen.dashboard.todayEventsSubtitle')}</Text>
|
||||||
|
</Text>;
|
||||||
|
} else
|
||||||
|
subtitle = i18n.t('homeScreen.dashboard.todayEventsSubtitleNA');
|
||||||
clickAction = () => this.props.navigation.navigate('Planning');
|
clickAction = () => this.props.navigation.navigate('Planning');
|
||||||
break;
|
break;
|
||||||
case 'proximo_articles':
|
case 'proximo_articles':
|
||||||
icon = 'shopping';
|
icon = 'shopping';
|
||||||
title = 'Proximo';
|
color = ThemeManager.getCurrentThemeVariables().proximoColor;
|
||||||
subtitle = item['data'] + ' articles disponibles';
|
title = i18n.t('homeScreen.dashboard.proximoTitle');
|
||||||
|
isAvailable = parseInt(item['data']) > 0;
|
||||||
|
if (isAvailable) {
|
||||||
|
subtitle =
|
||||||
|
<Text>
|
||||||
|
<Text style={{fontWeight: "bold"}}>{item['data']}</Text>
|
||||||
|
<Text>{i18n.t('homeScreen.dashboard.proximoSubtitle')}</Text>
|
||||||
|
</Text>;
|
||||||
|
} else
|
||||||
|
subtitle = i18n.t('homeScreen.dashboard.proximoSubtitleNA');
|
||||||
clickAction = () => this.props.navigation.navigate('Proximo');
|
clickAction = () => this.props.navigation.navigate('Proximo');
|
||||||
break;
|
break;
|
||||||
case 'available_machines':
|
case 'available_machines':
|
||||||
icon = 'washing-machine';
|
icon = 'washing-machine';
|
||||||
title = 'Machines disponibles';
|
color = ThemeManager.getCurrentThemeVariables().proxiwashColor;
|
||||||
subtitle = item['data']['dryers'] + ' dryers and ' + item['data']['washers'] + ' washers.';
|
title = i18n.t('homeScreen.dashboard.proxiwashTitle');
|
||||||
|
isAvailable = parseInt(item['data']['dryers']) > 0 || parseInt(item['data']['washers']) > 0;
|
||||||
|
if (isAvailable) {
|
||||||
|
subtitle =
|
||||||
|
<Text>
|
||||||
|
<Text style={{
|
||||||
|
fontWeight: parseInt(item['data']['dryers']) > 0 ?
|
||||||
|
'bold' :
|
||||||
|
'normal',
|
||||||
|
color: parseInt(item['data']['dryers']) > 0 ?
|
||||||
|
ThemeManager.getCurrentThemeVariables().textColor :
|
||||||
|
ThemeManager.getCurrentThemeVariables().listNoteColor
|
||||||
|
}}>
|
||||||
|
{item['data']['dryers']}
|
||||||
|
</Text>
|
||||||
|
<Text>{i18n.t('homeScreen.dashboard.proxiwashSubtitle1')}</Text>
|
||||||
|
<Text style={{
|
||||||
|
fontWeight: parseInt(item['data']['washers']) > 0 ?
|
||||||
|
'bold' :
|
||||||
|
'normal',
|
||||||
|
color: parseInt(item['data']['washers']) > 0 ?
|
||||||
|
ThemeManager.getCurrentThemeVariables().textColor :
|
||||||
|
ThemeManager.getCurrentThemeVariables().listNoteColor
|
||||||
|
}}>
|
||||||
|
{item['data']['washers']}
|
||||||
|
</Text>
|
||||||
|
<Text>{i18n.t('homeScreen.dashboard.proxiwashSubtitle2')}</Text>
|
||||||
|
</Text>;
|
||||||
|
} else
|
||||||
|
subtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA');
|
||||||
clickAction = () => this.props.navigation.navigate('Proxiwash');
|
clickAction = () => this.props.navigation.navigate('Proxiwash');
|
||||||
break;
|
break;
|
||||||
case 'today_menu':
|
case 'today_menu':
|
||||||
icon = 'silverware-fork-knife';
|
icon = 'silverware-fork-knife';
|
||||||
title = 'Menu du jour';
|
color = ThemeManager.getCurrentThemeVariables().menuColor;
|
||||||
if (item['data'].length === 0)
|
title = i18n.t('homeScreen.dashboard.menuTitle');
|
||||||
subtitle = 'non disponible';
|
isAvailable = item['data'].length > 0;
|
||||||
else
|
if (isAvailable) {
|
||||||
subtitle = 'Click here to show the menu';
|
subtitle = i18n.t('homeScreen.dashboard.menuSubtitle');
|
||||||
|
} else
|
||||||
|
subtitle = i18n.t('homeScreen.dashboard.menuSubtitleNA');
|
||||||
clickAction = () => this.props.navigation.navigate('SelfMenuScreen');
|
clickAction = () => this.props.navigation.navigate('SelfMenuScreen');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
icon: icon,
|
icon: icon,
|
||||||
|
color: color,
|
||||||
title: title,
|
title: title,
|
||||||
subtitle: subtitle,
|
subtitle: subtitle,
|
||||||
clickAction: clickAction
|
clickAction: clickAction,
|
||||||
|
isAvailable: isAvailable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,20 +220,46 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
<Card style={{
|
<Card style={{
|
||||||
flex: 0,
|
flex: 0,
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
marginRight: 10
|
marginRight: 10,
|
||||||
|
borderRadius: 50,
|
||||||
|
backgroundColor: ThemeManager.getCurrentThemeVariables().cardDefaultBg
|
||||||
}}>
|
}}>
|
||||||
<PlatformTouchable
|
<PlatformTouchable
|
||||||
onPress={itemData['clickAction']}
|
onPress={itemData['clickAction']}
|
||||||
|
style={{
|
||||||
|
zIndex: 100,
|
||||||
|
borderRadius: 50
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<CardItem>
|
<CardItem style={{
|
||||||
|
borderRadius: 50,
|
||||||
|
backgroundColor: 'transparent'
|
||||||
|
}}>
|
||||||
<Left>
|
<Left>
|
||||||
<CustomMaterialIcon
|
<CustomMaterialIcon
|
||||||
icon={itemData['icon']}
|
icon={itemData['icon']}
|
||||||
|
color={
|
||||||
|
itemData['isAvailable'] ?
|
||||||
|
itemData['color'] :
|
||||||
|
ThemeManager.getCurrentThemeVariables().textDisabledColor
|
||||||
|
}
|
||||||
fontSize={40}
|
fontSize={40}
|
||||||
width={40}/>
|
width={40}/>
|
||||||
<Body>
|
<Body>
|
||||||
<H3>{itemData['title']}</H3>
|
<H3 style={{
|
||||||
<Text>{itemData['subtitle']}</Text>
|
color: itemData['isAvailable'] ?
|
||||||
|
ThemeManager.getCurrentThemeVariables().textColor :
|
||||||
|
ThemeManager.getCurrentThemeVariables().listNoteColor
|
||||||
|
}}>
|
||||||
|
{itemData['title']}
|
||||||
|
</H3>
|
||||||
|
<Text style={{
|
||||||
|
color: itemData['isAvailable'] ?
|
||||||
|
ThemeManager.getCurrentThemeVariables().listNoteColor :
|
||||||
|
ThemeManager.getCurrentThemeVariables().textDisabledColor
|
||||||
|
}}>
|
||||||
|
{itemData['subtitle']}
|
||||||
|
</Text>
|
||||||
</Body>
|
</Body>
|
||||||
</Left>
|
</Left>
|
||||||
</CardItem>
|
</CardItem>
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
|
||||||
}
|
}
|
||||||
|
|
||||||
getKeyExtractor(item: Object) {
|
getKeyExtractor(item: Object) {
|
||||||
return item !== undefined ? item.type : undefined;
|
return item !== undefined ? item.type['id'] : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
createDataset(fetchedData: Object) {
|
createDataset(fetchedData: Object) {
|
||||||
|
|
|
@ -53,7 +53,7 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
|
||||||
}
|
}
|
||||||
|
|
||||||
getKeyExtractor(item: Object) {
|
getKeyExtractor(item: Object) {
|
||||||
return item !== undefined ? item.name : undefined;
|
return item !== undefined ? item['date'] + '_' + item['name'] : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasBackButton() {
|
hasBackButton() {
|
||||||
|
@ -79,12 +79,16 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
|
||||||
}
|
}
|
||||||
// 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++) {
|
||||||
|
// Add the date to the item to allow creation of unique list id
|
||||||
|
for (let item of fetchedData[i].meal[0].foodcategory) {
|
||||||
|
item['date'] = fetchedData[i]['date'];
|
||||||
|
}
|
||||||
result.push(
|
result.push(
|
||||||
{
|
{
|
||||||
title: this.getFormattedDate(fetchedData[i].date),
|
title: this.getFormattedDate(fetchedData[i].date),
|
||||||
data: fetchedData[i].meal[0].foodcategory,
|
data: fetchedData[i].meal[0].foodcategory,
|
||||||
extraData: super.state,
|
extraData: super.state,
|
||||||
keyExtractor: this.getKeyExtractor
|
keyExtractor: this.getKeyExtractor,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,23 @@
|
||||||
},
|
},
|
||||||
"homeScreen": {
|
"homeScreen": {
|
||||||
"listUpdated": "List updated!",
|
"listUpdated": "List updated!",
|
||||||
"listUpdateFail": "Error while updating list"
|
"listUpdateFail": "Error while updating list",
|
||||||
|
"newsFeed": "Campus News",
|
||||||
|
"dashboard": {
|
||||||
|
"todayEventsTitle": "Today's events",
|
||||||
|
"todayEventsSubtitleNA": "No events today",
|
||||||
|
"todayEventsSubtitle": " events today",
|
||||||
|
"proximoTitle": "Proximo",
|
||||||
|
"proximoSubtitleNA": "No articles available",
|
||||||
|
"proximoSubtitle": " articles available",
|
||||||
|
"proxiwashTitle": "Available machines",
|
||||||
|
"proxiwashSubtitleNA": "No machines available",
|
||||||
|
"proxiwashSubtitle1": " dryers and ",
|
||||||
|
"proxiwashSubtitle2": " washers",
|
||||||
|
"menuTitle": "Today's menu",
|
||||||
|
"menuSubtitleNA": "No menu available",
|
||||||
|
"menuSubtitle": "Click here to see the menu"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"planningScreen": {
|
"planningScreen": {
|
||||||
"wipTitle": "WORK IN PROGRESS",
|
"wipTitle": "WORK IN PROGRESS",
|
||||||
|
|
Loading…
Reference in a new issue