-
Notifications
You must be signed in to change notification settings - Fork 98
/
App.js
84 lines (77 loc) · 1.96 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @format
*/
import React, { Component } from 'react';
import {
StyleSheet,
View,
Alert,
} from 'react-native';
import WeekView, { addLocale } from 'react-native-week-view';
addLocale('fr', {
months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
});
export default class App extends Component {
selectedDate = new Date();
generateDates = (hours, minutes) => {
const date = new Date();
date.setHours(date.getHours() + hours);
if (minutes != null) {
date.setMinutes(minutes);
}
return date;
};
render() {
const events = [
{
id: 1,
description: 'Event 1',
startDate: this.generateDates(0),
endDate: this.generateDates(2),
color: 'blue',
},
{
id: 2,
description: 'Event 2',
startDate: this.generateDates(1),
endDate: this.generateDates(4),
color: 'red',
},
{
id: 3,
description: 'Event 3',
startDate: this.generateDates(-5),
endDate: this.generateDates(-3),
color: 'green',
},
];
return (
<View style={styles.container}>
<WeekView
events={events}
selectedDate={this.selectedDate}
numberOfDays={3}
onEventPress={(event) => Alert.alert('eventId:' + event.id)}
headerStyle={styles.headerStyle}
formatDateHeader="MMM D"
locale="fr"
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#FFF',
paddingTop: 22,
},
headerStyle: {
backgroundColor: '#4286f4',
},
});