Browse Source

Improved proxiwash screen + show help banner on proxiwash and planex

keplyx 4 years ago
parent
commit
7f7ae68664

+ 40
- 18
components/ProxiwashListItem.js View File

@@ -1,5 +1,5 @@
1 1
 import * as React from 'react';
2
-import {Divider, List, Text, withTheme} from 'react-native-paper';
2
+import {Card, Avatar, List, Text, withTheme} from 'react-native-paper';
3 3
 import {View} from "react-native";
4 4
 import ProxiwashConstants from "../constants/ProxiwashConstants";
5 5
 
@@ -13,27 +13,48 @@ function ProxiwashListItem(props) {
13 13
     stateColors[ProxiwashConstants.machineStates.ERREUR] = colors.proxiwashErrorColor;
14 14
     const icon = (
15 15
         props.isWatched ?
16
-            <List.Icon icon={'bell-ring'} color={colors.primary}/> :
17
-            <List.Icon icon={props.isDryer ? 'tumble-dryer' : 'washing-machine'}/>
16
+            <Avatar.Icon
17
+                icon={'bell-ring'}
18
+                size={45}
19
+                color={colors.primary}
20
+                style={{backgroundColor: 'transparent'}}
21
+            /> :
22
+            <Avatar.Icon
23
+                icon={props.isDryer ? 'tumble-dryer' : 'washing-machine'}
24
+                color={colors.text}
25
+                size={40}
26
+                style={{backgroundColor: 'transparent'}}
27
+            />
18 28
     );
19 29
     return (
20
-        <View style={{
21
-            backgroundColor:
22
-                ProxiwashConstants.machineStates[props.state] === ProxiwashConstants.machineStates["EN COURS"] ?
23
-                    colors.proxiwashRunningBgColor :
24
-                    colors.background
25
-        }}>
26
-            <View style={{
30
+        <Card
31
+            style={{
32
+                margin: 5,
33
+            }}
34
+            onPress={props.onPress}
35
+        >
36
+            {ProxiwashConstants.machineStates[props.state] === ProxiwashConstants.machineStates["EN COURS"] ?
37
+                <Card style={{
38
+                    height: '100%',
39
+                    position: 'absolute',
40
+                    left: 0,
41
+                    width: '100%',
42
+                    backgroundColor: colors.proxiwashRunningBgColor,
43
+                    elevation: 0
44
+                }}/> : null
45
+            }
46
+
47
+            <Card style={{
27 48
                 height: '100%',
28 49
                 position: 'absolute',
29 50
                 left: 0,
30 51
                 width: props.progress,
31
-                backgroundColor: stateColors[ProxiwashConstants.machineStates[props.state]]
52
+                backgroundColor: stateColors[ProxiwashConstants.machineStates[props.state]],
53
+                elevation: 0
32 54
             }}/>
33
-            <List.Item
55
+            <Card.Title
34 56
                 title={props.title}
35
-                description={props.description}
36
-                onPress={props.onPress}
57
+                subtitle={props.description}
37 58
                 style={{
38 59
                     backgroundColor: 'transparent',
39 60
                     height: 64
@@ -52,14 +73,15 @@ function ProxiwashListItem(props) {
52 73
                             </Text>
53 74
                         </View>
54 75
 
55
-                        <List.Icon
56
-                            color={colors.text}
76
+                        <Avatar.Icon
57 77
                             icon={props.statusIcon}
78
+                            color={colors.text}
79
+                            size={30}
80
+                            style={{backgroundColor: 'transparent'}}
58 81
                         />
59 82
                     </View>)}
60 83
             />
61
-            <Divider/>
62
-        </View>
84
+        </Card>
63 85
     );
64 86
 }
65 87
 

+ 1
- 1
components/WebSectionList.js View File

@@ -187,7 +187,7 @@ export default class WebSectionList extends React.Component<Props, State> {
187 187
     render() {
188 188
         let dataset = this.props.createDataset(this.state.fetchedData);
189 189
         const isEmpty = dataset[0].data.length === 0;
190
-        const shouldRenderHeader = !isEmpty || (this.props.renderSectionHeader !== null);
190
+        const shouldRenderHeader = !isEmpty && (this.props.renderSectionHeader !== null);
191 191
         if (isEmpty)
192 192
             dataset = this.createEmptyDataset();
193 193
         return (

+ 58
- 14
screens/Proxiwash/ProxiwashScreen.js View File

@@ -2,13 +2,12 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {Alert, Platform, View} from 'react-native';
5
-import ThemeManager from '../../utils/ThemeManager';
6 5
 import i18n from "i18n-js";
7 6
 import WebSectionList from "../../components/WebSectionList";
8 7
 import NotificationsManager from "../../utils/NotificationsManager";
9 8
 import AsyncStorageManager from "../../utils/AsyncStorageManager";
10 9
 import * as Expo from "expo";
11
-import {Divider, IconButton, List, Text, Title} from 'react-native-paper';
10
+import {Card, Banner, Avatar} from 'react-native-paper';
12 11
 import HeaderButton from "../../components/HeaderButton";
13 12
 import ProxiwashListItem from "../../components/ProxiwashListItem";
14 13
 import ProxiwashConstants from "../../constants/ProxiwashConstants";
@@ -30,6 +29,7 @@ type State = {
30 29
     firstLoading: boolean,
31 30
     fetchedData: Object,
32 31
     machinesWatched: Array<string>,
32
+    bannerVisible: boolean,
33 33
 };
34 34
 
35 35
 
@@ -43,6 +43,7 @@ export default class ProxiwashScreen extends React.Component<Props, State> {
43 43
     getRenderItem: Function;
44 44
     getRenderSectionHeader: Function;
45 45
     createDataset: Function;
46
+    onHideBanner: Function;
46 47
 
47 48
     state = {
48 49
         refreshing: false,
@@ -50,6 +51,7 @@ export default class ProxiwashScreen extends React.Component<Props, State> {
50 51
         fetchedData: {},
51 52
         // machinesWatched: JSON.parse(dataString),
52 53
         machinesWatched: [],
54
+        bannerVisible: AsyncStorageManager.getInstance().preferences.proxiwashShowBanner.current === '1',
53 55
     };
54 56
 
55 57
     /**
@@ -80,6 +82,15 @@ export default class ProxiwashScreen extends React.Component<Props, State> {
80 82
         this.getRenderItem = this.getRenderItem.bind(this);
81 83
         this.getRenderSectionHeader = this.getRenderSectionHeader.bind(this);
82 84
         this.createDataset = this.createDataset.bind(this);
85
+        this.onHideBanner = this.onHideBanner.bind(this);
86
+    }
87
+
88
+    onHideBanner() {
89
+        this.setState({bannerVisible: false});
90
+        AsyncStorageManager.getInstance().savePref(
91
+            AsyncStorageManager.getInstance().preferences.proxiwashShowBanner.key,
92
+            '0'
93
+        );
83 94
     }
84 95
 
85 96
     /**
@@ -280,24 +291,57 @@ export default class ProxiwashScreen extends React.Component<Props, State> {
280 291
     render() {
281 292
         const nav = this.props.navigation;
282 293
         return (
283
-            <WebSectionList
284
-                createDataset={this.createDataset}
285
-                navigation={nav}
286
-                refreshTime={REFRESH_TIME}
287
-                fetchUrl={DATA_URL}
288
-                renderItem={this.getRenderItem}
289
-                renderSectionHeader={this.getRenderSectionHeader}/>
294
+            <View>
295
+                <Banner
296
+                    visible={this.state.bannerVisible}
297
+                    actions={[
298
+                        {
299
+                            label: 'OK',
300
+                            onPress: this.onHideBanner,
301
+                        },
302
+                    ]}
303
+                    icon={() => <Avatar.Icon
304
+                        icon={'information'}
305
+                        size={40}
306
+                        />}
307
+                >
308
+                    {i18n.t('proxiwashScreen.enableNotificationsTip')}
309
+                </Banner>
310
+                <WebSectionList
311
+                    createDataset={this.createDataset}
312
+                    navigation={nav}
313
+                    refreshTime={REFRESH_TIME}
314
+                    fetchUrl={DATA_URL}
315
+                    renderItem={this.getRenderItem}
316
+                    renderSectionHeader={this.getRenderSectionHeader}/>
317
+            </View>
318
+
290 319
         );
291 320
     }
292 321
 
293 322
     getRenderSectionHeader({section}: Object) {
294 323
         return (
295
-            <Title style={{
296
-                marginTop: 10,
297
-                textAlign: 'center'
324
+            <Card style={{
325
+                width: '80%',
326
+                marginLeft: 'auto',
327
+                marginRight: 'auto',
328
+                marginBottom: 10,
329
+                marginTop: 20,
298 330
             }}>
299
-                {section.title}
300
-            </Title>
331
+                <Card.Title
332
+                    title={section.title}
333
+                    // subtitle={''} // TODO display num available
334
+                    titleStyle={{
335
+                        textAlign: 'center'
336
+                    }}
337
+                    subtitleStyle={{
338
+                        textAlign: 'center'
339
+                    }}
340
+                    style={{
341
+                        paddingLeft: 0,
342
+                    }}
343
+                />
344
+            </Card>
301 345
         );
302 346
     }
303 347
 

+ 69
- 15
screens/Websites/PlanexScreen.js View File

@@ -3,11 +3,19 @@
3 3
 import * as React from 'react';
4 4
 import ThemeManager from "../../utils/ThemeManager";
5 5
 import WebViewScreen from "../../components/WebViewScreen";
6
+import {Avatar, Banner} from "react-native-paper";
7
+import i18n from "i18n-js";
8
+import {View} from "react-native";
9
+import AsyncStorageManager from "../../utils/AsyncStorageManager";
6 10
 
7 11
 type Props = {
8 12
     navigation: Object,
9 13
 }
10 14
 
15
+type State = {
16
+    bannerVisible: boolean,
17
+}
18
+
11 19
 
12 20
 const PLANEX_URL = 'http://planex.insa-toulouse.fr/';
13 21
 
@@ -75,9 +83,11 @@ const OBSERVE_MUTATIONS_INJECTED =
75 83
  * Class defining the app's planex screen.
76 84
  * This screen uses a webview to render the planex page
77 85
  */
78
-export default class PlanexScreen extends React.Component<Props> {
86
+export default class PlanexScreen extends React.Component<Props, State> {
79 87
 
80 88
     customInjectedJS: string;
89
+    onHideBanner: Function;
90
+    onGoToSettings: Function;
81 91
 
82 92
     constructor() {
83 93
         super();
@@ -93,26 +103,70 @@ export default class PlanexScreen extends React.Component<Props> {
93 103
         this.customInjectedJS +=
94 104
             'removeAlpha();' +
95 105
             '});true;'; // Prevent crash on ios
106
+        this.onHideBanner = this.onHideBanner.bind(this);
107
+        this.onGoToSettings = this.onGoToSettings.bind(this);
108
+    }
109
+
110
+    state = {
111
+        bannerVisible:
112
+            AsyncStorageManager.getInstance().preferences.planexShowBanner.current === '1' &&
113
+            AsyncStorageManager.getInstance().preferences.defaultStartScreen.current !== 'Planex',
114
+    };
96 115
 
116
+    onHideBanner() {
117
+        this.setState({bannerVisible: false});
118
+        AsyncStorageManager.getInstance().savePref(
119
+            AsyncStorageManager.getInstance().preferences.planexShowBanner.key,
120
+            '0'
121
+        );
122
+    }
123
+
124
+    onGoToSettings() {
125
+        this.onHideBanner();
126
+        this.props.navigation.navigate('SettingsScreen');
97 127
     }
98 128
 
99 129
     render() {
100 130
         const nav = this.props.navigation;
101 131
         return (
102
-            <WebViewScreen
103
-                navigation={nav}
104
-                data={[
105
-                    {
106
-                        url: PLANEX_URL,
107
-                        icon: '',
108
-                        name: '',
109
-                        customJS: this.customInjectedJS
110
-                    },
111
-                ]}
112
-                customInjectedJS={this.customInjectedJS}
113
-                headerTitle={'Planex'}
114
-                hasHeaderBackButton={false}
115
-                hasFooter={false}/>
132
+            <View style={{
133
+                height: '100%'
134
+            }}>
135
+                <Banner
136
+                    visible={this.state.bannerVisible}
137
+                    actions={[
138
+                        {
139
+                            label: i18n.t('planexScreen.enableStartOK'),
140
+                            onPress: this.onGoToSettings,
141
+                        },
142
+                        {
143
+                            label: i18n.t('planexScreen.enableStartCancel'),
144
+                            onPress: this.onHideBanner,
145
+                        },
146
+
147
+                    ]}
148
+                    icon={() => <Avatar.Icon
149
+                        icon={'information'}
150
+                        size={40}
151
+                    />}
152
+                >
153
+                    {i18n.t('planexScreen.enableStartScreen')}
154
+                </Banner>
155
+                <WebViewScreen
156
+                    navigation={nav}
157
+                    data={[
158
+                        {
159
+                            url: PLANEX_URL,
160
+                            icon: '',
161
+                            name: '',
162
+                            customJS: this.customInjectedJS
163
+                        },
164
+                    ]}
165
+                    customInjectedJS={this.customInjectedJS}
166
+                    headerTitle={'Planex'}
167
+                    hasHeaderBackButton={false}
168
+                    hasFooter={false}/>
169
+            </View>
116 170
         );
117 171
     }
118 172
 }

+ 4
- 2
translations/en.json View File

@@ -160,6 +160,7 @@
160 160
     "dryerTips": "The advised dryer length is 35 minutes for 14 kg of laundry. You can choose a shorter length if the dryer is not fully charged.",
161 161
     "procedure": "Procedure",
162 162
     "tips": "Tips",
163
+    "enableNotificationsTip": "Click on a running machine to enable notifications",
163 164
     "modal": {
164 165
       "enableNotifications": "Notify me",
165 166
       "disableNotifications": "Stop notifications",
@@ -188,8 +189,9 @@
188 189
     }
189 190
   },
190 191
   "planexScreen": {
191
-    "rotateToLandscape": "Turn your screen to see the whole week",
192
-    "rotateToPortrait": "Turn your screen to see only 2 days"
192
+    "enableStartScreen": "Come here often? Set it as default screen!",
193
+    "enableStartOK": "Yes please!",
194
+    "enableStartCancel": "Later"
193 195
   },
194 196
   "availableRoomScreen": {
195 197
     "normalRoom": "Work",

+ 4
- 3
translations/fr.json View File

@@ -160,7 +160,7 @@
160 160
     "dryerTips": "La durée conseillée est de 35 minutes pour 14kg de linge. Vous pouvez choisir une durée plus courte si le sèche-linge n'est pas chargé.",
161 161
     "procedure": "Procédure",
162 162
     "tips": "Conseils",
163
-
163
+    "enableNotificationsTip": "Cliquez sur une machine en cours pour activer les notifications",
164 164
     "modal": {
165 165
       "enableNotifications": "Me Notifier",
166 166
       "disableNotifications": "Désactiver les  notifications",
@@ -190,8 +190,9 @@
190 190
     }
191 191
   },
192 192
   "planexScreen": {
193
-    "rotateToLandscape": "Tournez votre téléphone pour voir la semaine entière",
194
-    "rotateToPortrait": "Tournez votre téléphone pour voir seulement 2 jours"
193
+    "enableStartScreen": "Vous venez souvent ici ? Démarrez l'appli sur cette page!",
194
+    "enableStartOK": "Oui svp!",
195
+    "enableStartCancel": "Plus tard"
195 196
   },
196 197
   "availableRoomScreen": {
197 198
     "normalRoom": "Travail",

+ 11
- 1
utils/AsyncStorageManager.js View File

@@ -63,7 +63,17 @@ export default class AsyncStorageManager {
63 63
             key: 'defaultStartScreen',
64 64
             default: 'Home',
65 65
             current: '',
66
-        }
66
+        },
67
+        proxiwashShowBanner: {
68
+            key: 'proxiwashShowBanner',
69
+            default: '1',
70
+            current: '',
71
+        },
72
+        planexShowBanner: {
73
+            key: 'planexShowBanner',
74
+            default: '1',
75
+            current: '',
76
+        },
67 77
     };
68 78
 
69 79
     /**

+ 10
- 10
utils/ThemeManager.js View File

@@ -35,12 +35,12 @@ export default class ThemeManager {
35 35
                 agendaDayTextColor: '#636363',
36 36
 
37 37
                 // PROXIWASH
38
-                proxiwashFinishedColor: "rgba(54,165,22,0.31)",
38
+                proxiwashFinishedColor: "#a5dc9d",
39 39
                 proxiwashReadyColor: "transparent",
40
-                proxiwashRunningColor: "rgba(94,104,241,0.3)",
41
-                proxiwashRunningBgColor: "rgba(99,109,255,0.14)",
42
-                proxiwashBrokenColor: "rgba(162,162,162,0.31)",
43
-                proxiwashErrorColor: "rgba(204,7,0,0.31)",
40
+                proxiwashRunningColor: "#a0ceff",
41
+                proxiwashRunningBgColor: "#c7e3ff",
42
+                proxiwashBrokenColor: "#8e8e8e",
43
+                proxiwashErrorColor: "rgba(204,7,0,0.31)#e35f57",
44 44
 
45 45
                 // Screens
46 46
                 planningColor: '#d9b10a',
@@ -72,12 +72,12 @@ export default class ThemeManager {
72 72
                 agendaDayTextColor: '#6d6d6d',
73 73
 
74 74
                 // PROXIWASH
75
-                proxiwashFinishedColor: "rgba(17,149,32,0.53)",
75
+                proxiwashFinishedColor: "#31682c",
76 76
                 proxiwashReadyColor: "transparent",
77
-                proxiwashRunningColor: "rgba(29,59,175,0.65)",
78
-                proxiwashRunningBgColor: "rgba(99,109,255,0.14)",
79
-                proxiwashBrokenColor: "#000000",
80
-                proxiwashErrorColor: "rgba(213,8,0,0.57)",
77
+                proxiwashRunningColor: "#213c79",
78
+                proxiwashRunningBgColor: "#1a2033",
79
+                proxiwashBrokenColor: "#656565",
80
+                proxiwashErrorColor: "#7e2e2f",
81 81
 
82 82
                 // Screens
83 83
                 planningColor: '#d99e09',

Loading…
Cancel
Save