Browse Source

Improved AF + improved dashboard buttons

keplyx 4 years ago
parent
commit
da24621c67

+ 1
- 1
components/CustomIntroSlider.js View File

@@ -116,7 +116,7 @@ export default class CustomIntroSlider extends React.Component<Props> {
116 116
                 key: '1',
117 117
                 title: i18n.t('intro.aprilFoolsSlide.title'),
118 118
                 text: i18n.t('intro.aprilFoolsSlide.text'),
119
-                icon: 'information',
119
+                icon: 'fish',
120 120
                 colors: ['#e01928', '#be1522'],
121 121
             },
122 122
         ];

+ 24
- 46
components/SquareDashboardItem.js View File

@@ -1,54 +1,32 @@
1 1
 import * as React from 'react';
2
-import {Card, Text, Title, withTheme} from 'react-native-paper';
2
+import {Badge, IconButton, withTheme} from 'react-native-paper';
3 3
 import {View} from "react-native";
4
-import {MaterialCommunityIcons} from "@expo/vector-icons";
5 4
 
6 5
 function SquareDashboardItem(props) {
7
-    const { colors } = props.theme;
6
+    const {colors} = props.theme;
8 7
     return (
9
-        <Card
10
-            style={{
11
-                width: '48%',
12
-                marginTop: 10,
13
-                marginRight: props.isLeft ? '4%': 0,
14
-                overflow: 'hidden',
15
-            }}
16
-            onPress={props.clickAction}>
17
-            <Card.Content>
18
-                <View style={{marginLeft: 'auto', marginRight: 'auto'}}>
19
-                    <MaterialCommunityIcons
20
-                        name={props.icon}
21
-                        color={
22
-                            props.isAvailable ?
23
-                                props.color :
24
-                                colors.textDisabled
25
-                        }
26
-                        size={50}/>
27
-                </View>
28
-                <View style={{
29
-                    width: '100%',
30
-                }}>
31
-                    <Title style={{
32
-                        color: props.isAvailable ?
33
-                            colors.text :
34
-                            colors.textDisabled,
35
-                        textAlign: 'center',
36
-                        width: '100%',
37
-                    }}>
38
-                        {props.title}
39
-                    </Title>
40
-                    <Text style={{
41
-                        color: props.isAvailable ?
42
-                            colors.text :
43
-                            colors.textDisabled,
44
-                        textAlign: 'center',
45
-                        width: '100%',
46
-                    }}>
47
-                        {props.subtitle}
48
-                    </Text>
49
-                </View>
50
-            </Card.Content>
51
-        </Card>
8
+        <View>
9
+            <IconButton
10
+                icon={props.icon}
11
+                color={
12
+                    props.isAvailable ?
13
+                        props.color :
14
+                        colors.textDisabled
15
+                }
16
+                size={35}
17
+                onPress={props.clickAction}
18
+            />
19
+            {
20
+                props.badgeNumber > 0 ?
21
+                    <Badge
22
+                        style={{
23
+                            position: 'absolute',
24
+                            top: 5,
25
+                            right: 5
26
+                        }}>{props.badgeNumber}</Badge> : null
27
+            }
28
+
29
+        </View>
52 30
     );
53 31
 }
54 32
 

+ 50
- 166
screens/HomeScreen.js View File

@@ -1,14 +1,13 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import {TouchableOpacity, View} from 'react-native';
4
+import {View} from 'react-native';
5 5
 import i18n from "i18n-js";
6
-import Autolink from 'react-native-autolink';
7 6
 import ThemeManager from "../utils/ThemeManager";
8 7
 import DashboardItem from "../components/EventDashboardItem";
9 8
 import * as WebBrowser from 'expo-web-browser';
10 9
 import WebSectionList from "../components/WebSectionList";
11
-import {Avatar, Button, Card, Text} from 'react-native-paper';
10
+import {Text} from 'react-native-paper';
12 11
 import FeedItem from "../components/FeedItem";
13 12
 import SquareDashboardItem from "../components/SquareDashboardItem";
14 13
 import PreviewEventDashboardItem from "../components/PreviewEventDashboardItem";
@@ -109,36 +108,32 @@ export default class HomeScreen extends React.Component<Props> {
109 108
 
110 109
     generateDashboardDataset(dashboardData: Object) {
111 110
         let dataset = [
112
-            {
113
-                id: 'event',
114
-                content: undefined
115
-            },
111
+
116 112
             {
117 113
                 id: 'middle',
118
-                content: [{}, {}]
114
+                content: []
119 115
             },
120 116
             {
121
-                id: 'bottom',
122
-                content: [{}, {}]
117
+                id: 'event',
118
+                content: undefined
123 119
             },
124
-
125 120
         ];
126 121
         for (let [key, value] of Object.entries(dashboardData)) {
127 122
             switch (key) {
128 123
                 case 'today_events':
129
-                    dataset[0]['content'] = value;
124
+                    dataset[1]['content'] = value;
130 125
                     break;
131 126
                 case 'available_machines':
132
-                    dataset[1]['content'][0] = {id: key, data: value};
127
+                    dataset[0]['content'][0] = {id: key, data: value};
133 128
                     break;
134 129
                 case 'available_tutorials':
135
-                    dataset[1]['content'][1] = {id: key, data: value};
130
+                    dataset[0]['content'][1] = {id: key, data: value};
136 131
                     break;
137 132
                 case 'proximo_articles':
138
-                    dataset[2]['content'][0] = {id: key, data: value};
133
+                    dataset[0]['content'][2] = {id: key, data: value};
139 134
                     break;
140 135
                 case 'today_menu':
141
-                    dataset[2]['content'][1] = {id: key, data: value};
136
+                    dataset[0]['content'][3] = {id: key, data: value};
142 137
                     break;
143 138
 
144 139
             }
@@ -152,8 +147,6 @@ export default class HomeScreen extends React.Component<Props> {
152 147
             return this.getDashboardEventItem(content);
153 148
         else if (item['id'] === 'middle')
154 149
             return this.getDashboardMiddleItem(content);
155
-        else
156
-            return this.getDashboardBottomItem(content);
157 150
     }
158 151
 
159 152
     /**
@@ -310,7 +303,8 @@ export default class HomeScreen extends React.Component<Props> {
310 303
 
311 304
         let displayEvent = this.getDisplayEvent(futureEvents);
312 305
         const clickContainerAction = () => this.props.navigation.navigate('Planning');
313
-        const clickPreviewAction = () => this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent});;
306
+        const clickPreviewAction = () => this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent});
307
+
314 308
         return (
315 309
             <DashboardItem
316 310
                 {...this.props}
@@ -330,164 +324,54 @@ export default class HomeScreen extends React.Component<Props> {
330 324
     }
331 325
 
332 326
 
333
-    getDashboardBottomItem(content: Array<Object>) {
334
-        let proximoData = content[0]['data'];
335
-        let menuData = content[1]['data'];
336
-        let proximoIcon = 'shopping';
337
-        let proximoColor = ThemeManager.getCurrentThemeVariables().proximoColor;
338
-        let proximoTitle = i18n.t('homeScreen.dashboard.proximoTitle');
339
-        let isProximoAvailable = parseInt(proximoData) > 0;
340
-        let proximoSubtitle;
341
-        if (isProximoAvailable) {
342
-            proximoSubtitle =
343
-                <Text>
344
-                    <Text style={{fontWeight: "bold"}}>{proximoData}</Text>
345
-                    <Text>
346
-                        {
347
-                            proximoData > 1 ?
348
-                                i18n.t('homeScreen.dashboard.proximoSubtitlePlural') :
349
-                                i18n.t('homeScreen.dashboard.proximoSubtitle')
350
-                        }
351
-                    </Text>
352
-                </Text>;
353
-        } else
354
-            proximoSubtitle = i18n.t('homeScreen.dashboard.proximoSubtitleNA');
355
-
356
-
357
-        let menuIcon = 'silverware-fork-knife';
358
-        let menuColor = ThemeManager.getCurrentThemeVariables().menuColor;
359
-        let menuTitle = i18n.t('homeScreen.dashboard.menuTitle');
360
-        let isMenuAvailable = menuData.length > 0;
361
-        let menuSubtitle;
362
-        if (isMenuAvailable) {
363
-            menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitle');
364
-        } else
365
-            menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitleNA');
366
-        return (
367
-            <View style={{
368
-                flexDirection: 'row',
369
-                marginLeft: 10,
370
-                marginRight: 10,
371
-                marginBottom: 10,
372
-            }}>
373
-                <SquareDashboardItem
374
-                    title={menuTitle}
375
-                    subtitle={menuSubtitle}
376
-                    color={menuColor}
377
-                    icon={menuIcon}
378
-                    clickAction={this.onMenuClick}
379
-                    isAvailable={isMenuAvailable}
380
-                    isLeft={true}/>
381
-                <SquareDashboardItem
382
-                    title={proximoTitle}
383
-                    subtitle={proximoSubtitle}
384
-                    color={proximoColor}
385
-                    icon={proximoIcon}
386
-                    clickAction={this.onProximoClick}
387
-                    isAvailable={isProximoAvailable}
388
-                    isLeft={false}/>
389
-            </View>
390
-        );
391
-    }
392
-
393
-
394 327
     getDashboardMiddleItem(content: Array<Object>) {
395 328
         let proxiwashData = content[0]['data'];
396 329
         let tutorinsaData = content[1]['data'];
397
-
398
-        let proxiwashIcon = 'washing-machine';
399
-        let proxiwashColor = ThemeManager.getCurrentThemeVariables().proxiwashColor;
400
-        let proxiwashTitle = i18n.t('homeScreen.dashboard.proxiwashTitle');
401
-        let proxiwashIsAvailable = parseInt(proxiwashData['dryers']) > 0 || parseInt(proxiwashData['washers']) > 0;
402
-        let proxiwashSubtitle;
403
-        let dryerColor = parseInt(proxiwashData['dryers']) > 0 ?
404
-            ThemeManager.getCurrentThemeVariables().text :
405
-            ThemeManager.getCurrentThemeVariables().textDisabled;
406
-        let washerColor = parseInt(proxiwashData['washers']) > 0 ?
407
-            ThemeManager.getCurrentThemeVariables().text :
408
-            ThemeManager.getCurrentThemeVariables().textDisabled;
409
-        let availableDryers = proxiwashData['dryers'];
410
-        let availableWashers = proxiwashData['washers'];
411
-        if (proxiwashIsAvailable) {
412
-            proxiwashSubtitle =
413
-                <Text>
414
-                    <Text style={{
415
-                        fontWeight: parseInt(proxiwashData['dryers']) > 0 ?
416
-                            'bold' :
417
-                            'normal',
418
-                        color: dryerColor
419
-                    }}>
420
-                        {availableDryers}
421
-                    </Text>
422
-                    <Text>
423
-                        {
424
-                            availableDryers > 1 ?
425
-                                i18n.t('homeScreen.dashboard.proxiwashSubtitle1Plural') :
426
-                                i18n.t('homeScreen.dashboard.proxiwashSubtitle1')
427
-                        }
428
-                    </Text>
429
-                    {"\n"}
430
-                    <Text style={{
431
-                        fontWeight: parseInt(proxiwashData['washers']) > 0 ?
432
-                            'bold' :
433
-                            'normal',
434
-                        color: washerColor
435
-                    }}>
436
-                        {availableWashers}
437
-                    </Text>
438
-                    <Text>
439
-                        {
440
-                            availableWashers > 1 ?
441
-                                i18n.t('homeScreen.dashboard.proxiwashSubtitle2Plural') :
442
-                                i18n.t('homeScreen.dashboard.proxiwashSubtitle2')
443
-                        }
444
-                    </Text>
445
-                </Text>;
446
-        } else
447
-            proxiwashSubtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA');
448
-
449
-        let tutorinsaIcon = 'school';
450
-        let tutorinsaColor = ThemeManager.getCurrentThemeVariables().tutorinsaColor;
451
-        let tutorinsaTitle = 'Tutor\'INSA';
452
-        let tutorinsaIsAvailable = tutorinsaData > 0;
453
-        let tutorinsaSubtitle;
454
-        if (tutorinsaIsAvailable) {
455
-            tutorinsaSubtitle =
456
-                <Text>
457
-                    <Text style={{fontWeight: "bold"}}>{tutorinsaData}</Text>
458
-                    <Text>
459
-                        {
460
-                            tutorinsaData > 1 ?
461
-                                i18n.t('homeScreen.dashboard.tutorinsaSubtitlePlural') :
462
-                                i18n.t('homeScreen.dashboard.tutorinsaSubtitle')
463
-                        }
464
-                    </Text>
465
-                </Text>;
466
-        } else
467
-            tutorinsaSubtitle = i18n.t('homeScreen.dashboard.tutorinsaSubtitleNA');
468
-
330
+        let proximoData = content[2]['data'];
331
+        let menuData = content[3]['data'];
469 332
         return (
470 333
             <View style={{
334
+                flex: 1,
471 335
                 flexDirection: 'row',
472
-                marginLeft: 10,
473
-                marginRight: 10,
336
+                justifyContent: 'center',
337
+                flexWrap: 'wrap',
338
+                margin: 10,
474 339
             }}>
475 340
                 <SquareDashboardItem
476
-                    title={proxiwashTitle}
477
-                    subtitle={proxiwashSubtitle}
478
-                    color={proxiwashColor}
479
-                    icon={proxiwashIcon}
341
+                    color={ThemeManager.getCurrentThemeVariables().proxiwashColor}
342
+                    icon={'washing-machine'}
343
+                    clickAction={this.onProxiwashClick}
344
+                    isAvailable={parseInt(proxiwashData['washers']) > 0}
345
+                    badgeNumber={proxiwashData['washers']}
346
+                />
347
+                <SquareDashboardItem
348
+                    color={ThemeManager.getCurrentThemeVariables().proxiwashColor}
349
+                    icon={'tumble-dryer'}
480 350
                     clickAction={this.onProxiwashClick}
481
-                    isAvailable={proxiwashIsAvailable}
482
-                    isLeft={true}/>
351
+                    isAvailable={parseInt(proxiwashData['dryers']) > 0}
352
+                    badgeNumber={proxiwashData['dryers']}
353
+                />
483 354
                 <SquareDashboardItem
484
-                    title={tutorinsaTitle}
485
-                    subtitle={tutorinsaSubtitle}
486
-                    color={tutorinsaColor}
487
-                    icon={tutorinsaIcon}
355
+                    color={ThemeManager.getCurrentThemeVariables().tutorinsaColor}
356
+                    icon={'school'}
488 357
                     clickAction={this.onTutorInsaClick}
489
-                    isAvailable={tutorinsaIsAvailable}
490
-                    isLeft={false}/>
358
+                    isAvailable={tutorinsaData > 0}
359
+                    badgeNumber={tutorinsaData}
360
+                />
361
+                <SquareDashboardItem
362
+                    color={ThemeManager.getCurrentThemeVariables().proximoColor}
363
+                    icon={'shopping'}
364
+                    clickAction={this.onProximoClick}
365
+                    isAvailable={parseInt(proximoData) > 0}
366
+                    badgeNumber={parseInt(proximoData)}
367
+                />
368
+                <SquareDashboardItem
369
+                    color={ThemeManager.getCurrentThemeVariables().menuColor}
370
+                    icon={'silverware-fork-knife'}
371
+                    clickAction={this.onMenuClick}
372
+                    isAvailable={menuData.length > 0}
373
+                    badgeNumber={0}
374
+                />
491 375
             </View>
492 376
         );
493 377
     }

+ 11
- 14
utils/AprilFoolsManager.js View File

@@ -25,32 +25,29 @@ export default class AprilFoolsManager {
25 25
     }
26 26
 
27 27
     static getFakeMenuItem(menu: Object) {
28
-        if (menu[1]["dishes"].length >= 3) {
29
-            menu[1]["dishes"].splice(0, 0, {name: "Coq au vin"});
30
-            menu[1]["dishes"].splice(2, 0, {name: "Pave de loup"});
31
-        } else {
32
-            menu[1]["dishes"].push({name: "Coq au vin"});
33
-            menu[1]["dishes"].push({name: "Pave de loup"});
34
-        }
28
+        menu[1]["dishes"].splice(2, 0, {name: "Coq au vin"});
29
+        menu[1]["dishes"].splice(1, 0, {name: "Pave de loup"});
30
+        menu[1]["dishes"].splice(0, 0, {name: "Béranger à point"});
31
+        menu[1]["dishes"].splice(0, 0, {name: "Pieds d'Arnaud"});
35 32
         return menu;
36 33
     }
37 34
 
38
-    static getAprilFoolsTheme(currentTheme : Object) {
35
+    static getAprilFoolsTheme(currentTheme: Object) {
39 36
         return {
40 37
             ...currentTheme,
41 38
             colors: {
42 39
                 ...currentTheme.colors,
43 40
                 primary: '#00be45',
44 41
                 accent: '#00be45',
45
-                background: '#50005b',
46
-                tabBackground: "#50005b",
47
-                card: "#50005b",
48
-                surface: "#50005b",
49
-                dividerBackground: '#3e0047',
42
+                background: '#d02eee',
43
+                tabIcon: "#380d43",
44
+                card: "#eed639",
45
+                surface: "#eed639",
46
+                dividerBackground: '#c72ce4',
50 47
                 textDisabled: '#b9b9b9',
51 48
 
52 49
                 // Calendar/Agenda
53
-                agendaBackgroundColor: '#5b3e02',
50
+                agendaBackgroundColor: '#c72ce4',
54 51
                 agendaDayTextColor: '#6d6d6d',
55 52
             },
56 53
         };

+ 1
- 1
utils/ThemeManager.js View File

@@ -120,7 +120,7 @@ export default class ThemeManager {
120 120
      */
121 121
     static getCurrentTheme(): Object {
122 122
         if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
123
-            return AprilFoolsManager.getAprilFoolsTheme(ThemeManager.getDarkTheme());
123
+            return AprilFoolsManager.getAprilFoolsTheme(ThemeManager.getWhiteTheme());
124 124
          else
125 125
             return ThemeManager.getBaseTheme()
126 126
     }

Loading…
Cancel
Save