|
@@ -15,6 +15,9 @@ import {
|
15
|
15
|
import {Avatar, Divider, List} from 'react-native-paper';
|
16
|
16
|
import CustomAgenda from "../../components/Overrides/CustomAgenda";
|
17
|
17
|
import {StackNavigationProp} from "@react-navigation/stack";
|
|
18
|
+import {MASCOT_STYLE} from "../../components/Mascot/Mascot";
|
|
19
|
+import MascotPopup from "../../components/Mascot/MascotPopup";
|
|
20
|
+import AsyncStorageManager from "../../managers/AsyncStorageManager";
|
18
|
21
|
|
19
|
22
|
LocaleConfig.locales['fr'] = {
|
20
|
23
|
monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
|
|
@@ -33,6 +36,7 @@ type State = {
|
33
|
36
|
refreshing: boolean,
|
34
|
37
|
agendaItems: Object,
|
35
|
38
|
calendarShowing: boolean,
|
|
39
|
+ mascotDialogVisible: boolean,
|
36
|
40
|
};
|
37
|
41
|
|
38
|
42
|
const FETCH_URL = "https://www.amicale-insat.fr/api/event/list";
|
|
@@ -52,6 +56,7 @@ class PlanningScreen extends React.Component<Props, State> {
|
52
|
56
|
refreshing: false,
|
53
|
57
|
agendaItems: {},
|
54
|
58
|
calendarShowing: false,
|
|
59
|
+ mascotDialogVisible: AsyncStorageManager.getInstance().preferences.eventsShowBanner.current === "1"
|
55
|
60
|
};
|
56
|
61
|
|
57
|
62
|
currentDate = getDateOnlyString(getCurrentDateString());
|
|
@@ -101,6 +106,18 @@ class PlanningScreen extends React.Component<Props, State> {
|
101
|
106
|
};
|
102
|
107
|
|
103
|
108
|
/**
|
|
109
|
+ * Callback used when closing the banner.
|
|
110
|
+ * This hides the banner and saves to preferences to prevent it from reopening
|
|
111
|
+ */
|
|
112
|
+ onHideMascotDialog = () => {
|
|
113
|
+ this.setState({mascotDialogVisible: false});
|
|
114
|
+ AsyncStorageManager.getInstance().savePref(
|
|
115
|
+ AsyncStorageManager.getInstance().preferences.eventsShowBanner.key,
|
|
116
|
+ '0'
|
|
117
|
+ );
|
|
118
|
+ };
|
|
119
|
+
|
|
120
|
+ /**
|
104
|
121
|
* Function used to check if a row has changed
|
105
|
122
|
*
|
106
|
123
|
* @param r1
|
|
@@ -206,34 +223,51 @@ class PlanningScreen extends React.Component<Props, State> {
|
206
|
223
|
|
207
|
224
|
render() {
|
208
|
225
|
return (
|
209
|
|
- <CustomAgenda
|
210
|
|
- {...this.props}
|
211
|
|
- // the list of items that have to be displayed in agenda. If you want to render item as empty date
|
212
|
|
- // the value of date key kas to be an empty array []. If there exists no value for date key it is
|
213
|
|
- // considered that the date in question is not yet loaded
|
214
|
|
- items={this.state.agendaItems}
|
215
|
|
- // initially selected day
|
216
|
|
- selected={this.currentDate}
|
217
|
|
- // Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined
|
218
|
|
- minDate={this.currentDate}
|
219
|
|
- // Max amount of months allowed to scroll to the past. Default = 50
|
220
|
|
- pastScrollRange={1}
|
221
|
|
- // Max amount of months allowed to scroll to the future. Default = 50
|
222
|
|
- futureScrollRange={AGENDA_MONTH_SPAN}
|
223
|
|
- // If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly.
|
224
|
|
- onRefresh={this.onRefresh}
|
225
|
|
- // callback that fires when the calendar is opened or closed
|
226
|
|
- onCalendarToggled={this.onCalendarToggled}
|
227
|
|
- // Set this true while waiting for new data from a refresh
|
228
|
|
- refreshing={this.state.refreshing}
|
229
|
|
- renderItem={this.getRenderItem}
|
230
|
|
- renderEmptyDate={this.getRenderEmptyDate}
|
231
|
|
- rowHasChanged={this.rowHasChanged}
|
232
|
|
- // If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
|
233
|
|
- firstDay={1}
|
234
|
|
- // ref to this agenda in order to handle back button event
|
235
|
|
- onRef={this.onAgendaRef}
|
236
|
|
- />
|
|
226
|
+ <View style={{flex: 1}}>
|
|
227
|
+ <CustomAgenda
|
|
228
|
+ {...this.props}
|
|
229
|
+ // the list of items that have to be displayed in agenda. If you want to render item as empty date
|
|
230
|
+ // the value of date key kas to be an empty array []. If there exists no value for date key it is
|
|
231
|
+ // considered that the date in question is not yet loaded
|
|
232
|
+ items={this.state.agendaItems}
|
|
233
|
+ // initially selected day
|
|
234
|
+ selected={this.currentDate}
|
|
235
|
+ // Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined
|
|
236
|
+ minDate={this.currentDate}
|
|
237
|
+ // Max amount of months allowed to scroll to the past. Default = 50
|
|
238
|
+ pastScrollRange={1}
|
|
239
|
+ // Max amount of months allowed to scroll to the future. Default = 50
|
|
240
|
+ futureScrollRange={AGENDA_MONTH_SPAN}
|
|
241
|
+ // If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly.
|
|
242
|
+ onRefresh={this.onRefresh}
|
|
243
|
+ // callback that fires when the calendar is opened or closed
|
|
244
|
+ onCalendarToggled={this.onCalendarToggled}
|
|
245
|
+ // Set this true while waiting for new data from a refresh
|
|
246
|
+ refreshing={this.state.refreshing}
|
|
247
|
+ renderItem={this.getRenderItem}
|
|
248
|
+ renderEmptyDate={this.getRenderEmptyDate}
|
|
249
|
+ rowHasChanged={this.rowHasChanged}
|
|
250
|
+ // If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
|
|
251
|
+ firstDay={1}
|
|
252
|
+ // ref to this agenda in order to handle back button event
|
|
253
|
+ onRef={this.onAgendaRef}
|
|
254
|
+ />
|
|
255
|
+ <MascotPopup
|
|
256
|
+ visible={this.state.mascotDialogVisible}
|
|
257
|
+ title={i18n.t("planningScreen.mascotTitle")}
|
|
258
|
+ message={i18n.t("planningScreen.mascotMessage")}
|
|
259
|
+ icon={"calendar-range"}
|
|
260
|
+ buttons={{
|
|
261
|
+ action: null,
|
|
262
|
+ cancel: {
|
|
263
|
+ message: i18n.t("planningScreen.mascotButton"),
|
|
264
|
+ icon: "check",
|
|
265
|
+ onPress: this.onHideMascotDialog,
|
|
266
|
+ }
|
|
267
|
+ }}
|
|
268
|
+ emotion={MASCOT_STYLE.HAPPY}
|
|
269
|
+ />
|
|
270
|
+ </View>
|
237
|
271
|
);
|
238
|
272
|
}
|
239
|
273
|
}
|