-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
41 lines (36 loc) · 1.18 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
import React, { Component } from 'react';
import { View } from 'react-native';
import { CalendarList } from 'react-native-calendars';
import moment from 'moment';
import { Dimensions } from 'react-native';
const windowWidth = Dimensions.get('window').width;
class Calendars extends Component {
constructor(props) {
super(props);
this.state = {
currentDate: moment().format('YYYY-MM-DD')
}
}
onSwipeMonths(months) {
let { month, year, day } = months[0] ;
let currentDate = moment(`${year}/${month}/${day}`).format('YYYY-MM-DD');
this.setState({ currentDate });
}
render() {
return (
<View style={{height: 420}}>
<CalendarList
current={this.state.currentDate}
firstDay={0}
horizontal={true}
hideArrows={false}
pagingEnabled={true}
calendarWidth={windowWidth}
calendarHeight={420}
onVisibleMonthsChange={months => this.onSwipeMonths(months)}
/>
</View>
);
}
}
export default Calendars;