Browse Source

Improved dashboard display

keplyx 4 years ago
parent
commit
158973c74d

+ 8
- 1
native-base-theme/variables/platform.js View File

243
 
243
 
244
     // Text
244
     // Text
245
     textColor: "#000",
245
     textColor: "#000",
246
-    textDisabledColor: "#d9e1e8",
246
+    textDisabledColor: "#c1c1c1",
247
     inverseTextColor: "#fff",
247
     inverseTextColor: "#fff",
248
     noteFontSize: 14,
248
     noteFontSize: 14,
249
     get defaultTextColor() {
249
     get defaultTextColor() {
273
     proxiwashBrokenColor: "rgba(162,162,162,0.31)",
273
     proxiwashBrokenColor: "rgba(162,162,162,0.31)",
274
     proxiwashErrorColor: "rgba(204,7,0,0.31)",
274
     proxiwashErrorColor: "rgba(204,7,0,0.31)",
275
 
275
 
276
+    // Screens
277
+    planningColor: '#d9b10a',
278
+    proximoColor: '#ec5904',
279
+    proxiwashColor: '#1fa5ee',
280
+    menuColor: '#e91314',
281
+
282
+
276
     // Other
283
     // Other
277
     borderRadiusBase: platform === "ios" ? 5 : 2,
284
     borderRadiusBase: platform === "ios" ? 5 : 2,
278
     borderWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),
285
     borderWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),

+ 6
- 1
native-base-theme/variables/platformDark.js View File

244
 
244
 
245
     // Text
245
     // Text
246
     textColor: "#ebebeb",
246
     textColor: "#ebebeb",
247
-    textDisabledColor: "#3b3f42",
247
+    textDisabledColor: "#5b5b5b",
248
     inverseTextColor: "#000",
248
     inverseTextColor: "#000",
249
     noteFontSize: 14,
249
     noteFontSize: 14,
250
     get defaultTextColor() {
250
     get defaultTextColor() {
274
     proxiwashBrokenColor: "#000000",
274
     proxiwashBrokenColor: "#000000",
275
     proxiwashErrorColor: "rgba(213,8,0,0.57)",
275
     proxiwashErrorColor: "rgba(213,8,0,0.57)",
276
 
276
 
277
+    // Screens
278
+    planningColor: '#d99e09',
279
+    proximoColor: '#ec5904',
280
+    proxiwashColor: '#1fa5ee',
281
+    menuColor: '#b81213',
277
 
282
 
278
     // Other
283
     // Other
279
     borderRadiusBase: platform === "ios" ? 5 : 2,
284
     borderRadiusBase: platform === "ios" ? 5 : 2,

+ 97
- 21
screens/HomeScreen.js View File

65
                 id: SECTIONS_ID[0]
65
                 id: SECTIONS_ID[0]
66
             },
66
             },
67
             {
67
             {
68
-                title: 'News Feed',
68
+                title: i18n.t('homeScreen.newsFeed'),
69
                 data: newsData,
69
                 data: newsData,
70
                 extraData: super.state,
70
                 extraData: super.state,
71
                 keyExtractor: this.getKeyExtractor,
71
                 keyExtractor: this.getKeyExtractor,
120
     getDashboardItemData(item: Object) {
120
     getDashboardItemData(item: Object) {
121
         let icon = '';
121
         let icon = '';
122
         let title = '';
122
         let title = '';
123
-        let subtitle = '';
123
+        let subtitle;
124
         let clickAction;
124
         let clickAction;
125
+        let isAvailable = false;
126
+        let color = ThemeManager.getCurrentThemeVariables().disabledTextColor;
125
         switch (item['id']) {
127
         switch (item['id']) {
126
             case 'today_events':
128
             case 'today_events':
127
                 icon = 'calendar-range';
129
                 icon = 'calendar-range';
128
-                title = 'Today\s events';
129
-                if (item['data'].length === 0)
130
-                    subtitle = 'Pas d\'event ajd';
131
-                else
132
-                    subtitle = item['data'].length + ' events ajd';
130
+                color = ThemeManager.getCurrentThemeVariables().planningColor;
131
+                title = i18n.t('homeScreen.dashboard.todayEventsTitle');
132
+                isAvailable = item['data'].length > 0;
133
+                if (isAvailable) {
134
+                    subtitle =
135
+                        <Text>
136
+                            <Text style={{fontWeight: "bold"}}>{item['data'].length}</Text>
137
+                            <Text>{i18n.t('homeScreen.dashboard.todayEventsSubtitle')}</Text>
138
+                        </Text>;
139
+                } else
140
+                    subtitle = i18n.t('homeScreen.dashboard.todayEventsSubtitleNA');
133
                 clickAction = () => this.props.navigation.navigate('Planning');
141
                 clickAction = () => this.props.navigation.navigate('Planning');
134
                 break;
142
                 break;
135
             case 'proximo_articles':
143
             case 'proximo_articles':
136
                 icon = 'shopping';
144
                 icon = 'shopping';
137
-                title = 'Proximo';
138
-                subtitle = item['data'] + ' articles disponibles';
145
+                color = ThemeManager.getCurrentThemeVariables().proximoColor;
146
+                title = i18n.t('homeScreen.dashboard.proximoTitle');
147
+                isAvailable = parseInt(item['data']) > 0;
148
+                if (isAvailable) {
149
+                    subtitle =
150
+                        <Text>
151
+                            <Text style={{fontWeight: "bold"}}>{item['data']}</Text>
152
+                            <Text>{i18n.t('homeScreen.dashboard.proximoSubtitle')}</Text>
153
+                        </Text>;
154
+                } else
155
+                    subtitle = i18n.t('homeScreen.dashboard.proximoSubtitleNA');
139
                 clickAction = () => this.props.navigation.navigate('Proximo');
156
                 clickAction = () => this.props.navigation.navigate('Proximo');
140
                 break;
157
                 break;
141
             case 'available_machines':
158
             case 'available_machines':
142
                 icon = 'washing-machine';
159
                 icon = 'washing-machine';
143
-                title = 'Machines disponibles';
144
-                subtitle = item['data']['dryers'] + ' dryers and ' + item['data']['washers'] + ' washers.';
160
+                color = ThemeManager.getCurrentThemeVariables().proxiwashColor;
161
+                title = i18n.t('homeScreen.dashboard.proxiwashTitle');
162
+                isAvailable = parseInt(item['data']['dryers']) > 0 || parseInt(item['data']['washers']) > 0;
163
+                if (isAvailable) {
164
+                    subtitle =
165
+                        <Text>
166
+                            <Text style={{
167
+                                fontWeight: parseInt(item['data']['dryers']) > 0 ?
168
+                                    'bold' :
169
+                                    'normal',
170
+                                color: parseInt(item['data']['dryers']) > 0 ?
171
+                                    ThemeManager.getCurrentThemeVariables().textColor :
172
+                                    ThemeManager.getCurrentThemeVariables().listNoteColor
173
+                            }}>
174
+                                {item['data']['dryers']}
175
+                            </Text>
176
+                            <Text>{i18n.t('homeScreen.dashboard.proxiwashSubtitle1')}</Text>
177
+                            <Text style={{
178
+                                fontWeight: parseInt(item['data']['washers']) > 0 ?
179
+                                    'bold' :
180
+                                    'normal',
181
+                                color: parseInt(item['data']['washers']) > 0 ?
182
+                                    ThemeManager.getCurrentThemeVariables().textColor :
183
+                                    ThemeManager.getCurrentThemeVariables().listNoteColor
184
+                            }}>
185
+                                {item['data']['washers']}
186
+                            </Text>
187
+                            <Text>{i18n.t('homeScreen.dashboard.proxiwashSubtitle2')}</Text>
188
+                        </Text>;
189
+                } else
190
+                    subtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA');
145
                 clickAction = () => this.props.navigation.navigate('Proxiwash');
191
                 clickAction = () => this.props.navigation.navigate('Proxiwash');
146
                 break;
192
                 break;
147
             case 'today_menu':
193
             case 'today_menu':
148
                 icon = 'silverware-fork-knife';
194
                 icon = 'silverware-fork-knife';
149
-                title = 'Menu du jour';
150
-                if (item['data'].length === 0)
151
-                    subtitle = 'non disponible';
152
-                else
153
-                    subtitle = 'Click here to show the menu';
195
+                color = ThemeManager.getCurrentThemeVariables().menuColor;
196
+                title = i18n.t('homeScreen.dashboard.menuTitle');
197
+                isAvailable = item['data'].length > 0;
198
+                if (isAvailable) {
199
+                    subtitle = i18n.t('homeScreen.dashboard.menuSubtitle');
200
+                } else
201
+                    subtitle = i18n.t('homeScreen.dashboard.menuSubtitleNA');
154
                 clickAction = () => this.props.navigation.navigate('SelfMenuScreen');
202
                 clickAction = () => this.props.navigation.navigate('SelfMenuScreen');
155
                 break;
203
                 break;
156
         }
204
         }
157
         return {
205
         return {
158
             icon: icon,
206
             icon: icon,
207
+            color: color,
159
             title: title,
208
             title: title,
160
             subtitle: subtitle,
209
             subtitle: subtitle,
161
-            clickAction: clickAction
210
+            clickAction: clickAction,
211
+            isAvailable: isAvailable
162
         }
212
         }
163
     }
213
     }
164
 
214
 
170
                 <Card style={{
220
                 <Card style={{
171
                     flex: 0,
221
                     flex: 0,
172
                     marginLeft: 10,
222
                     marginLeft: 10,
173
-                    marginRight: 10
223
+                    marginRight: 10,
224
+                    borderRadius: 50,
225
+                    backgroundColor: ThemeManager.getCurrentThemeVariables().cardDefaultBg
174
                 }}>
226
                 }}>
175
                     <PlatformTouchable
227
                     <PlatformTouchable
176
                         onPress={itemData['clickAction']}
228
                         onPress={itemData['clickAction']}
229
+                        style={{
230
+                            zIndex: 100,
231
+                            borderRadius: 50
232
+                        }}
177
                     >
233
                     >
178
-                        <CardItem>
234
+                        <CardItem style={{
235
+                            borderRadius: 50,
236
+                            backgroundColor: 'transparent'
237
+                        }}>
179
                             <Left>
238
                             <Left>
180
                                 <CustomMaterialIcon
239
                                 <CustomMaterialIcon
181
                                     icon={itemData['icon']}
240
                                     icon={itemData['icon']}
241
+                                    color={
242
+                                        itemData['isAvailable'] ?
243
+                                            itemData['color'] :
244
+                                            ThemeManager.getCurrentThemeVariables().textDisabledColor
245
+                                    }
182
                                     fontSize={40}
246
                                     fontSize={40}
183
                                     width={40}/>
247
                                     width={40}/>
184
                                 <Body>
248
                                 <Body>
185
-                                    <H3>{itemData['title']}</H3>
186
-                                    <Text>{itemData['subtitle']}</Text>
249
+                                    <H3 style={{
250
+                                        color: itemData['isAvailable'] ?
251
+                                            ThemeManager.getCurrentThemeVariables().textColor :
252
+                                            ThemeManager.getCurrentThemeVariables().listNoteColor
253
+                                    }}>
254
+                                        {itemData['title']}
255
+                                    </H3>
256
+                                    <Text style={{
257
+                                        color: itemData['isAvailable'] ?
258
+                                            ThemeManager.getCurrentThemeVariables().listNoteColor :
259
+                                            ThemeManager.getCurrentThemeVariables().textDisabledColor
260
+                                    }}>
261
+                                        {itemData['subtitle']}
262
+                                    </Text>
187
                                 </Body>
263
                                 </Body>
188
                             </Left>
264
                             </Left>
189
                         </CardItem>
265
                         </CardItem>

+ 1
- 1
screens/Proximo/ProximoMainScreen.js View File

31
     }
31
     }
32
 
32
 
33
     getKeyExtractor(item: Object) {
33
     getKeyExtractor(item: Object) {
34
-        return item !== undefined ? item.type : undefined;
34
+        return item !== undefined ? item.type['id'] : undefined;
35
     }
35
     }
36
 
36
 
37
     createDataset(fetchedData: Object) {
37
     createDataset(fetchedData: Object) {

+ 6
- 2
screens/SelfMenuScreen.js View File

53
     }
53
     }
54
 
54
 
55
     getKeyExtractor(item: Object) {
55
     getKeyExtractor(item: Object) {
56
-        return item !== undefined ? item.name : undefined;
56
+        return item !== undefined ? item['date'] + '_' + item['name'] : undefined;
57
     }
57
     }
58
 
58
 
59
     hasBackButton() {
59
     hasBackButton() {
79
         }
79
         }
80
         // fetched data is an array here
80
         // fetched data is an array here
81
         for (let i = 0; i < fetchedData.length; i++) {
81
         for (let i = 0; i < fetchedData.length; i++) {
82
+            // Add the date to the item to allow creation of unique list id
83
+            for (let item of fetchedData[i].meal[0].foodcategory) {
84
+                item['date'] = fetchedData[i]['date'];
85
+            }
82
             result.push(
86
             result.push(
83
                 {
87
                 {
84
                     title: this.getFormattedDate(fetchedData[i].date),
88
                     title: this.getFormattedDate(fetchedData[i].date),
85
                     data: fetchedData[i].meal[0].foodcategory,
89
                     data: fetchedData[i].meal[0].foodcategory,
86
                     extraData: super.state,
90
                     extraData: super.state,
87
-                    keyExtractor: this.getKeyExtractor
91
+                    keyExtractor: this.getKeyExtractor,
88
                 }
92
                 }
89
             );
93
             );
90
         }
94
         }

+ 17
- 1
translations/en.json View File

69
   },
69
   },
70
   "homeScreen": {
70
   "homeScreen": {
71
     "listUpdated": "List updated!",
71
     "listUpdated": "List updated!",
72
-    "listUpdateFail": "Error while updating list"
72
+    "listUpdateFail": "Error while updating list",
73
+    "newsFeed": "Campus News",
74
+    "dashboard": {
75
+      "todayEventsTitle": "Today's events",
76
+      "todayEventsSubtitleNA": "No events today",
77
+      "todayEventsSubtitle": " events today",
78
+      "proximoTitle": "Proximo",
79
+      "proximoSubtitleNA": "No articles available",
80
+      "proximoSubtitle": " articles available",
81
+      "proxiwashTitle": "Available machines",
82
+      "proxiwashSubtitleNA": "No machines available",
83
+      "proxiwashSubtitle1": " dryers and ",
84
+      "proxiwashSubtitle2": " washers",
85
+      "menuTitle": "Today's menu",
86
+      "menuSubtitleNA": "No menu available",
87
+      "menuSubtitle": "Click here to see the menu"
88
+    }
73
   },
89
   },
74
   "planningScreen": {
90
   "planningScreen": {
75
     "wipTitle": "WORK IN PROGRESS",
91
     "wipTitle": "WORK IN PROGRESS",

Loading…
Cancel
Save