From 1aa4a59fa06c834247f0a13d00264a19b5db10f8 Mon Sep 17 00:00:00 2001 From: keplyx Date: Thu, 8 Aug 2019 18:05:18 +0200 Subject: [PATCH] Added proxiwash info screen + fixed crash when machine running --- components/FetchedDataSectionList.js | 6 +- native-base-theme/variables/platformDark.js | 2 +- navigation/AppNavigator.js | 2 + screens/ProxiwashAboutScreen.js | 132 ++++++++++++++++++++ screens/ProxiwashScreen.js | 36 ++++-- 5 files changed, 164 insertions(+), 14 deletions(-) create mode 100644 screens/ProxiwashAboutScreen.js diff --git a/components/FetchedDataSectionList.js b/components/FetchedDataSectionList.js index 14c9f7c..167870c 100644 --- a/components/FetchedDataSectionList.js +++ b/components/FetchedDataSectionList.js @@ -235,6 +235,10 @@ export default class FetchedDataSectionList extends React.Component + } + /** * Get the section list render using the generated dataset * @@ -312,7 +316,7 @@ export default class FetchedDataSectionList extends React.Component + {this.hasTabs() ? {this.getTabbedView(dataset)} diff --git a/native-base-theme/variables/platformDark.js b/native-base-theme/variables/platformDark.js index ef6c7b3..26c47f6 100644 --- a/native-base-theme/variables/platformDark.js +++ b/native-base-theme/variables/platformDark.js @@ -88,7 +88,7 @@ export default { }, // Card - cardDefaultBg: "#363636", + cardDefaultBg: "#2A2A2A", cardBorderColor: "#1a1a1a", cardBorderRadius: 2, cardItemPadding: platform === "ios" ? 10 : 12, diff --git a/navigation/AppNavigator.js b/navigation/AppNavigator.js index 9c04aea..453021a 100644 --- a/navigation/AppNavigator.js +++ b/navigation/AppNavigator.js @@ -6,6 +6,7 @@ import SettingsScreen from '../screens/SettingsScreen'; import AboutScreen from '../screens/About/AboutScreen'; import ProximoListScreen from '../screens/Proximo/ProximoListScreen'; import AboutDependenciesScreen from '../screens/About/AboutDependenciesScreen'; +import ProxiwashAboutScreen from '../screens/ProxiwashAboutScreen'; import SelfMenuScreen from '../screens/SelfMenuScreen'; import {fromRight} from "react-navigation-transitions"; @@ -21,6 +22,7 @@ export default createAppContainer( AboutScreen: {screen: AboutScreen}, AboutDependenciesScreen: {screen: AboutDependenciesScreen}, SelfMenuScreen: {screen: SelfMenuScreen}, + ProxiwashAboutScreen: {screen: ProxiwashAboutScreen}, }, { initialRouteName: "Main", diff --git a/screens/ProxiwashAboutScreen.js b/screens/ProxiwashAboutScreen.js new file mode 100644 index 0000000..efb36c5 --- /dev/null +++ b/screens/ProxiwashAboutScreen.js @@ -0,0 +1,132 @@ +// @flow + +import * as React from 'react'; +import {Image, Linking, View} from 'react-native'; +import {Body, Card, CardItem, Container, Content, H1, Left, Tab, TabHeading, Tabs, Text} from 'native-base'; +import CustomHeader from "../components/CustomHeader"; +import i18n from "i18n-js"; +import CustomMaterialIcon from "../components/CustomMaterialIcon"; +import ThemeManager from "../utils/ThemeManager"; + +type Props = { + navigation: Object, +}; + +/** + * Opens a link in the device's browser + * @param link The link to open + */ +function openWebLink(link) { + Linking.openURL(link).catch((err) => console.error('Error opening link', err)); +} + +/** + * Class defining an about screen. This screen shows the user information about the app and it's author. + */ +export default class ProxiwashAboutScreen extends React.Component { + + render() { + const nav = this.props.navigation; + return ( + + + + + + Information + + } + key={1} + style={{backgroundColor: ThemeManager.getCurrentThemeVariables().containerBgColor}}> + + + + + Ta laverie directement sur le campus, au pied du R3. + + + + +

Seche linge

+ +
+
+ + Coucou + +
+ + + + +

Machine a laver

+ +
+
+ + Coucou + +
+
+
+ + + Payment + + } + key={2} + style={{backgroundColor: ThemeManager.getCurrentThemeVariables().containerBgColor}}> + + + + + +

Tarifs

+ +
+
+ + Coucou + +
+ + + + +

Moyens de Paiement

+ +
+
+ + Coucou + +
+
+
+
+
+ ); + } +} diff --git a/screens/ProxiwashScreen.js b/screens/ProxiwashScreen.js index 6018bcb..fc14905 100644 --- a/screens/ProxiwashScreen.js +++ b/screens/ProxiwashScreen.js @@ -11,17 +11,18 @@ import NotificationsManager from "../utils/NotificationsManager"; import PlatformTouchable from "react-native-platform-touchable"; import AsyncStorageManager from "../utils/AsyncStorageManager"; import * as Expo from "expo"; +import Touchable from "react-native-platform-touchable"; const DATA_URL = "https://srv-falcon.etud.insa-toulouse.fr/~vergnet/appli-amicale/washinsa/washinsa.json"; let reminderNotifTime = 5; const MACHINE_STATES = { - TERMINE: "0", - DISPONIBLE: "1", - FONCTIONNE: "2", - HS: "3", - ERREUR: "4" + "TERMINE": "0", + "DISPONIBLE": "1", + "EN COURS": "2", + "HS": "3", + "ERREUR": "4" }; let stateStrings = {}; @@ -46,25 +47,25 @@ export default class ProxiwashScreen extends FetchedDataSectionList { let colors = ThemeManager.getCurrentThemeVariables(); stateColors[MACHINE_STATES.TERMINE] = colors.proxiwashFinishedColor; stateColors[MACHINE_STATES.DISPONIBLE] = colors.proxiwashReadyColor; - stateColors[MACHINE_STATES.FONCTIONNE] = colors.proxiwashRunningColor; + stateColors[MACHINE_STATES["EN COURS"]] = colors.proxiwashRunningColor; stateColors[MACHINE_STATES.HS] = colors.proxiwashBrokenColor; stateColors[MACHINE_STATES.ERREUR] = colors.proxiwashErrorColor; stateStrings[MACHINE_STATES.TERMINE] = i18n.t('proxiwashScreen.states.finished'); stateStrings[MACHINE_STATES.DISPONIBLE] = i18n.t('proxiwashScreen.states.ready'); - stateStrings[MACHINE_STATES.FONCTIONNE] = i18n.t('proxiwashScreen.states.running'); + stateStrings[MACHINE_STATES["EN COURS"]] = i18n.t('proxiwashScreen.states.running'); stateStrings[MACHINE_STATES.HS] = i18n.t('proxiwashScreen.states.broken'); stateStrings[MACHINE_STATES.ERREUR] = i18n.t('proxiwashScreen.states.error'); modalStateStrings[MACHINE_STATES.TERMINE] = i18n.t('proxiwashScreen.modal.finished'); modalStateStrings[MACHINE_STATES.DISPONIBLE] = i18n.t('proxiwashScreen.modal.ready'); - modalStateStrings[MACHINE_STATES.FONCTIONNE] = i18n.t('proxiwashScreen.modal.running'); + modalStateStrings[MACHINE_STATES["EN COURS"]] = i18n.t('proxiwashScreen.modal.running'); modalStateStrings[MACHINE_STATES.HS] = i18n.t('proxiwashScreen.modal.broken'); modalStateStrings[MACHINE_STATES.ERREUR] = i18n.t('proxiwashScreen.modal.error'); stateIcons[MACHINE_STATES.TERMINE] = 'check-circle'; stateIcons[MACHINE_STATES.DISPONIBLE] = 'radiobox-blank'; - stateIcons[MACHINE_STATES.FONCTIONNE] = 'progress-check'; + stateIcons[MACHINE_STATES["EN COURS"]] = 'progress-check'; stateIcons[MACHINE_STATES.HS] = 'alert-octagram-outline'; stateIcons[MACHINE_STATES.ERREUR] = 'alert'; @@ -299,7 +300,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList { showAlert(title: string, item: Object, remainingTime: number) { let buttons = [{text: i18n.t("proxiwashScreen.modal.ok")}]; let message = modalStateStrings[MACHINE_STATES[item.state]]; - if (MACHINE_STATES[item.state] === MACHINE_STATES.FONCTIONNE) { + if (MACHINE_STATES[item.state] === MACHINE_STATES["EN COURS"]) { buttons = [ { text: this.isMachineWatched(item.number) ? @@ -325,6 +326,18 @@ export default class ProxiwashScreen extends FetchedDataSectionList { ); } + getRightButton(): * { + return ( + this.props.navigation.navigate('ProxiwashAboutScreen')}> + + + ); + } + /** * Get list item to be rendered * @@ -334,12 +347,11 @@ 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 isMachineRunning = MACHINE_STATES[item.state] === MACHINE_STATES["EN COURS"]; 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 (