Browse Source

Optimised imported and cleaned code

keplyx 4 years ago
parent
commit
c478a117b5

+ 5
- 8
components/BaseContainer.js View File

@@ -5,7 +5,7 @@ import {Container} from "native-base";
5 5
 import CustomHeader from "./CustomHeader";
6 6
 import CustomSideMenu from "./CustomSideMenu";
7 7
 import CustomMaterialIcon from "./CustomMaterialIcon";
8
-import {Platform, View, StatusBar} from "react-native";
8
+import {Platform, StatusBar, View} from "react-native";
9 9
 import ThemeManager from "../utils/ThemeManager";
10 10
 import Touchable from "react-native-platform-touchable";
11 11
 import {ScreenOrientation} from "expo";
@@ -32,9 +32,6 @@ type State = {
32 32
 
33 33
 export default class BaseContainer extends React.Component<Props, State> {
34 34
 
35
-    willBlurSubscription: function;
36
-    willFocusSubscription: function;
37
-
38 35
     static defaultProps = {
39 36
         headerRightButton: <View/>,
40 37
         hasTabs: false,
@@ -43,8 +40,8 @@ export default class BaseContainer extends React.Component<Props, State> {
43 40
         enableRotation: false,
44 41
         hideHeaderOnLandscape: false,
45 42
     };
46
-
47
-
43
+    willBlurSubscription: function;
44
+    willFocusSubscription: function;
48 45
     state = {
49 46
         isOpen: false,
50 47
         isHeaderVisible: true,
@@ -66,7 +63,7 @@ export default class BaseContainer extends React.Component<Props, State> {
66 63
     componentDidMount() {
67 64
         this.willFocusSubscription = this.props.navigation.addListener(
68 65
             'willFocus',
69
-            payload => {
66
+            () => {
70 67
                 if (this.props.enableRotation) {
71 68
                     ScreenOrientation.unlockAsync();
72 69
                     ScreenOrientation.addOrientationChangeListener((OrientationChangeEvent) => {
@@ -87,7 +84,7 @@ export default class BaseContainer extends React.Component<Props, State> {
87 84
             });
88 85
         this.willBlurSubscription = this.props.navigation.addListener(
89 86
             'willBlur',
90
-            payload => {
87
+            () => {
91 88
                 if (this.props.enableRotation)
92 89
                     ScreenOrientation.lockAsync(ScreenOrientation.Orientation.PORTRAIT);
93 90
                 this.setState({isOpen: false});

+ 1
- 1
components/CustomHeader.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from "react";
4
-import {Body, Header, Input, Item, Left, Right, Title, Form} from "native-base";
4
+import {Body, Header, Input, Item, Left, Right, Title} from "native-base";
5 5
 import {Platform, StyleSheet, View} from "react-native";
6 6
 import {getStatusBarHeight} from "react-native-status-bar-height";
7 7
 import Touchable from 'react-native-platform-touchable';

+ 9
- 10
components/FetchedDataSectionList.js View File

@@ -35,13 +35,6 @@ export default class FetchedDataSectionList extends React.Component<Props, State
35 35
     lastRefresh: Date;
36 36
 
37 37
     minTimeBetweenRefresh = 60;
38
-
39
-    constructor(fetchUrl: string, refreshTime: number) {
40
-        super();
41
-        this.webDataManager = new WebDataManager(fetchUrl);
42
-        this.refreshTime = refreshTime;
43
-    }
44
-
45 38
     state = {
46 39
         refreshing: false,
47 40
         firstLoading: true,
@@ -49,6 +42,12 @@ export default class FetchedDataSectionList extends React.Component<Props, State
49 42
         machinesWatched: [],
50 43
     };
51 44
 
45
+    constructor(fetchUrl: string, refreshTime: number) {
46
+        super();
47
+        this.webDataManager = new WebDataManager(fetchUrl);
48
+        this.refreshTime = refreshTime;
49
+    }
50
+
52 51
     /**
53 52
      * Get the translation for the header in the current language
54 53
      * @return {string}
@@ -76,13 +75,13 @@ export default class FetchedDataSectionList extends React.Component<Props, State
76 75
     componentDidMount() {
77 76
         this.willFocusSubscription = this.props.navigation.addListener(
78 77
             'willFocus',
79
-            payload => {
78
+            () => {
80 79
                 this.onScreenFocus();
81 80
             }
82 81
         );
83 82
         this.willBlurSubscription = this.props.navigation.addListener(
84 83
             'willBlur',
85
-            payload => {
84
+            () => {
86 85
                 this.onScreenBlur();
87 86
             }
88 87
         );
@@ -136,7 +135,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
136 135
                     });
137 136
                     this.lastRefresh = new Date();
138 137
                 })
139
-                .catch((err) => {
138
+                .catch(() => {
140 139
                     this.setState({
141 140
                         fetchedData: {},
142 141
                         refreshing: false,

+ 1
- 2
components/Sidebar.js View File

@@ -2,12 +2,11 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {Dimensions, FlatList, Image, Linking, Platform, StyleSheet} from 'react-native';
5
-import {Badge, Container, Content, Left, ListItem, Right, Text} from "native-base";
5
+import {Badge, Container, Left, ListItem, Right, Text} from "native-base";
6 6
 import i18n from "i18n-js";
7 7
 import CustomMaterialIcon from '../components/CustomMaterialIcon';
8 8
 import ThemeManager from "../utils/ThemeManager";
9 9
 
10
-const deviceHeight = Dimensions.get("window").height;
11 10
 const deviceWidth = Dimensions.get("window").width;
12 11
 
13 12
 const drawerCover = require("../assets/drawer-cover.png");

+ 2
- 3
components/WebViewScreen.js View File

@@ -2,13 +2,12 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {Linking, Platform, View} from 'react-native';
5
-import {Spinner, Footer, Right, Left, Body, Tab, TabHeading, Text, Tabs} from 'native-base';
5
+import {Body, Footer, Left, Right, Spinner, Tab, TabHeading, Tabs, Text} from 'native-base';
6 6
 import WebView from "react-native-webview";
7 7
 import Touchable from "react-native-platform-touchable";
8 8
 import CustomMaterialIcon from "../components/CustomMaterialIcon";
9 9
 import ThemeManager from "../utils/ThemeManager";
10 10
 import BaseContainer from "../components/BaseContainer";
11
-import {NavigationActions} from 'react-navigation';
12 11
 
13 12
 type Props = {
14 13
     navigation: Object,
@@ -153,7 +152,7 @@ export default class WebViewScreen extends React.Component<Props> {
153 152
                             elevation: 0, // Fix for android shadow
154 153
                         }}
155 154
                         locked={true}
156
-                        style = {{
155
+                        style={{
157 156
                             backgroundColor: Platform.OS === 'ios' ?
158 157
                                 ThemeManager.getCurrentThemeVariables().tabDefaultBg :
159 158
                                 ThemeManager.getCurrentThemeVariables().brandPrimary

+ 1
- 0
navigation/AppNavigator.js View File

@@ -52,4 +52,5 @@ function createAppContainerWithInitialRoute(initialRoute: string) {
52 52
             })
53 53
     );
54 54
 }
55
+
55 56
 export {createAppContainerWithInitialRoute};

+ 0
- 34
navigation/MainDrawerNavigator.js View File

@@ -1,34 +0,0 @@
1
-// @flow
2
-
3
-import * as React from 'react';
4
-import {createDrawerNavigator} from 'react-navigation';
5
-
6
-import HomeScreen from '../screens/HomeScreen';
7
-import PlanningScreen from '../screens/PlanningScreen';
8
-import ProxiwashScreen from '../screens/Proxiwash/ProxiwashScreen';
9
-import ProximoMainScreen from '../screens/Proximo/ProximoMainScreen';
10
-import PlanexScreen from '../screens/Websites/PlanexScreen';
11
-import SettingsScreen from '../screens/SettingsScreen';
12
-import AboutScreen from '../screens/About/AboutScreen';
13
-import Sidebar from "../components/Sidebar";
14
-
15
-/**
16
- * Creates the drawer navigation stack
17
- */
18
-export default createDrawerNavigator({
19
-        Home: {screen: HomeScreen},
20
-        Planning: {screen: PlanningScreen,},
21
-        Proxiwash: {screen: ProxiwashScreen,},
22
-        Proximo: {screen: ProximoMainScreen,},
23
-        Planex: {screen: PlanexScreen},
24
-        Settings: {screen: SettingsScreen,},
25
-        About: {screen: AboutScreen,},
26
-    }, {
27
-        contentComponent: Sidebar,
28
-        initialRouteName: 'Home',
29
-        backBehavior: 'initialRoute',
30
-        drawerType: 'front',
31
-        useNativeAnimations: true,
32
-    }
33
-);
34
-

+ 0
- 1
navigation/MainTabNavigator.js View File

@@ -8,7 +8,6 @@ import ProximoMainScreen from '../screens/Proximo/ProximoMainScreen';
8 8
 import PlanexScreen from '../screens/Websites/PlanexScreen';
9 9
 import CustomMaterialIcon from "../components/CustomMaterialIcon";
10 10
 import ThemeManager from "../utils/ThemeManager";
11
-import AsyncStorageManager from "../utils/AsyncStorageManager";
12 11
 
13 12
 const TAB_ICONS = {
14 13
     Home: 'triangle',

+ 2
- 2
package.json View File

@@ -8,8 +8,6 @@
8 8
     "eject": "expo eject"
9 9
   },
10 10
   "dependencies": {
11
-    "@expo/vector-icons": "^10.0.0",
12
-    "@react-native-community/status-bar": "^1.0.3",
13 11
     "expo": "^36.0.0",
14 12
     "expo-font": "~8.0.0",
15 13
     "expo-linear-gradient": "~8.0.0",
@@ -27,8 +25,10 @@
27 25
     "react-native-gesture-handler": "~1.5.0",
28 26
     "react-native-material-menu": "^0.6.7",
29 27
     "react-native-modalize": "^1.3.6",
28
+    "react-native-paper": "^3.5.1",
30 29
     "react-native-platform-touchable": "^1.1.1",
31 30
     "react-native-render-html": "^4.1.2",
31
+    "react-native-screens": "2.0.0-alpha.12",
32 32
     "react-native-side-menu": "^1.1.3",
33 33
     "react-native-status-bar-height": "^2.3.1",
34 34
     "react-native-webview": "7.4.3",

+ 1
- 1
screens/About/AboutDependenciesScreen.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import {Body, Container, Content, ListItem, Text} from 'native-base';
4
+import {Body, Container, ListItem, Text} from 'native-base';
5 5
 import CustomHeader from "../../components/CustomHeader";
6 6
 import {FlatList} from "react-native";
7 7
 import i18n from "i18n-js";

+ 6
- 11
screens/About/AboutScreen.js View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {FlatList, Linking, Platform, View} from 'react-native';
5
-import {Body, Card, CardItem, Container, Content, H1, Left, Right, Text, Thumbnail, Button} from 'native-base';
5
+import {Body, Button, Card, CardItem, Container, H1, Left, Right, Text, Thumbnail} from 'native-base';
6 6
 import CustomHeader from "../../components/CustomHeader";
7 7
 import i18n from "i18n-js";
8 8
 import appJson from '../../app';
@@ -70,12 +70,6 @@ export default class AboutScreen extends React.Component<Props, State> {
70 70
     state = {
71 71
         isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1'
72 72
     };
73
-
74
-    constructor(props: any) {
75
-        super(props);
76
-        this.modalRef = React.createRef();
77
-    }
78
-
79 73
     /**
80 74
      * Data to be displayed in the app card
81 75
      */
@@ -118,7 +112,6 @@ export default class AboutScreen extends React.Component<Props, State> {
118 112
             showOnlyDebug: true
119 113
         },
120 114
     ];
121
-
122 115
     /**
123 116
      * Data to be displayed in the author card
124 117
      */
@@ -142,7 +135,6 @@ export default class AboutScreen extends React.Component<Props, State> {
142 135
             showChevron: true
143 136
         },
144 137
     ];
145
-
146 138
     /**
147 139
      * Data to be displayed in the additional developer card
148 140
      */
@@ -166,7 +158,6 @@ export default class AboutScreen extends React.Component<Props, State> {
166 158
             showChevron: true
167 159
         },
168 160
     ];
169
-
170 161
     /**
171 162
      * Data to be displayed in the technologies card
172 163
      */
@@ -184,7 +175,6 @@ export default class AboutScreen extends React.Component<Props, State> {
184 175
             showChevron: true
185 176
         },
186 177
     ];
187
-
188 178
     dataOrder: Array<Object> = [
189 179
         {
190 180
             id: 'app',
@@ -197,6 +187,11 @@ export default class AboutScreen extends React.Component<Props, State> {
197 187
         },
198 188
     ];
199 189
 
190
+    constructor(props: any) {
191
+        super(props);
192
+        this.modalRef = React.createRef();
193
+    }
194
+
200 195
     getAppCard() {
201 196
         return (
202 197
             <Card>

+ 28
- 31
screens/DebugScreen.js View File

@@ -3,29 +3,28 @@
3 3
 import * as React from 'react';
4 4
 import {
5 5
     Body,
6
+    Button,
6 7
     Card,
7 8
     CardItem,
8 9
     Container,
9 10
     Content,
11
+    Form,
10 12
     H1,
11 13
     H3,
14
+    Input,
15
+    Item,
16
+    Label,
12 17
     Left,
13 18
     List,
14 19
     ListItem,
15 20
     Right,
16
-    Text,
17
-    Form,
18
-    Item,
19
-    Label,
20
-    Input,
21
-    Button
21
+    Text
22 22
 } from "native-base";
23 23
 import CustomHeader from "../components/CustomHeader";
24 24
 import ThemeManager from '../utils/ThemeManager';
25 25
 import i18n from "i18n-js";
26 26
 import CustomMaterialIcon from "../components/CustomMaterialIcon";
27
-import Touchable from "react-native-platform-touchable";
28
-import {Alert, View, Clipboard, Image} from "react-native";
27
+import {Alert, Clipboard, View} from "react-native";
29 28
 import AsyncStorageManager from "../utils/AsyncStorageManager";
30 29
 import NotificationsManager from "../utils/NotificationsManager";
31 30
 import {Modalize} from "react-native-modalize";
@@ -46,36 +45,16 @@ export default class DebugScreen extends React.Component<Props, State> {
46 45
 
47 46
     modalRef: { current: null | Modalize };
48 47
     modalInputValue = '';
49
-
50
-    constructor(props: any) {
51
-        super(props);
52
-        this.modalRef = React.createRef();
53
-    }
54
-
55 48
     state = {
56 49
         modalCurrentDisplayItem: {},
57 50
         currentPreferences: JSON.parse(JSON.stringify(AsyncStorageManager.getInstance().preferences))
58 51
     };
59 52
 
60
-    alertCurrentExpoToken() {
61
-        let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
62
-        console.log(token);
63
-        Alert.alert(
64
-            'Expo Token',
65
-            token,
66
-            [
67
-                {text: 'Copy', onPress: () => Clipboard.setString(token)},
68
-                {text: 'OK'}
69
-            ]
70
-        );
71
-    }
72
-
73
-    async forceExpoTokenUpdate() {
74
-        await NotificationsManager.forceExpoTokenUpdate();
75
-        this.alertCurrentExpoToken();
53
+    constructor(props: any) {
54
+        super(props);
55
+        this.modalRef = React.createRef();
76 56
     }
77 57
 
78
-
79 58
     static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) {
80 59
         return (
81 60
             <ListItem
@@ -102,6 +81,24 @@ export default class DebugScreen extends React.Component<Props, State> {
102 81
         );
103 82
     }
104 83
 
84
+    alertCurrentExpoToken() {
85
+        let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
86
+        console.log(token);
87
+        Alert.alert(
88
+            'Expo Token',
89
+            token,
90
+            [
91
+                {text: 'Copy', onPress: () => Clipboard.setString(token)},
92
+                {text: 'OK'}
93
+            ]
94
+        );
95
+    }
96
+
97
+    async forceExpoTokenUpdate() {
98
+        await NotificationsManager.forceExpoTokenUpdate();
99
+        this.alertCurrentExpoToken();
100
+    }
101
+
105 102
     showEditModal(item: Object) {
106 103
         this.setState({
107 104
             modalCurrentDisplayItem: item

+ 49
- 54
screens/HomeScreen.js View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {Image, Linking, TouchableOpacity, View} from 'react-native';
5
-import {Body, Button, Card, CardItem, Left, Text, Thumbnail, H1, H3} from 'native-base';
5
+import {Body, Button, Card, CardItem, H1, Left, Text, Thumbnail} from 'native-base';
6 6
 import i18n from "i18n-js";
7 7
 import CustomMaterialIcon from '../components/CustomMaterialIcon';
8 8
 import FetchedDataSectionList from "../components/FetchedDataSectionList";
@@ -42,6 +42,16 @@ export default class HomeScreen extends FetchedDataSectionList {
42 42
         super(DATA_URL, REFRESH_TIME);
43 43
     }
44 44
 
45
+    /**
46
+     * Converts a dateString using Unix Timestamp to a formatted date
47
+     * @param dateString {string} The Unix Timestamp representation of a date
48
+     * @return {string} The formatted output date
49
+     */
50
+    static getFormattedDate(dateString: string) {
51
+        let date = new Date(Number.parseInt(dateString) * 1000);
52
+        return date.toLocaleString();
53
+    }
54
+
45 55
     getHeaderTranslation() {
46 56
         return i18n.t("screens.home");
47 57
     }
@@ -119,17 +129,6 @@ export default class HomeScreen extends FetchedDataSectionList {
119 129
         return dataset
120 130
     }
121 131
 
122
-
123
-    /**
124
-     * Converts a dateString using Unix Timestamp to a formatted date
125
-     * @param dateString {string} The Unix Timestamp representation of a date
126
-     * @return {string} The formatted output date
127
-     */
128
-    static getFormattedDate(dateString: string) {
129
-        let date = new Date(Number.parseInt(dateString) * 1000);
130
-        return date.toLocaleString();
131
-    }
132
-
133 132
     getRenderSectionHeader(title: string) {
134 133
         if (title === '') {
135 134
             return <View/>;
@@ -294,7 +293,7 @@ export default class HomeScreen extends FetchedDataSectionList {
294 293
         let icon = 'calendar-range';
295 294
         let color = ThemeManager.getCurrentThemeVariables().planningColor;
296 295
         let title = i18n.t('homeScreen.dashboard.todayEventsTitle');
297
-        let subtitle = '';
296
+        let subtitle;
298 297
         let futureEvents = this.getFutureEvents(content);
299 298
         let isAvailable = futureEvents.length > 0;
300 299
         if (isAvailable) {
@@ -336,7 +335,7 @@ export default class HomeScreen extends FetchedDataSectionList {
336 335
         let proximoColor = ThemeManager.getCurrentThemeVariables().proximoColor;
337 336
         let proximoTitle = i18n.t('homeScreen.dashboard.proximoTitle');
338 337
         let isProximoAvailable = parseInt(proximoData) > 0;
339
-        let proximoSubtitle = '';
338
+        let proximoSubtitle;
340 339
         if (isProximoAvailable) {
341 340
             proximoSubtitle =
342 341
                 <Text>
@@ -358,7 +357,7 @@ export default class HomeScreen extends FetchedDataSectionList {
358 357
         let menuColor = ThemeManager.getCurrentThemeVariables().menuColor;
359 358
         let menuTitle = i18n.t('homeScreen.dashboard.menuTitle');
360 359
         let isMenuAvailable = menuData.length > 0;
361
-        let menuSubtitle = '';
360
+        let menuSubtitle;
362 361
         if (isMenuAvailable) {
363 362
             menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitle');
364 363
         } else
@@ -410,39 +409,39 @@ export default class HomeScreen extends FetchedDataSectionList {
410 409
         let availableWashers = proxiwashData['washers'];
411 410
         if (proxiwashIsAvailable) {
412 411
             proxiwashSubtitle =
412
+                <Text>
413
+                    <Text style={{
414
+                        fontWeight: parseInt(proxiwashData['dryers']) > 0 ?
415
+                            'bold' :
416
+                            'normal',
417
+                        color: dryerColor
418
+                    }}>
419
+                        {availableDryers}
420
+                    </Text>
413 421
                     <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>;
422
+                        {
423
+                            availableDryers > 1 ?
424
+                                i18n.t('homeScreen.dashboard.proxiwashSubtitle1Plural') :
425
+                                i18n.t('homeScreen.dashboard.proxiwashSubtitle1')
426
+                        }
427
+                    </Text>
428
+                    {"\n"}
429
+                    <Text style={{
430
+                        fontWeight: parseInt(proxiwashData['washers']) > 0 ?
431
+                            'bold' :
432
+                            'normal',
433
+                        color: washerColor
434
+                    }}>
435
+                        {availableWashers}
436
+                    </Text>
437
+                    <Text>
438
+                        {
439
+                            availableWashers > 1 ?
440
+                                i18n.t('homeScreen.dashboard.proxiwashSubtitle2Plural') :
441
+                                i18n.t('homeScreen.dashboard.proxiwashSubtitle2')
442
+                        }
443
+                    </Text>
444
+                </Text>;
446 445
         } else
447 446
             proxiwashSubtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA');
448 447
         let proxiwashClickAction = () => this.props.navigation.navigate('Proxiwash');
@@ -497,10 +496,8 @@ export default class HomeScreen extends FetchedDataSectionList {
497 496
 
498 497
 
499 498
     getRenderItem(item: Object, section: Object, data: Object) {
500
-        if (section['id'] === SECTIONS_ID[0]) {
501
-            return this.getDashboardItem(item);
502
-        } else {
503
-            return (
499
+        return (
500
+            section['id'] === SECTIONS_ID[0] ? this.getDashboardItem(item) :
504 501
                 <Card style={{
505 502
                     flex: 0,
506 503
                     marginLeft: 10,
@@ -555,8 +552,6 @@ export default class HomeScreen extends FetchedDataSectionList {
555 552
                         </Left>
556 553
                     </CardItem>
557 554
                 </Card>
558
-            );
559
-        }
555
+        );
560 556
     }
561
-
562 557
 }

+ 11
- 13
screens/PlanningScreen.js View File

@@ -1,10 +1,9 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import {BackHandler} from 'react-native';
5
-import {Content, H1, H3, Text, Button} from 'native-base';
4
+import {BackHandler, Image, View} from 'react-native';
5
+import {Button, Content, H1, H3, Text} from 'native-base';
6 6
 import i18n from "i18n-js";
7
-import {View, Image} from "react-native";
8 7
 import ThemeManager from "../utils/ThemeManager";
9 8
 import {Linking} from "expo";
10 9
 import BaseContainer from "../components/BaseContainer";
@@ -61,6 +60,12 @@ export default class PlanningScreen extends React.Component<Props, State> {
61 60
 
62 61
     didFocusSubscription: Function;
63 62
     willBlurSubscription: Function;
63
+    state = {
64
+        modalCurrentDisplayItem: {},
65
+        refreshing: false,
66
+        agendaItems: {},
67
+        calendarShowing: false,
68
+    };
64 69
 
65 70
     constructor(props: any) {
66 71
         super(props);
@@ -68,7 +73,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
68 73
         this.webDataManager = new WebDataManager(FETCH_URL);
69 74
         this.didFocusSubscription = props.navigation.addListener(
70 75
             'didFocus',
71
-            payload =>
76
+            () =>
72 77
                 BackHandler.addEventListener(
73 78
                     'hardwareBackPress',
74 79
                     this.onBackButtonPressAndroid
@@ -83,7 +88,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
83 88
         this._onRefresh();
84 89
         this.willBlurSubscription = this.props.navigation.addListener(
85 90
             'willBlur',
86
-            payload =>
91
+            () =>
87 92
                 BackHandler.removeEventListener(
88 93
                     'hardwareBackPress',
89 94
                     this.onBackButtonPressAndroid
@@ -105,13 +110,6 @@ export default class PlanningScreen extends React.Component<Props, State> {
105 110
         this.willBlurSubscription && this.willBlurSubscription.remove();
106 111
     }
107 112
 
108
-    state = {
109
-        modalCurrentDisplayItem: {},
110
-        refreshing: false,
111
-        agendaItems: {},
112
-        calendarShowing: false,
113
-    };
114
-
115 113
     getCurrentDate() {
116 114
         let today = new Date();
117 115
         return this.getFormattedDate(today);
@@ -351,7 +349,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
351 349
 
352 350
     getFormattedTime(event: Object) {
353 351
         if (this.getEventEndTime(event) !== "")
354
-            return this.getEventStartTime(event) + " - " + this.getEventEndTime(event)
352
+            return this.getEventStartTime(event) + " - " + this.getEventEndTime(event);
355 353
         else
356 354
             return this.getEventStartTime(event);
357 355
     }

+ 1
- 9
screens/Proximo/ProximoAboutScreen.js View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {Image, Linking, View} from 'react-native';
5
-import {Body, Card, CardItem, Container, Content, H2, Left, Text} from 'native-base';
5
+import {Card, CardItem, Container, Content, H2, Left, Text} from 'native-base';
6 6
 import CustomHeader from "../../components/CustomHeader";
7 7
 import i18n from "i18n-js";
8 8
 import CustomMaterialIcon from "../../components/CustomMaterialIcon";
@@ -12,14 +12,6 @@ type Props = {
12 12
 };
13 13
 
14 14
 /**
15
- * Opens a link in the device's browser
16
- * @param link The link to open
17
- */
18
-function openWebLink(link) {
19
-    Linking.openURL(link).catch((err) => console.error('Error opening link', err));
20
-}
21
-
22
-/**
23 15
  * Class defining an about screen. This screen shows the user information about the app and it's author.
24 16
  */
25 17
 export default class ProximoAboutScreen extends React.Component<Props> {

+ 8
- 14
screens/Proximo/ProximoListScreen.js View File

@@ -1,9 +1,9 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import {Body, Container, Content, Left, ListItem, Right, Text, Thumbnail, H1, H3} from 'native-base';
4
+import {Body, Container, Content, H1, H3, Left, ListItem, Right, Text, Thumbnail} from 'native-base';
5 5
 import CustomHeader from "../../components/CustomHeader";
6
-import {FlatList, Platform, View, Image} from "react-native";
6
+import {FlatList, Image, Platform, View} from "react-native";
7 7
 import Touchable from 'react-native-platform-touchable';
8 8
 import Menu, {MenuItem} from 'react-native-material-menu';
9 9
 import i18n from "i18n-js";
@@ -62,13 +62,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
62 62
     originalData: Array<Object>;
63 63
     navData = this.props.navigation.getParam('data', []);
64 64
     shouldFocusSearchBar = this.props.navigation.getParam('shouldFocusSearchBar', false);
65
-
66
-    constructor(props: any) {
67
-        super(props);
68
-        this.modalRef = React.createRef();
69
-        this.originalData = this.navData['data'];
70
-    }
71
-
72 65
     state = {
73 66
         currentlyDisplayedData: this.navData['data'].sort(sortPrice),
74 67
         currentSortMode: sortMode.price,
@@ -77,9 +70,14 @@ export default class ProximoListScreen extends React.Component<Props, State> {
77 70
         sortNameIcon: '',
78 71
         modalCurrentDisplayItem: {},
79 72
     };
80
-
81 73
     _menu: Menu;
82 74
 
75
+    constructor(props: any) {
76
+        super(props);
77
+        this.modalRef = React.createRef();
78
+        this.originalData = this.navData['data'];
79
+    }
80
+
83 81
     /**
84 82
      * Saves the reference to the sort menu for later use
85 83
      *
@@ -132,9 +130,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
132 130
                 }
133 131
                 break;
134 132
         }
135
-        this.setState({
136
-            navData: data,
137
-        });
138 133
         this.setupSortIcons(mode, isReverse);
139 134
         this._menu.hide();
140 135
     }
@@ -297,7 +292,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
297 292
 
298 293
     render() {
299 294
         const nav = this.props.navigation;
300
-        const navType = nav.getParam('type', '{name: "Error"}');
301 295
         return (
302 296
             <Container>
303 297
                 <Modalize ref={this.modalRef}

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

@@ -2,7 +2,7 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {Platform, View} from 'react-native'
5
-import {Badge, Body, Left, ListItem, Right, Text} from 'native-base';
5
+import {Body, Left, ListItem, Right, Text} from 'native-base';
6 6
 import i18n from "i18n-js";
7 7
 import CustomMaterialIcon from "../../components/CustomMaterialIcon";
8 8
 import FetchedDataSectionList from "../../components/FetchedDataSectionList";
@@ -22,6 +22,10 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
22 22
         super(DATA_URL, 0);
23 23
     }
24 24
 
25
+    static sortFinalData(a: Object, b: Object) {
26
+        return a.type.id - b.type.id;
27
+    }
28
+
25 29
     getHeaderTranslation() {
26 30
         return i18n.t("screens.proximo");
27 31
     }
@@ -96,10 +100,6 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
96 100
         return availableArticles;
97 101
     }
98 102
 
99
-    static sortFinalData(a: Object, b: Object) {
100
-        return a.type.id - b.type.id;
101
-    }
102
-
103 103
     getRightButton() {
104 104
         let searchScreenData = {
105 105
             shouldFocusSearchBar: true,

+ 1
- 9
screens/Proxiwash/ProxiwashAboutScreen.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import {Image, Linking, View} from 'react-native';
4
+import {Image, View} from 'react-native';
5 5
 import {Body, Card, CardItem, Container, Content, H2, H3, Left, Tab, TabHeading, Tabs, Text} from 'native-base';
6 6
 import CustomHeader from "../../components/CustomHeader";
7 7
 import i18n from "i18n-js";
@@ -13,14 +13,6 @@ type Props = {
13 13
 };
14 14
 
15 15
 /**
16
- * Opens a link in the device's browser
17
- * @param link The link to open
18
- */
19
-function openWebLink(link) {
20
-    Linking.openURL(link).catch((err) => console.error('Error opening link', err));
21
-}
22
-
23
-/**
24 16
  * Class defining an about screen. This screen shows the user information about the app and it's author.
25 17
  */
26 18
 export default class ProxiwashAboutScreen extends React.Component<Props> {

+ 1
- 1
screens/Proxiwash/ProxiwashScreen.js View File

@@ -89,7 +89,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
89 89
                 this.setState({machinesWatched: fetchedList})
90 90
             });
91 91
             // Get updated watchlist after received notification
92
-            Expo.Notifications.addListener((notification) => {
92
+            Expo.Notifications.addListener(() => {
93 93
                 NotificationsManager.getMachineNotificationWatchlist((fetchedList) => {
94 94
                     this.setState({machinesWatched: fetchedList})
95 95
                 });

+ 3
- 4
screens/SelfMenuScreen.js View File

@@ -2,11 +2,10 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import {View} from 'react-native';
5
-import {Text, H2, H3, Card, CardItem} from 'native-base';
5
+import {Card, CardItem, H2, H3, Text} from 'native-base';
6 6
 import ThemeManager from "../utils/ThemeManager";
7 7
 import i18n from "i18n-js";
8 8
 import FetchedDataSectionList from "../components/FetchedDataSectionList";
9
-import LocaleManager from "../utils/LocaleManager";
10 9
 
11 10
 const DATA_URL = "https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/menu/menu_data.json";
12 11
 
@@ -64,7 +63,7 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
64 63
         return true;
65 64
     }
66 65
 
67
-    hasSideMenu() : boolean {
66
+    hasSideMenu(): boolean {
68 67
         return false;
69 68
     }
70 69
 
@@ -150,7 +149,7 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
150 149
                     flexDirection: 'column',
151 150
                     paddingTop: 0,
152 151
                 }}>
153
-                    {item.dishes.map((object, i) =>
152
+                    {item.dishes.map((object) =>
154 153
                         <View>
155 154
                             {object.name !== "" ?
156 155
                                 <Text style={{

+ 33
- 35
screens/SettingsScreen.js View File

@@ -21,8 +21,6 @@ import i18n from "i18n-js";
21 21
 import {NavigationActions, StackActions} from "react-navigation";
22 22
 import CustomMaterialIcon from "../components/CustomMaterialIcon";
23 23
 import AsyncStorageManager from "../utils/AsyncStorageManager";
24
-import Touchable from "react-native-platform-touchable";
25
-import {Platform} from "react-native";
26 24
 import NotificationsManager from "../utils/NotificationsManager";
27 25
 
28 26
 type Props = {
@@ -46,6 +44,39 @@ export default class SettingsScreen extends React.Component<Props, State> {
46 44
     };
47 45
 
48 46
     /**
47
+     * Get a list item using the specified control
48
+     *
49
+     * @param control The custom control to use
50
+     * @param icon The icon name to display on the list item
51
+     * @param title The text to display as this list item title
52
+     * @param subtitle The text to display as this list item subtitle
53
+     * @returns {React.Node}
54
+     */
55
+    static getGeneralItem(control: React.Node, icon: string, title: string, subtitle: string) {
56
+        return (
57
+            <ListItem
58
+                thumbnail
59
+            >
60
+                <Left>
61
+                    <CustomMaterialIcon icon={icon}/>
62
+                </Left>
63
+                <Body>
64
+                    <Text>
65
+                        {title}
66
+                    </Text>
67
+                    <Text note>
68
+                        {subtitle}
69
+                    </Text>
70
+                </Body>
71
+
72
+                <Right>
73
+                    {control}
74
+                </Right>
75
+            </ListItem>
76
+        );
77
+    }
78
+
79
+    /**
49 80
      * Save the value for the proxiwash reminder notification time
50 81
      *
51 82
      * @param value The value to store
@@ -179,39 +210,6 @@ export default class SettingsScreen extends React.Component<Props, State> {
179 210
         );
180 211
     }
181 212
 
182
-    /**
183
-     * Get a list item using the specified control
184
-     *
185
-     * @param control The custom control to use
186
-     * @param icon The icon name to display on the list item
187
-     * @param title The text to display as this list item title
188
-     * @param subtitle The text to display as this list item subtitle
189
-     * @returns {React.Node}
190
-     */
191
-    static getGeneralItem(control: React.Node, icon: string, title: string, subtitle: string) {
192
-        return (
193
-            <ListItem
194
-                thumbnail
195
-            >
196
-                <Left>
197
-                    <CustomMaterialIcon icon={icon}/>
198
-                </Left>
199
-                <Body>
200
-                    <Text>
201
-                        {title}
202
-                    </Text>
203
-                    <Text note>
204
-                        {subtitle}
205
-                    </Text>
206
-                </Body>
207
-
208
-                <Right>
209
-                    {control}
210
-                </Right>
211
-            </ListItem>
212
-        );
213
-    }
214
-
215 213
     render() {
216 214
         const nav = this.props.navigation;
217 215
         return (

+ 0
- 1
screens/Websites/AmicaleScreen.js View File

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import ThemeManager from "../../utils/ThemeManager";
5 4
 import WebViewScreen from "../../components/WebViewScreen";
6 5
 
7 6
 type Props = {

+ 0
- 1
screens/Websites/BlueMindScreen.js View File

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import ThemeManager from "../../utils/ThemeManager";
5 4
 import WebViewScreen from "../../components/WebViewScreen";
6 5
 import i18n from "i18n-js";
7 6
 

+ 0
- 1
screens/Websites/ElusEtudScreen.js View File

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import ThemeManager from "../../utils/ThemeManager";
5 4
 import WebViewScreen from "../../components/WebViewScreen";
6 5
 
7 6
 type Props = {

+ 1
- 2
screens/Websites/EntScreen.js View File

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import ThemeManager from "../../utils/ThemeManager";
5 4
 import WebViewScreen from "../../components/WebViewScreen";
6 5
 import i18n from "i18n-js";
7 6
 
@@ -50,7 +49,7 @@ export default class EntScreen extends React.Component<Props> {
50 49
             'let stylesheet = document.createElement(\'link\');\n' +
51 50
             'stylesheet.type = \'text/css\';\n' +
52 51
             'stylesheet.rel = \'stylesheet\';\n' +
53
-            'stylesheet.href = \'' + CUSTOM_CSS_GENERAL +'\';\n' +
52
+            'stylesheet.href = \'' + CUSTOM_CSS_GENERAL + '\';\n' +
54 53
             'let mobileSpec = document.createElement(\'meta\');\n' +
55 54
             'mobileSpec.name = \'viewport\';\n' +
56 55
             'mobileSpec.content = \'width=device-width, initial-scale=1.0\';\n' +

+ 0
- 1
screens/Websites/PlanexScreen.js View File

@@ -3,7 +3,6 @@
3 3
 import * as React from 'react';
4 4
 import ThemeManager from "../../utils/ThemeManager";
5 5
 import WebViewScreen from "../../components/WebViewScreen";
6
-import i18n from "i18n-js";
7 6
 
8 7
 type Props = {
9 8
     navigation: Object,

+ 0
- 1
screens/Websites/TutorInsaScreen.js View File

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import ThemeManager from "../../utils/ThemeManager";
5 4
 import WebViewScreen from "../../components/WebViewScreen";
6 5
 
7 6
 type Props = {

+ 0
- 1
screens/Websites/WiketudScreen.js View File

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import ThemeManager from "../../utils/ThemeManager";
5 4
 import WebViewScreen from "../../components/WebViewScreen";
6 5
 
7 6
 type Props = {

Loading…
Cancel
Save