|
@@ -0,0 +1,569 @@
|
|
1
|
+// @flow
|
|
2
|
+
|
|
3
|
+import * as React from 'react';
|
|
4
|
+import {Button, Caption, Card, Headline, Subheading, Text, withTheme} from 'react-native-paper';
|
|
5
|
+import {Collapsible} from "react-navigation-collapsible";
|
|
6
|
+import {withCollapsible} from "../../../utils/withCollapsible";
|
|
7
|
+import {StackNavigationProp} from "@react-navigation/stack";
|
|
8
|
+import type {CustomTheme} from "../../../managers/ThemeManager";
|
|
9
|
+import type {Device} from "./EquipmentListScreen";
|
|
10
|
+import {Animated, BackHandler} from "react-native";
|
|
11
|
+import * as Animatable from "react-native-animatable";
|
|
12
|
+import {View} from "react-native-animatable";
|
|
13
|
+import i18n from "i18n-js";
|
|
14
|
+import {dateToString, getTimeOnlyString, stringToDate} from "../../../utils/Planning";
|
|
15
|
+import {CalendarList} from "react-native-calendars";
|
|
16
|
+import DateTimePicker from '@react-native-community/datetimepicker';
|
|
17
|
+import LoadingConfirmDialog from "../../../components/Dialogs/LoadingConfirmDialog";
|
|
18
|
+import ConnectionManager from "../../../managers/ConnectionManager";
|
|
19
|
+import ErrorDialog from "../../../components/Dialogs/ErrorDialog";
|
|
20
|
+
|
|
21
|
+type Props = {
|
|
22
|
+ navigation: StackNavigationProp,
|
|
23
|
+ route: {
|
|
24
|
+ params?: {
|
|
25
|
+ item?: Device,
|
|
26
|
+ },
|
|
27
|
+ },
|
|
28
|
+ theme: CustomTheme,
|
|
29
|
+ collapsibleStack: Collapsible,
|
|
30
|
+}
|
|
31
|
+
|
|
32
|
+type State = {
|
|
33
|
+ dialogVisible: boolean,
|
|
34
|
+ errorDialogVisible: boolean,
|
|
35
|
+ markedDates: { [key: string]: { startingDay: boolean, endingDay: boolean, color: string } },
|
|
36
|
+ timePickerVisible: boolean,
|
|
37
|
+ currentError: number,
|
|
38
|
+}
|
|
39
|
+
|
|
40
|
+class EquipmentRentScreen extends React.Component<Props, State> {
|
|
41
|
+
|
|
42
|
+ state = {
|
|
43
|
+ dialogVisible: false,
|
|
44
|
+ errorDialogVisible: false,
|
|
45
|
+ markedDates: {},
|
|
46
|
+ timePickerVisible: false,
|
|
47
|
+ currentError: 0,
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ item: Device | null;
|
|
51
|
+ selectedDates: {
|
|
52
|
+ start: Date | null,
|
|
53
|
+ end: Date | null,
|
|
54
|
+ };
|
|
55
|
+
|
|
56
|
+ currentlySelectedDate: Date | null;
|
|
57
|
+
|
|
58
|
+ bookRef: { current: null | Animatable.View }
|
|
59
|
+ canBookEquipment: boolean;
|
|
60
|
+
|
|
61
|
+ constructor(props: Props) {
|
|
62
|
+ super(props);
|
|
63
|
+ this.resetSelection();
|
|
64
|
+ this.bookRef = React.createRef();
|
|
65
|
+ this.canBookEquipment = false;
|
|
66
|
+ if (this.props.route.params != null) {
|
|
67
|
+ if (this.props.route.params.item != null)
|
|
68
|
+ this.item = this.props.route.params.item;
|
|
69
|
+ else
|
|
70
|
+ this.item = null;
|
|
71
|
+ }
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ /**
|
|
75
|
+ * Captures focus and blur events to hook on android back button
|
|
76
|
+ */
|
|
77
|
+ componentDidMount() {
|
|
78
|
+ this.props.navigation.addListener(
|
|
79
|
+ 'focus',
|
|
80
|
+ () =>
|
|
81
|
+ BackHandler.addEventListener(
|
|
82
|
+ 'hardwareBackPress',
|
|
83
|
+ this.onBackButtonPressAndroid
|
|
84
|
+ )
|
|
85
|
+ );
|
|
86
|
+ this.props.navigation.addListener(
|
|
87
|
+ 'blur',
|
|
88
|
+ () =>
|
|
89
|
+ BackHandler.removeEventListener(
|
|
90
|
+ 'hardwareBackPress',
|
|
91
|
+ this.onBackButtonPressAndroid
|
|
92
|
+ )
|
|
93
|
+ );
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ /**
|
|
97
|
+ * Overrides default android back button behaviour to deselect date if any is selected.
|
|
98
|
+ *
|
|
99
|
+ * @return {boolean}
|
|
100
|
+ */
|
|
101
|
+ onBackButtonPressAndroid = () => {
|
|
102
|
+ if (this.currentlySelectedDate != null) {
|
|
103
|
+ this.resetSelection();
|
|
104
|
+ this.setState({
|
|
105
|
+ markedDates: this.generateMarkedDates(),
|
|
106
|
+ });
|
|
107
|
+ return true;
|
|
108
|
+ } else
|
|
109
|
+ return false;
|
|
110
|
+ };
|
|
111
|
+
|
|
112
|
+ isAvailable(item: Device) {
|
|
113
|
+ const availableDate = stringToDate(item.available_at);
|
|
114
|
+ return availableDate != null && availableDate < new Date();
|
|
115
|
+ }
|
|
116
|
+
|
|
117
|
+ /**
|
|
118
|
+ * Gets the string representation of the given date.
|
|
119
|
+ *
|
|
120
|
+ * If the given date is the same day as today, only return the tile.
|
|
121
|
+ * Otherwise, return the full date.
|
|
122
|
+ *
|
|
123
|
+ * @param dateString The string representation of the wanted date
|
|
124
|
+ * @returns {string}
|
|
125
|
+ */
|
|
126
|
+ getDateString(dateString: string): string {
|
|
127
|
+ const today = new Date();
|
|
128
|
+ const date = stringToDate(dateString);
|
|
129
|
+ if (date != null && today.getDate() === date.getDate()) {
|
|
130
|
+ const str = getTimeOnlyString(dateString);
|
|
131
|
+ return str != null ? str : "";
|
|
132
|
+ } else
|
|
133
|
+ return dateString;
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ /**
|
|
137
|
+ * Gets the minimum date for renting equipment
|
|
138
|
+ *
|
|
139
|
+ * @param item The item to rent
|
|
140
|
+ * @param isAvailable True is it is available right now
|
|
141
|
+ * @returns {Date}
|
|
142
|
+ */
|
|
143
|
+ getMinDate(item: Device, isAvailable: boolean) {
|
|
144
|
+ let date = new Date();
|
|
145
|
+ if (isAvailable)
|
|
146
|
+ return date;
|
|
147
|
+ else {
|
|
148
|
+ const limit = stringToDate(item.available_at)
|
|
149
|
+ return limit != null ? limit : date;
|
|
150
|
+ }
|
|
151
|
+ }
|
|
152
|
+
|
|
153
|
+ /**
|
|
154
|
+ * Selects a new date on the calendar.
|
|
155
|
+ * If both start and end dates are already selected, unselect all.
|
|
156
|
+ *
|
|
157
|
+ * @param day The day selected
|
|
158
|
+ */
|
|
159
|
+ selectNewDate = (day: { dateString: string, day: number, month: number, timestamp: number, year: number }) => {
|
|
160
|
+ this.currentlySelectedDate = new Date(day.dateString);
|
|
161
|
+
|
|
162
|
+ if (!this.canBookEquipment) {
|
|
163
|
+ const start = this.selectedDates.start;
|
|
164
|
+ if (start == null)
|
|
165
|
+ this.selectedDates.start = this.currentlySelectedDate;
|
|
166
|
+ else if (this.currentlySelectedDate < start) {
|
|
167
|
+ this.selectedDates.end = start;
|
|
168
|
+ this.selectedDates.start = this.currentlySelectedDate;
|
|
169
|
+ } else
|
|
170
|
+ this.selectedDates.end = this.currentlySelectedDate;
|
|
171
|
+ } else
|
|
172
|
+ this.resetSelection();
|
|
173
|
+
|
|
174
|
+ if (this.selectedDates.start != null) {
|
|
175
|
+ this.setState({
|
|
176
|
+ markedDates: this.generateMarkedDates(),
|
|
177
|
+ timePickerVisible: true,
|
|
178
|
+ });
|
|
179
|
+ } else {
|
|
180
|
+ this.setState({
|
|
181
|
+ markedDates: this.generateMarkedDates(),
|
|
182
|
+ });
|
|
183
|
+ }
|
|
184
|
+ }
|
|
185
|
+
|
|
186
|
+ resetSelection() {
|
|
187
|
+ if (this.canBookEquipment)
|
|
188
|
+ this.hideBookButton();
|
|
189
|
+ this.canBookEquipment = false;
|
|
190
|
+ this.selectedDates = {start: null, end: null};
|
|
191
|
+ this.currentlySelectedDate = null;
|
|
192
|
+ }
|
|
193
|
+
|
|
194
|
+ /**
|
|
195
|
+ * Deselect the currently selected date
|
|
196
|
+ */
|
|
197
|
+ deselectCurrentDate() {
|
|
198
|
+ let currentlySelectedDate = this.currentlySelectedDate;
|
|
199
|
+ const start = this.selectedDates.start;
|
|
200
|
+ const end = this.selectedDates.end;
|
|
201
|
+ if (currentlySelectedDate != null && start != null) {
|
|
202
|
+ if (currentlySelectedDate === start && end === null)
|
|
203
|
+ this.resetSelection();
|
|
204
|
+ else if (end != null && currentlySelectedDate === end) {
|
|
205
|
+ this.currentlySelectedDate = start;
|
|
206
|
+ this.selectedDates.end = null;
|
|
207
|
+ } else if (currentlySelectedDate === start) {
|
|
208
|
+ this.currentlySelectedDate = end;
|
|
209
|
+ this.selectedDates.start = this.selectedDates.end;
|
|
210
|
+ this.selectedDates.end = null;
|
|
211
|
+ }
|
|
212
|
+ }
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ /**
|
|
216
|
+ * Saves the selected time to the currently selected date.
|
|
217
|
+ * If no the time selection was canceled, cancels the current selecction
|
|
218
|
+ *
|
|
219
|
+ * @param event The click event
|
|
220
|
+ * @param date The date selected
|
|
221
|
+ */
|
|
222
|
+ onTimeChange = (event: { nativeEvent: { timestamp: number }, type: string }, date: Date) => {
|
|
223
|
+ let currentDate = this.currentlySelectedDate;
|
|
224
|
+ const item = this.item;
|
|
225
|
+ if (item != null && event.type === "set" && currentDate != null) {
|
|
226
|
+ currentDate.setHours(date.getHours());
|
|
227
|
+ currentDate.setMinutes(date.getMinutes());
|
|
228
|
+
|
|
229
|
+ const isAvailable = this.isAvailable(item);
|
|
230
|
+ let limit = this.getMinDate(item, isAvailable);
|
|
231
|
+ // Prevent selecting a date before now
|
|
232
|
+ if (this.getISODate(currentDate) === this.getISODate(limit) && currentDate < limit) {
|
|
233
|
+ currentDate.setHours(limit.getHours());
|
|
234
|
+ currentDate.setMinutes(limit.getMinutes());
|
|
235
|
+ }
|
|
236
|
+
|
|
237
|
+ if (this.selectedDates.start != null && this.selectedDates.end != null) {
|
|
238
|
+ if (this.selectedDates.start > this.selectedDates.end) {
|
|
239
|
+ const temp = this.selectedDates.start;
|
|
240
|
+ this.selectedDates.start = this.selectedDates.end;
|
|
241
|
+ this.selectedDates.end = temp;
|
|
242
|
+ }
|
|
243
|
+ this.canBookEquipment = true;
|
|
244
|
+ this.showBookButton();
|
|
245
|
+ }
|
|
246
|
+ } else
|
|
247
|
+ this.deselectCurrentDate();
|
|
248
|
+
|
|
249
|
+ this.setState({
|
|
250
|
+ timePickerVisible: false,
|
|
251
|
+ markedDates: this.generateMarkedDates(),
|
|
252
|
+ });
|
|
253
|
+ }
|
|
254
|
+
|
|
255
|
+ /**
|
|
256
|
+ * Returns the ISO date format (without the time)
|
|
257
|
+ *
|
|
258
|
+ * @param date The date to recover the ISO format from
|
|
259
|
+ * @returns {*}
|
|
260
|
+ */
|
|
261
|
+ getISODate(date: Date) {
|
|
262
|
+ return date.toISOString().split("T")[0];
|
|
263
|
+ }
|
|
264
|
+
|
|
265
|
+ /**
|
|
266
|
+ * Generates the object containing all marked dates between the start and end dates selected
|
|
267
|
+ *
|
|
268
|
+ * @returns {{}}
|
|
269
|
+ */
|
|
270
|
+ generateMarkedDates() {
|
|
271
|
+ let markedDates = {}
|
|
272
|
+ const start = this.selectedDates.start;
|
|
273
|
+ const end = this.selectedDates.end;
|
|
274
|
+ if (start != null) {
|
|
275
|
+ const startISODate = this.getISODate(start);
|
|
276
|
+ if (end != null && this.getISODate(end) !== startISODate) {
|
|
277
|
+ markedDates[startISODate] = {
|
|
278
|
+ startingDay: true,
|
|
279
|
+ endingDay: false,
|
|
280
|
+ color: this.props.theme.colors.primary
|
|
281
|
+ };
|
|
282
|
+ markedDates[this.getISODate(end)] = {
|
|
283
|
+ startingDay: false,
|
|
284
|
+ endingDay: true,
|
|
285
|
+ color: this.props.theme.colors.primary
|
|
286
|
+ };
|
|
287
|
+ let date = new Date(start);
|
|
288
|
+ date.setDate(date.getDate() + 1);
|
|
289
|
+ while (date < end && this.getISODate(date) !== this.getISODate(end)) {
|
|
290
|
+ markedDates[this.getISODate(date)] =
|
|
291
|
+ {startingDay: false, endingDay: false, color: this.props.theme.colors.danger};
|
|
292
|
+ date.setDate(date.getDate() + 1);
|
|
293
|
+ }
|
|
294
|
+ } else {
|
|
295
|
+ markedDates[startISODate] = {
|
|
296
|
+ startingDay: true,
|
|
297
|
+ endingDay: true,
|
|
298
|
+ color: this.props.theme.colors.primary
|
|
299
|
+ };
|
|
300
|
+ }
|
|
301
|
+ }
|
|
302
|
+ return markedDates;
|
|
303
|
+ }
|
|
304
|
+
|
|
305
|
+ /**
|
|
306
|
+ * Shows the book button by plying a fade animation
|
|
307
|
+ */
|
|
308
|
+ showBookButton() {
|
|
309
|
+ if (this.bookRef.current != null) {
|
|
310
|
+ this.bookRef.current.fadeInUp(500);
|
|
311
|
+ }
|
|
312
|
+ }
|
|
313
|
+
|
|
314
|
+ /**
|
|
315
|
+ * Hides the book button by plying a fade animation
|
|
316
|
+ */
|
|
317
|
+ hideBookButton() {
|
|
318
|
+ if (this.bookRef.current != null) {
|
|
319
|
+ this.bookRef.current.fadeOutDown(500);
|
|
320
|
+ }
|
|
321
|
+ }
|
|
322
|
+
|
|
323
|
+ showDialog = () => {
|
|
324
|
+ this.setState({dialogVisible: true});
|
|
325
|
+ }
|
|
326
|
+
|
|
327
|
+ showErrorDialog = (error: number) => {
|
|
328
|
+ this.setState({
|
|
329
|
+ errorDialogVisible: true,
|
|
330
|
+ currentError: error,
|
|
331
|
+ });
|
|
332
|
+ }
|
|
333
|
+
|
|
334
|
+ onDialogDismiss = () => {
|
|
335
|
+ this.setState({dialogVisible: false});
|
|
336
|
+ }
|
|
337
|
+
|
|
338
|
+ onErrorDialogDismiss = () => {
|
|
339
|
+ this.setState({errorDialogVisible: false});
|
|
340
|
+ }
|
|
341
|
+
|
|
342
|
+ /**
|
|
343
|
+ * Sends the selected data to the server and waits for a response.
|
|
344
|
+ * If the request is a success, navigate to the recap screen.
|
|
345
|
+ * If it is an error, display the error to the user.
|
|
346
|
+ *
|
|
347
|
+ * @returns {Promise<R>}
|
|
348
|
+ */
|
|
349
|
+ onDialogAccept = () => {
|
|
350
|
+ return new Promise((resolve) => {
|
|
351
|
+ const item = this.item;
|
|
352
|
+ const start = this.selectedDates.start;
|
|
353
|
+ const end = this.selectedDates.end;
|
|
354
|
+ if (item != null && start != null && end != null) {
|
|
355
|
+ ConnectionManager.getInstance().authenticatedRequest(
|
|
356
|
+ "", // TODO set path
|
|
357
|
+ {
|
|
358
|
+ "id": item.id,
|
|
359
|
+ "start": dateToString(start, false),
|
|
360
|
+ "end": dateToString(end, false),
|
|
361
|
+ })
|
|
362
|
+ .then(() => {
|
|
363
|
+ console.log("Success, replace screen");
|
|
364
|
+ resolve();
|
|
365
|
+ })
|
|
366
|
+ .catch((error: number) => {
|
|
367
|
+ this.onDialogDismiss();
|
|
368
|
+ this.showErrorDialog(error);
|
|
369
|
+ resolve();
|
|
370
|
+ });
|
|
371
|
+ } else
|
|
372
|
+ resolve();
|
|
373
|
+ });
|
|
374
|
+ }
|
|
375
|
+
|
|
376
|
+ render() {
|
|
377
|
+ const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
|
|
378
|
+ let startString = <Caption>{i18n.t('equipmentScreen.notSet')}</Caption>;
|
|
379
|
+ let endString = <Caption>{i18n.t('equipmentScreen.notSet')}</Caption>;
|
|
380
|
+ const start = this.selectedDates.start;
|
|
381
|
+ const end = this.selectedDates.end;
|
|
382
|
+ if (start != null)
|
|
383
|
+ startString = dateToString(start, false);
|
|
384
|
+ if (end != null)
|
|
385
|
+ endString = dateToString(end, false);
|
|
386
|
+
|
|
387
|
+ const item = this.item;
|
|
388
|
+ if (item != null) {
|
|
389
|
+ const isAvailable = this.isAvailable(item);
|
|
390
|
+ return (
|
|
391
|
+ <View style={{flex: 1}}>
|
|
392
|
+ <Animated.ScrollView
|
|
393
|
+ // Animations
|
|
394
|
+ onScroll={onScroll}
|
|
395
|
+ contentContainerStyle={{
|
|
396
|
+ paddingTop: containerPaddingTop,
|
|
397
|
+ minHeight: '100%'
|
|
398
|
+ }}
|
|
399
|
+ scrollIndicatorInsets={{top: scrollIndicatorInsetTop}}>
|
|
400
|
+ <Card style={{margin: 5}}>
|
|
401
|
+ <Card.Content>
|
|
402
|
+ <View style={{flex: 1}}>
|
|
403
|
+ <View style={{
|
|
404
|
+ marginLeft: "auto",
|
|
405
|
+ marginRight: "auto",
|
|
406
|
+ flexDirection: "row",
|
|
407
|
+ flexWrap: "wrap",
|
|
408
|
+ }}>
|
|
409
|
+ <Headline style={{textAlign: "center"}}>
|
|
410
|
+ {item.name}
|
|
411
|
+ </Headline>
|
|
412
|
+ <Caption style={{
|
|
413
|
+ textAlign: "center",
|
|
414
|
+ lineHeight: 35,
|
|
415
|
+ marginLeft: 10,
|
|
416
|
+ }}>
|
|
417
|
+ ({i18n.t('equipmentScreen.bail', {cost: item.caution})})
|
|
418
|
+ </Caption>
|
|
419
|
+ </View>
|
|
420
|
+ </View>
|
|
421
|
+
|
|
422
|
+ <Button
|
|
423
|
+ icon={isAvailable ? "check-circle-outline" : "update"}
|
|
424
|
+ color={isAvailable ? this.props.theme.colors.success : this.props.theme.colors.primary}
|
|
425
|
+ mode="text"
|
|
426
|
+ >
|
|
427
|
+ {
|
|
428
|
+ isAvailable
|
|
429
|
+ ? i18n.t('equipmentScreen.available')
|
|
430
|
+ : i18n.t('equipmentScreen.availableAt', {date: this.getDateString(item.available_at)})
|
|
431
|
+ }
|
|
432
|
+ </Button>
|
|
433
|
+ <Text style={{
|
|
434
|
+ textAlign: "center",
|
|
435
|
+ marginBottom: 10
|
|
436
|
+ }}>
|
|
437
|
+ {i18n.t('equipmentScreen.booking')}
|
|
438
|
+ </Text>
|
|
439
|
+ <Subheading style={{textAlign: "center"}}>
|
|
440
|
+ {i18n.t('equipmentScreen.startDate')}
|
|
441
|
+ {startString}
|
|
442
|
+ </Subheading>
|
|
443
|
+ <Subheading style={{textAlign: "center"}}>
|
|
444
|
+ {i18n.t('equipmentScreen.endDate')}
|
|
445
|
+ {endString}
|
|
446
|
+ </Subheading>
|
|
447
|
+ </Card.Content>
|
|
448
|
+ </Card>
|
|
449
|
+ {this.state.timePickerVisible
|
|
450
|
+ ? <DateTimePicker
|
|
451
|
+ value={new Date()}
|
|
452
|
+ mode={"time"}
|
|
453
|
+ display={"clock"}
|
|
454
|
+ is24Hour={true}
|
|
455
|
+ onChange={this.onTimeChange}
|
|
456
|
+ />
|
|
457
|
+ : null}
|
|
458
|
+ <CalendarList
|
|
459
|
+ // Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined
|
|
460
|
+ minDate={this.getMinDate(item, isAvailable)}
|
|
461
|
+ // Max amount of months allowed to scroll to the past. Default = 50
|
|
462
|
+ pastScrollRange={0}
|
|
463
|
+ // Max amount of months allowed to scroll to the future. Default = 50
|
|
464
|
+ futureScrollRange={3}
|
|
465
|
+ // Enable horizontal scrolling, default = false
|
|
466
|
+ horizontal={true}
|
|
467
|
+ // Enable paging on horizontal, default = false
|
|
468
|
+ pagingEnabled={true}
|
|
469
|
+ // Handler which gets executed on day press. Default = undefined
|
|
470
|
+ onDayPress={this.selectNewDate}
|
|
471
|
+ // If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
|
|
472
|
+ firstDay={1}
|
|
473
|
+ // Disable all touch events for disabled days. can be override with disableTouchEvent in markedDates
|
|
474
|
+ disableAllTouchEventsForDisabledDays={true}
|
|
475
|
+ // Hide month navigation arrows.
|
|
476
|
+ hideArrows={false}
|
|
477
|
+ // Date marking style [simple/period/multi-dot/custom]. Default = 'simple'
|
|
478
|
+ markingType={'period'}
|
|
479
|
+ markedDates={this.state.markedDates}
|
|
480
|
+
|
|
481
|
+ theme={{
|
|
482
|
+ backgroundColor: this.props.theme.colors.agendaBackgroundColor,
|
|
483
|
+ calendarBackground: this.props.theme.colors.background,
|
|
484
|
+ textSectionTitleColor: this.props.theme.colors.agendaDayTextColor,
|
|
485
|
+ selectedDayBackgroundColor: this.props.theme.colors.primary,
|
|
486
|
+ selectedDayTextColor: '#ffffff',
|
|
487
|
+ todayTextColor: this.props.theme.colors.text,
|
|
488
|
+ dayTextColor: this.props.theme.colors.text,
|
|
489
|
+ textDisabledColor: this.props.theme.colors.agendaDayTextColor,
|
|
490
|
+ dotColor: this.props.theme.colors.primary,
|
|
491
|
+ selectedDotColor: '#ffffff',
|
|
492
|
+ arrowColor: this.props.theme.colors.primary,
|
|
493
|
+ monthTextColor: this.props.theme.colors.text,
|
|
494
|
+ indicatorColor: this.props.theme.colors.primary,
|
|
495
|
+ textDayFontFamily: 'monospace',
|
|
496
|
+ textMonthFontFamily: 'monospace',
|
|
497
|
+ textDayHeaderFontFamily: 'monospace',
|
|
498
|
+ textDayFontWeight: '300',
|
|
499
|
+ textMonthFontWeight: 'bold',
|
|
500
|
+ textDayHeaderFontWeight: '300',
|
|
501
|
+ textDayFontSize: 16,
|
|
502
|
+ textMonthFontSize: 16,
|
|
503
|
+ textDayHeaderFontSize: 16,
|
|
504
|
+ 'stylesheet.day.period': {
|
|
505
|
+ base: {
|
|
506
|
+ overflow: 'hidden',
|
|
507
|
+ height: 34,
|
|
508
|
+ width: 34,
|
|
509
|
+ alignItems: 'center',
|
|
510
|
+
|
|
511
|
+ }
|
|
512
|
+ }
|
|
513
|
+ }}
|
|
514
|
+ style={{marginBottom: 50}}
|
|
515
|
+ />
|
|
516
|
+ </Animated.ScrollView>
|
|
517
|
+ <LoadingConfirmDialog
|
|
518
|
+ visible={this.state.dialogVisible}
|
|
519
|
+ onDismiss={this.onDialogDismiss}
|
|
520
|
+ onAccept={this.onDialogAccept}
|
|
521
|
+ title={i18n.t('equipmentScreen.dialogTitle')}
|
|
522
|
+ titleLoading={i18n.t('equipmentScreen.dialogTitleLoading')}
|
|
523
|
+ message={i18n.t('equipmentScreen.dialogMessage')}
|
|
524
|
+ />
|
|
525
|
+
|
|
526
|
+ <ErrorDialog
|
|
527
|
+ visible={this.state.errorDialogVisible}
|
|
528
|
+ onDismiss={this.onErrorDialogDismiss}
|
|
529
|
+ errorCode={this.state.currentError}
|
|
530
|
+ />
|
|
531
|
+ <Animatable.View
|
|
532
|
+ ref={this.bookRef}
|
|
533
|
+ style={{
|
|
534
|
+ position: "absolute",
|
|
535
|
+ bottom: 0,
|
|
536
|
+ left: 0,
|
|
537
|
+ width: "100%",
|
|
538
|
+ flex: 1,
|
|
539
|
+ transform: [
|
|
540
|
+ {translateY: 100},
|
|
541
|
+ ]
|
|
542
|
+ }}>
|
|
543
|
+ <Button
|
|
544
|
+ icon="bookmark-check"
|
|
545
|
+ mode="contained"
|
|
546
|
+ onPress={this.showDialog}
|
|
547
|
+ style={{
|
|
548
|
+ width: "80%",
|
|
549
|
+ flex: 1,
|
|
550
|
+ marginLeft: "auto",
|
|
551
|
+ marginRight: "auto",
|
|
552
|
+ marginBottom: 20,
|
|
553
|
+ borderRadius: 10
|
|
554
|
+ }}
|
|
555
|
+ >
|
|
556
|
+ {i18n.t('equipmentScreen.bookButton')}
|
|
557
|
+ </Button>
|
|
558
|
+ </Animatable.View>
|
|
559
|
+
|
|
560
|
+ </View>
|
|
561
|
+
|
|
562
|
+ )
|
|
563
|
+ } else
|
|
564
|
+ return <View/>;
|
|
565
|
+ }
|
|
566
|
+
|
|
567
|
+}
|
|
568
|
+
|
|
569
|
+export default withCollapsible(withTheme(EquipmentRentScreen));
|