diff --git a/components/FetchedDataSectionList.js b/components/FetchedDataSectionList.js index c8d4cdf..96fe20b 100644 --- a/components/FetchedDataSectionList.js +++ b/components/FetchedDataSectionList.js @@ -4,7 +4,7 @@ import * as React from 'react'; import WebDataManager from "../utils/WebDataManager"; import {Container, Content, Tab, TabHeading, Tabs, Text} from "native-base"; import CustomHeader from "./CustomHeader"; -import {RefreshControl, SectionList, View} from "react-native"; +import {RefreshControl, SectionList, View, TouchableHighlight} from "react-native"; import CustomMaterialIcon from "./CustomMaterialIcon"; type Props = { @@ -15,16 +15,16 @@ type State = { refreshing: boolean, firstLoading: boolean, fetchedData: Object, - machinesWatched: Array + machinesWatched: Array, }; export default class FetchedDataSectionList extends React.Component { webDataManager: WebDataManager; - constructor() { + constructor(fetchUrl: string) { super(); - this.webDataManager = new WebDataManager(this.getFetchUrl()); + this.webDataManager = new WebDataManager(fetchUrl); } state = { @@ -34,10 +34,6 @@ export default class FetchedDataSectionList extends React.Component this.setupNotifications(item.number, remainingTime) + }, + { + text: i18n.t("proxiwashScreen.modal.cancel") + } + ]; + message = i18n.t('proxiwashScreen.modal.running', + { + start: item.startTime, + end: item.endTime, + remaining: remainingTime + }); + } + Alert.alert( + title, + message, + buttons + ); + } + /** * Get list item to be rendered * @@ -219,6 +253,12 @@ export default class ProxiwashScreen extends FetchedDataSectionList { * @returns {React.Node} */ getRenderItem(item: Object, section: Object, data: Object) { + let isMachineRunning = MACHINE_STATES[item.state] === MACHINE_STATES.FONCTIONNE; + let machineName = (section.title === i18n.t('proxiwashScreen.dryers') ? i18n.t('proxiwashScreen.dryer') : i18n.t('proxiwashScreen.washer')) + ' n°' + item.number; + let remainingTime = 0; + if (isMachineRunning) + remainingTime = ProxiwashScreen.getRemainingTime(item.startTime, item.endTime, item.donePercent); + return ( - - this.showAlert(machineName, item, remainingTime)} + style={{ + height: 64, + position: 'absolute', + right: 0, + width: '100%' + }} + > + + + + - {section.title === i18n.t('proxiwashScreen.dryers') ? i18n.t('proxiwashScreen.dryer') : i18n.t('proxiwashScreen.washer')} n°{item.number} + {machineName + ' '} + {this.isMachineWatched(item.number) ? + : ''} - {item.startTime !== '' ? item.startTime + '/' + item.endTime : ''} + {isMachineRunning ? item.startTime + '/' + item.endTime : ''} - + @@ -260,33 +320,8 @@ export default class ProxiwashScreen extends FetchedDataSectionList { - - {/*{item.startTime !== '' ?*/} - {/* {*/} - {/* this.setupNotifications(item.number, ProxiwashScreen.getRemainingTime(item.startTime, item.endTime, item.donePercent))*/} - {/* }}*/} - {/* >*/} - {/* */} - {/* {ProxiwashScreen.getRemainingTime(item.startTime, item.endTime, item.donePercent) + ' ' + i18n.t('proxiwashScreen.min')}*/} - {/* */} - {/* */} - {/* */} - {/* : (*/} - {/* )*/} - {/*}*/} ); } - - // getRenderSectionHeader(title: String) { - // return

{title}

; - // } } diff --git a/translations/en.json b/translations/en.json index 674b6cd..cf9a5b7 100644 --- a/translations/en.json +++ b/translations/en.json @@ -61,6 +61,17 @@ "listUpdateFail": "Error while updating machines state", "error": "Could not update machines state. Pull down to retry.", "loading": "Loading...", + "modal": { + "enableNotifications": "Notify me", + "disableNotifications": "Stop notifications", + "ok": "OK", + "cancel": "Cancel", + "finished": "This machine is finished. If you started it, you can get back your laundry.", + "ready": "This machine is empty and ready to use. {Put price here}", + "running": "This machine has been started at %{start} and will end at %{end}.\nRemaining time: %{remaining} min", + "broken": "This machine is broken and cannot be used. Thank you for your comprehension.", + "error": "There has been an error and we are unable to get information from this machine. Sorry for the inconvenience." + }, "states": { "finished": "FINISHED", "ready": "READY", diff --git a/translations/fr.json b/translations/fr.json index 19ca704..7c10450 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -61,6 +61,17 @@ "listUpdateFail": "Erreur lors de la mise à jour del'état des machines", "error": "Impossible de mettre a jour l'état des machines. Tirez vers le bas pour reessayer.", "loading": "Chargement...", + "modal": { + "enableNotifications": "Me Notifier", + "disableNotifications": "Désactiver les notifications", + "ok": "OK", + "cancel": "Annuler", + "finished": "Cette machine est terminée. Si vous l'avez l'avez démarée, vous pouvez récupérer votre linge.", + "ready": "Cette machine est vide et prête à être utilisée. {Afficher prix ici}", + "running": "Cette machine a démarré à %{start} et terminera à %{end}.\nTemps restant : %{remaining} min", + "broken": "Cette machine est hors service. Merci pour votre compréhension.", + "error": "Il y a eu une erreur et il est impossible de récupérer les informations de cette machine. Veuillez nous excuser pour le gène occasionnée." + }, "states": { "finished": "TERMINE", "ready": "DISPONIBLE",