Browse Source

Fixed flow errors

keplyx 4 years ago
parent
commit
83dc2dce34
1 changed files with 20 additions and 17 deletions
  1. 20
    17
      screens/PlanningScreen.js

+ 20
- 17
screens/PlanningScreen.js View File

@@ -1,15 +1,14 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
-import { BackHandler } from 'react-native';
5
-import {Content, H1, H2, H3, Text, Button} from 'native-base';
4
+import {BackHandler} from 'react-native';
5
+import {Content, H1, H3, Text, Button} from 'native-base';
6 6
 import i18n from "i18n-js";
7 7
 import {View, Image} from "react-native";
8 8
 import ThemeManager from "../utils/ThemeManager";
9 9
 import {Linking} from "expo";
10 10
 import BaseContainer from "../components/BaseContainer";
11
-import {Agenda} from 'react-native-calendars';
12
-import {LocaleConfig} from 'react-native-calendars';
11
+import {Agenda, LocaleConfig} from 'react-native-calendars';
13 12
 import HTML from 'react-native-render-html';
14 13
 import Touchable from 'react-native-platform-touchable';
15 14
 import Modalize from 'react-native-modalize';
@@ -17,10 +16,10 @@ import WebDataManager from "../utils/WebDataManager";
17 16
 import CustomMaterialIcon from "../components/CustomMaterialIcon";
18 17
 
19 18
 LocaleConfig.locales['fr'] = {
20
-    monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
21
-    monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin','Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
22
-    dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
23
-    dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
19
+    monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
20
+    monthNamesShort: ['Janv.', 'Févr.', 'Mars', 'Avril', 'Mai', 'Juin', 'Juil.', 'Août', 'Sept.', 'Oct.', 'Nov.', 'Déc.'],
21
+    dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
22
+    dayNamesShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
24 23
     today: 'Aujourd\'hui'
25 24
 };
26 25
 
@@ -53,19 +52,21 @@ function openWebLink(link) {
53 52
  */
54 53
 export default class PlanningScreen extends React.Component<Props, State> {
55 54
 
56
-    modalRef: { current: null | Modalize };
55
+    modalRef: Modalize;
56
+    agendaRef: Agenda;
57 57
     webDataManager: WebDataManager;
58 58
 
59 59
     lastRefresh: Date;
60 60
     minTimeBetweenRefresh = 60;
61 61
 
62
-    _agenda: Agenda;
62
+    didFocusSubscription: Function;
63
+    willBlurSubscription: Function;
63 64
 
64 65
     constructor(props: any) {
65 66
         super(props);
66 67
         this.modalRef = React.createRef();
67 68
         this.webDataManager = new WebDataManager(FETCH_URL);
68
-        this._didFocusSubscription = props.navigation.addListener(
69
+        this.didFocusSubscription = props.navigation.addListener(
69 70
             'didFocus',
70 71
             payload =>
71 72
                 BackHandler.addEventListener(
@@ -80,7 +81,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
80 81
 
81 82
     componentDidMount() {
82 83
         this._onRefresh();
83
-        this._willBlurSubscription = this.props.navigation.addListener(
84
+        this.willBlurSubscription = this.props.navigation.addListener(
84 85
             'willBlur',
85 86
             payload =>
86 87
                 BackHandler.removeEventListener(
@@ -92,7 +93,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
92 93
 
93 94
     onBackButtonPressAndroid = () => {
94 95
         if (this.state.calendarShowing) {
95
-            this._agenda.chooseDay(this._agenda.state.selectedDay);
96
+            this.agendaRef.chooseDay(this.agendaRef.state.selectedDay);
96 97
             return true;
97 98
         } else {
98 99
             return false;
@@ -100,8 +101,8 @@ export default class PlanningScreen extends React.Component<Props, State> {
100 101
     };
101 102
 
102 103
     componentWillUnmount() {
103
-        this._didFocusSubscription && this._didFocusSubscription.remove();
104
-        this._willBlurSubscription && this._willBlurSubscription.remove();
104
+        this.didFocusSubscription && this.didFocusSubscription.remove();
105
+        this.willBlurSubscription && this.willBlurSubscription.remove();
105 106
     }
106 107
 
107 108
     state = {
@@ -395,7 +396,9 @@ export default class PlanningScreen extends React.Component<Props, State> {
395 396
                     // If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly.
396 397
                     onRefresh={() => this._onRefresh()}
397 398
                     // callback that fires when the calendar is opened or closed
398
-                    onCalendarToggled={(calendarOpened) => {this.setState({calendarShowing: calendarOpened})}}
399
+                    onCalendarToggled={(calendarOpened) => {
400
+                        this.setState({calendarShowing: calendarOpened})
401
+                    }}
399 402
                     // Set this true while waiting for new data from a refresh
400 403
                     refreshing={this.state.refreshing}
401 404
                     renderItem={(item) => this.getRenderItem(item)}
@@ -404,7 +407,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
404 407
                     // If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
405 408
                     firstDay={1}
406 409
                     // ref to this agenda in order to handle back button event
407
-                    ref={(ref) => this._agenda = ref}
410
+                    ref={(ref) => this.agendaRef = ref}
408 411
                     // agenda theme
409 412
                     theme={{
410 413
                         backgroundColor: ThemeManager.getCurrentThemeVariables().agendaBackgroundColor,

Loading…
Cancel
Save