-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalendarScreen.js
More file actions
99 lines (73 loc) · 3.31 KB
/
CalendarScreen.js
File metadata and controls
99 lines (73 loc) · 3.31 KB
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
import React, {Component, useState} from 'react';
import { StyleSheet, Text, View, Button, Alert, TextInput, Image, FlatList, TouchableWithoutFeedback, Keyboard } from 'react-native';
import {CalendarList} from 'react-native-calendars'; // https://github.com/wix/react-native-calendars
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
export default function CalendarScreen( {route, navigation}) {
const [pvm, setPvm] =useState('');
const [data, setData] = useState([]);
const dayPressed = (date) => {
const pvm = date.day + '.' + date.month + '.' + date.year + ' ';
setPvm(pvm)
setData([...data, {pvm}]);
Alert.alert(pvm , 'date selected');
}
return (
<View style={styles.container}>
<CalendarList
// https://github.com/wix/react-native-calendars <-- DOCUMENTS ABOUT THIS CALENDAR!
// Callback which gets executed when visible months change in scroll view. Default = undefined
onVisibleMonthsChange={(months) => {console.log('now these months are visible', months);}}
// Max amount of months allowed to scroll to the past. Default = 50
pastScrollRange={1}
// Max amount of months allowed to scroll to the future. Default = 50
futureScrollRange={12}
// Enable or disable scrolling of calendar list
scrollEnabled={true}
// Enable or disable vertical scroll indicator. Default = false
showScrollIndicator={true}
onDayPress={(day) => {
dayPressed(day), day}
}
//onDayPress={({dateString}) => showDayTest(dateString)}
// prints object on console
showWeekNumbers={true}
minDate={new Date} // can't click dates in past
maxDate={'2020-12-31'} // change this to dynamic + 12 Months
/>
<FlatList // Sends date data CalenderTodo.js
data={data}
renderItem={({item}) => (
navigation.navigate('Todo', item)>
<Text>testi{item.pvm}</Text>
)}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
const styles2 = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'space-around',
},
});
const styles3 = StyleSheet.create({
container: {
flex: 2,
flexDirection: 'row',
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});