Browse Source

Improved dashboard display

keplyx 2 years ago
parent
commit
158973c74d

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

@@ -243,7 +243,7 @@ export default {
243 243
 
244 244
     // Text
245 245
     textColor: "#000",
246
-    textDisabledColor: "#d9e1e8",
246
+    textDisabledColor: "#c1c1c1",
247 247
     inverseTextColor: "#fff",
248 248
     noteFontSize: 14,
249 249
     get defaultTextColor() {
@@ -273,6 +273,13 @@ export default {
273 273
     proxiwashBrokenColor: "rgba(162,162,162,0.31)",
274 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 283
     // Other
277 284
     borderRadiusBase: platform === "ios" ? 5 : 2,
278 285
     borderWidth: 1 / PixelRatio.getPixelSizeForLayoutSize(1),

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

@@ -244,7 +244,7 @@ export default {
244 244
 
245 245
     // Text
246 246
     textColor: "#ebebeb",
247
-    textDisabledColor: "#3b3f42",
247
+    textDisabledColor: "#5b5b5b",
248 248
     inverseTextColor: "#000",
249 249
     noteFontSize: 14,
250 250
     get defaultTextColor() {
@@ -274,6 +274,11 @@ export default {
274 274
     proxiwashBrokenColor: "#000000",
275 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 283
     // Other
279 284
     borderRadiusBase: platform === "ios" ? 5 : 2,

+ 97
- 21
screens/HomeScreen.js View File

@@ -65,7 +65,7 @@ export default class HomeScreen extends FetchedDataSectionList {
65 65
                 id: SECTIONS_ID[0]
66 66
             },
67 67
             {
68
-                title: 'News Feed',
68
+                title: i18n.t('homeScreen.newsFeed'),
69 69
                 data: newsData,
70 70
                 extraData: super.state,
71 71
                 keyExtractor: this.getKeyExtractor,
@@ -120,45 +120,95 @@ export default class HomeScreen extends FetchedDataSectionList {
120 120
     getDashboardItemData(item: Object) {
121 121
         let icon = '';
122 122
         let title = '';
123
-        let subtitle = '';
123
+        let subtitle;
124 124
         let clickAction;
125
+        let isAvailable = false;
126
+        let color = ThemeManager.getCurrentThemeVariables().disabledTextColor;
125 127
         switch (item['id']) {
126 128
             case 'today_events':
127 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 141
                 clickAction = () => this.props.navigation.navigate('Planning');
134 142
                 break;
135 143
             case 'proximo_articles':
136 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 156
                 clickAction = () => this.props.navigation.navigate('Proximo');
140 157
                 break;
141 158
             case 'available_machines':
142 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 191
                 clickAction = () => this.props.navigation.navigate('Proxiwash');
146 192
                 break;
147 193
             case 'today_menu':
148 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 202
                 clickAction = () => this.props.navigation.navigate('SelfMenuScreen');
155 203
                 break;
156 204
         }
157 205
         return {
158 206
             icon: icon,
207
+            color: color,
159 208
             title: title,
160 209
             subtitle: subtitle,
161
-            clickAction: clickAction
210
+            clickAction: clickAction,
211
+            isAvailable: isAvailable
162 212
         }
163 213
     }
164 214
 
@@ -170,20 +220,46 @@ export default class HomeScreen extends FetchedDataSectionList {
170 220
                 <Card style={{
171 221
                     flex: 0,
172 222
                     marginLeft: 10,
173
-                    marginRight: 10
223
+                    marginRight: 10,
224
+                    borderRadius: 50,
225
+                    backgroundColor: ThemeManager.getCurrentThemeVariables().cardDefaultBg
174 226
                 }}>
175 227
                     <PlatformTouchable
176 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 238
                             <Left>
180 239
                                 <CustomMaterialIcon
181 240
                                     icon={itemData['icon']}
241
+                                    color={
242
+                                        itemData['isAvailable'] ?
243
+                                            itemData['color'] :
244
+                                            ThemeManager.getCurrentThemeVariables().textDisabledColor
245
+                                    }
182 246
                                     fontSize={40}
183 247
                                     width={40}/>
184 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 263
                                 </Body>
188 264
                             </Left>
189 265
                         </CardItem>

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

@@ -31,7 +31,7 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
31 31
     }
32 32
 
33 33
     getKeyExtractor(item: Object) {
34
-        return item !== undefined ? item.type : undefined;
34
+        return item !== undefined ? item.type['id'] : undefined;
35 35
     }
36 36
 
37 37
     createDataset(fetchedData: Object) {

+ 6
- 2
screens/SelfMenuScreen.js View File

@@ -53,7 +53,7 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
53 53
     }
54 54
 
55 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 59
     hasBackButton() {
@@ -79,12 +79,16 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
79 79
         }
80 80
         // fetched data is an array here
81 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 86
             result.push(
83 87
                 {
84 88
                     title: this.getFormattedDate(fetchedData[i].date),
85 89
                     data: fetchedData[i].meal[0].foodcategory,
86 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,7 +69,23 @@
69 69
   },
70 70
   "homeScreen": {
71 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 90
   "planningScreen": {
75 91
     "wipTitle": "WORK IN PROGRESS",

Loading…
Cancel
Save