-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
126 lines (113 loc) · 2.76 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import React, { useState } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";
import {
SafeAreaView,
View,
Text,
StyleSheet,
ImageBackground,
} from "react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import CalendarHeader from "./components/Calendar/CalendarHeader";
import CalendarContent from "./components/Calendar/CalendarContent";
import Days from "./components/Days/Days";
const MONTHS = [
"Январь",
"Февраль",
"Март",
"Апрель",
"Май",
"Июнь",
"Июль",
"Август",
"Сентябрь",
"Октябрь",
"Ноябрь",
"Декабрь",
];
const App = () => {
const Stack = createStackNavigator();
let activeDate = new Date();
const [year, setYear] = useState(activeDate.getFullYear());
const [month, setMonth] = useState(activeDate.getMonth());
const [chooseDay, setChooseDay] = useState(null);
//console.log(new Date(year, month + 1, 0).getDate());
const setMonthHandler = (variate) => {
if (variate) {
if (month < 11) {
setMonth(month + 1);
} else {
setYear(year + 1);
setMonth(0);
}
} else {
if (month > 0) {
setMonth(month - 1);
} else {
setYear(year - 1);
setMonth(11);
}
}
};
const MainScreen = ({ navigation }) => (
<SafeAreaView style={styles.body}>
<CalendarHeader
months={MONTHS}
date={{ month, year }}
setDate={setMonthHandler}
/>
<CalendarContent
countDay={new Date(year, month + 1, 0).getDate()}
date={{ month, year }}
chooseDay={(value) => setChooseDay(value)}
navigation={navigation}
/>
<Text>{month}</Text>
</SafeAreaView>
);
const DayScreen = ({ navigation }) => (
<Days
navigation={navigation}
date={{
year,
month,
day: chooseDay,
}}
/>
);
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Main">
<Stack.Screen
name="Main"
component={MainScreen}
options={{
headerShown: false,
documentTitle: `${MONTHS[month]} ${year}`,
}}
/>
<Stack.Screen
name="Day"
component={DayScreen}
options={{
headerShown: false,
documentTitle: `${MONTHS[month]} ${chooseDay} ${year}`,
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
const styles = StyleSheet.create({
body: {
flex: 1,
alignItems: "center",
justifyContent: "center",
backgroundColor: "#1E1F25",
},
test: {
display: "none",
},
});
export default App;