diff --git a/dataProxiwash.json b/dataProxiwash.json new file mode 100644 index 0000000..e874008 --- /dev/null +++ b/dataProxiwash.json @@ -0,0 +1,90 @@ +{ + "dryers": [ + { + "number": "1", + "state": "TERMINE", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "2", + "state": "DISPONIBLE", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "3", + "state": "FONCTIONNE", + "startTime": "10:16", + "endTime": "10:50", + "donePercent": "36.5" + } + ], + "washers": [ + { + "number": "4", + "state": "DISPONIBLE", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "5", + "state": "DISPONIBLE", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "6", + "state": "DISPONIBLE", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "7", + "state": "DISPONIBLE", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "8", + "state": "DISPONIBLE", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "9", + "state": "FONCTIONNE", + "startTime": "09:46", + "endTime": "10:31", + "donePercent": "93.9" + }, + { + "number": "10", + "state": "DISPONIBLE", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "11", + "state": "HS", + "startTime": "", + "endTime": "", + "donePercent": "" + }, + { + "number": "12", + "state": "DISPONIBLE", + "startTime": "", + "endTime": "", + "donePercent": "" + } + ] +} diff --git a/package.json b/package.json index f64c7bd..ec49a77 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "expo": "^33.0.0", "expo-font": "^5.0.1", "expo-localization": "^5.0.1", + "expo-permissions": "^5.0.1", "i18n-js": "^3.3.0", "i18next": "latest", "native-base": "latest", @@ -20,13 +21,13 @@ "react-i18next": "latest", "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz", "react-native-paper": "latest", + "react-native-platform-touchable": "latest", "react-native-settings-page": "latest", "react-native-status-bar-height": "latest", "react-native-web": "^0.11.4", "react-native-week-view": "latest", "react-navigation": "latest", - "react-navigation-material-bottom-tabs": "latest", - "react-native-platform-touchable": "latest" + "react-navigation-material-bottom-tabs": "latest" }, "devDependencies": { "babel-preset-expo": "^5.1.1", diff --git a/screens/HomeScreen.js b/screens/HomeScreen.js index 222c821..b320465 100644 --- a/screens/HomeScreen.js +++ b/screens/HomeScreen.js @@ -2,7 +2,7 @@ import React from 'react'; import {Container, Content, Text, Button, Icon} from 'native-base'; import CustomHeader from '../components/CustomHeader'; import i18n from "i18n-js"; - +import NotificationsManager from '../utils/NotificationsManager' import { Notifications } from 'expo'; @@ -13,7 +13,7 @@ export default class HomeScreen extends React.Component { - + : {stateStrings[MACHINE_STATES[item.state]]} + + } + + ); + } + render() { const nav = this.props.navigation; + const data = [ + { + title: i18n.t('proxiwashScreen.dryers'), + data: this.state.data.dryers === undefined ? [] : this.state.data.dryers, + extraData: this.state + }, + { + title: i18n.t('proxiwashScreen.washers'), + data: this.state.data.washers === undefined ? [] : this.state.data.washers, + extraData: this.state + }, + ]; + console.log(this.state.machinesWatched); return ( + item.number} + refreshControl={ + + } + renderSectionHeader={({section: {title}}) => ( +

{title}

+ )} + renderItem={({item, section}) => + this.renderItem(item, section, data) + } + />
); } } - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#fff', - alignItems: 'center', - justifyContent: 'center', - }, -}); diff --git a/translations/en.json b/translations/en.json index f56eb14..c422c51 100644 --- a/translations/en.json +++ b/translations/en.json @@ -28,5 +28,26 @@ "sortName": "Sort by name", "sortPrice": "Sort by price", "listUpdated": "Article list updated!" + }, + "proxiwashScreen": { + "dryer": "Dryer", + "dryers": "Dryers", + "washer": "Washer", + "washers": "Washers", + "min": "min", + "listUpdated": "Machines state updated", + "states": { + "finished": "FINISHED", + "ready": "READY", + "running": "RUNNING", + "broken": "BROKEN", + "error": "ERROR" + }, + "notifications": { + "machineFinishedTitle": "Laundry Ready", + "machineFinishedBody": "The machine n°{{number}} is finished and your laundry is ready to pickup", + "machineRunningTitle": "Laundry running: {{time}} minutes left", + "machineRunningBody": "The machine n°{{number}} is still running" + } } } diff --git a/translations/fr.json b/translations/fr.json index 22d2e87..6ca2ca8 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -28,5 +28,26 @@ "sortName": "Trier par nom", "sortPrice": "Trier par prix", "listUpdated": "Liste des articles mise à jour !" + }, + "proxiwashScreen": { + "dryer": "Sèche Linge", + "dryers": "Sèche Linges", + "washer": "Lave Linge", + "washers": "Lave Linges", + "min": "min", + "listUpdated": "Etat des machines mis à jour", + "states": { + "finished": "TERMINE", + "ready": "DISPONIBLE", + "running": "En COURS", + "broken": "HORS SERVICE", + "error": "ERREUR" + }, + "notifications": { + "machineFinishedTitle": "Linge prêt", + "machineFinishedBody": "La machine n°{{number}} est terminée et votre linge est prêt à être récupéré", + "machineRunningTitle": "Machine en cours: {{time}} minutes restantes", + "machineRunningBody": "La machine n°{{number}} n'est pas encore terminée" + } } } diff --git a/utils/NotificationsManager.js b/utils/NotificationsManager.js new file mode 100644 index 0000000..42d706c --- /dev/null +++ b/utils/NotificationsManager.js @@ -0,0 +1,40 @@ +import * as Permissions from 'expo-permissions'; +import { Notifications } from 'expo'; + +export default class NotificationsManager { + + static async askPermissions() { + const {status: existingStatus} = await Permissions.getAsync(Permissions.NOTIFICATIONS); + let finalStatus = existingStatus; + if (existingStatus !== 'granted') { + const {status} = await Permissions.askAsync(Permissions.NOTIFICATIONS); + finalStatus = status; + } + return finalStatus === 'granted'; + } + + static async sendNotificationImmediately (title, body) { + await NotificationsManager.askPermissions(); + return await Notifications.presentLocalNotificationAsync({ + title: title, + body: body, + }); + }; + + static async scheduleNotification(title, body, time) { + await NotificationsManager.askPermissions(); + return Notifications.scheduleLocalNotificationAsync( + { + title: title, + body: body, + }, + { + time: time, + }, + ); + }; + + static async cancelScheduledNoification(notifID) { + await Notifications.cancelScheduledNotificationAsync(notifID); + } +} diff --git a/utils/ThemeManager.js b/utils/ThemeManager.js index 07b5319..5046007 100644 --- a/utils/ThemeManager.js +++ b/utils/ThemeManager.js @@ -1,4 +1,3 @@ -import {DefaultTheme} from 'react-native-paper'; import {AsyncStorage} from 'react-native' import platform from '../native-base-theme/variables/platform'; import platformDark from '../native-base-theme/variables/platformDark';