-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCalendarPage.js
100 lines (95 loc) · 3.7 KB
/
CalendarPage.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import React from "react";
import { TouchableOpacity, View, Text } from "react-native";
import { createStackNavigator } from "react-navigation";
import { Ionicons } from "@expo/vector-icons";
import { Calendar, CalendarList, Agenda } from "react-native-calendars";
class CalendarPage extends React.Component {
render() {
return (
<View
style={{
flex: 1,
backgroundColor: "#eee"
}}
>
<Calendar
// Initially visible month. Default = Date()
current={new Date()}
// Handler which gets executed on day press. Default = undefined
onDayPress={day => {
console.log("selected day", day);
}}
// Handler which gets executed on day long press. Default = undefined
onDayLongPress={day => {
console.log("selected day", day);
}}
// Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting
monthFormat={"MMM yyyy"}
// Handler which gets executed when visible month changes in calendar. Default = undefined
onMonthChange={month => {
console.log("month changed", month);
}}
// Hide month navigation arrows. Default = false
hideArrows={true}
// Replace default arrows with custom ones (direction can be 'left' or 'right')
renderArrow={direction => <Arrow />}
// Do not show days of other months in month page. Default = false
hideExtraDays={true}
// If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out
// day from another month that is visible in calendar page. Default = false
disableMonthChange={true}
// If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
firstDay={1}
// Hide day names. Default = false
hideDayNames={false}
// Show week numbers to the left. Default = false
showWeekNumbers={false}
// Handler which gets executed when press arrow icon left. It receive a callback can go back month
onPressArrowLeft={substractMonth => substractMonth()}
// Handler which gets executed when press arrow icon left. It receive a callback can go next month
onPressArrowRight={addMonth => addMonth()}
markedDates={
{'2019-02-20': {textColor: '#FFA500'},
'2019-02-22': {startingDay: true, color: 'moccasin'},
'2019-02-23': {selected: true, endingDay: true, color: '#FFA500', textColor: 'gray'},
'2019-02-04': {startingDay: true, color: 'moccasin', endingDay: true}
}}
// Date marking style [simple/period/multi-dot/custom]. Default = 'simple'
markingType={'period'}
theme={{
dayTextColor: '#FFDAB9',
'stylesheet.calendar.header': {
week: {
marginTop: 5,
flexDirection: 'row',
justifyContent: 'space-between',
color:'red',
}
},
dayTextColor: '#FF7F50',
calendarBackground: '#333248',
}}
/>
</View>
);
}
}
export default (CalendarStack = createStackNavigator({
CalendarPage: {
screen: CalendarPage,
navigationOptions: ({ navigation }) => ({
headerTitle: "Calendar",
headerLeft: (
<View>
<TouchableOpacity
onPress={() => {
navigation.toggleDrawer();
}}
>
<Ionicons name="md-menu" size={35} />
</TouchableOpacity>
</View>
)
})
}
}));