Improved roxiwash section headers

This commit is contained in:
keplyx 2020-03-08 00:20:26 +01:00
parent 7f7ae68664
commit 198fca639e
3 changed files with 23 additions and 3 deletions

View file

@ -27,7 +27,6 @@ type Props = {
type State = { type State = {
refreshing: boolean, refreshing: boolean,
firstLoading: boolean, firstLoading: boolean,
fetchedData: Object,
machinesWatched: Array<string>, machinesWatched: Array<string>,
bannerVisible: boolean, bannerVisible: boolean,
}; };
@ -45,6 +44,8 @@ export default class ProxiwashScreen extends React.Component<Props, State> {
createDataset: Function; createDataset: Function;
onHideBanner: Function; onHideBanner: Function;
fetchedData: Object;
state = { state = {
refreshing: false, refreshing: false,
firstLoading: true, firstLoading: true,
@ -218,6 +219,7 @@ export default class ProxiwashScreen extends React.Component<Props, State> {
} }
createDataset(fetchedData: Object) { createDataset(fetchedData: Object) {
this.fetchedData = fetchedData;
return [ return [
{ {
title: i18n.t('proxiwashScreen.dryers'), title: i18n.t('proxiwashScreen.dryers'),
@ -319,18 +321,34 @@ export default class ProxiwashScreen extends React.Component<Props, State> {
); );
} }
getMachineAvailableNumber(isDryer: boolean) {
let data;
if (isDryer)
data = this.fetchedData.dryers;
else
data = this.fetchedData.washers;
let count = 0;
for (let i = 0; i < data.length; i++) {
if (ProxiwashConstants.machineStates[data[i].state] === ProxiwashConstants.machineStates["DISPONIBLE"])
count += 1;
}
return count;
}
getRenderSectionHeader({section}: Object) { getRenderSectionHeader({section}: Object) {
const subtitle = this.getMachineAvailableNumber(section.title === i18n.t('proxiwashScreen.dryers')) + ' ' + i18n.t('proxiwashScreen.numAvailable');
return ( return (
<Card style={{ <Card style={{
width: '80%', width: '60%',
marginLeft: 'auto', marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',
marginBottom: 10, marginBottom: 10,
marginTop: 20, marginTop: 20,
elevation: 4,
}}> }}>
<Card.Title <Card.Title
title={section.title} title={section.title}
// subtitle={''} // TODO display num available subtitle={subtitle}
titleStyle={{ titleStyle={{
textAlign: 'center' textAlign: 'center'
}} }}

View file

@ -161,6 +161,7 @@
"procedure": "Procedure", "procedure": "Procedure",
"tips": "Tips", "tips": "Tips",
"enableNotificationsTip": "Click on a running machine to enable notifications", "enableNotificationsTip": "Click on a running machine to enable notifications",
"numAvailable": "available",
"modal": { "modal": {
"enableNotifications": "Notify me", "enableNotifications": "Notify me",
"disableNotifications": "Stop notifications", "disableNotifications": "Stop notifications",

View file

@ -161,6 +161,7 @@
"procedure": "Procédure", "procedure": "Procédure",
"tips": "Conseils", "tips": "Conseils",
"enableNotificationsTip": "Cliquez sur une machine en cours pour activer les notifications", "enableNotificationsTip": "Cliquez sur une machine en cours pour activer les notifications",
"numAvailable": "disponibles",
"modal": { "modal": {
"enableNotifications": "Me Notifier", "enableNotifications": "Me Notifier",
"disableNotifications": "Désactiver les notifications", "disableNotifications": "Désactiver les notifications",