forked from mrzachnugent/react-native-reusables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendar.tsx
147 lines (140 loc) · 2.9 KB
/
calendar.tsx
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { useColorScheme } from 'nativewind';
import React from 'react';
import { Calendar as RNCalendar, LocaleConfig } from 'react-native-calendars';
import { NAV_THEME } from '~/lib/constants';
/**
* @docs https://github.com/wix/react-native-calendars
*/
function Calendar({
theme,
...props
}: React.ComponentProps<typeof RNCalendar>) {
const { colorScheme } = useColorScheme();
const id = React.useId();
return (
<RNCalendar
key={`${id}-${colorScheme}`}
theme={getTheme(colorScheme === 'dark', theme)}
{...props}
/>
);
}
const SKY_500 = '#0ea5e9';
const SKY_600 = '#0284c7';
function getTheme(
isThemeDark: boolean,
customTheme?: React.ComponentProps<typeof RNCalendar>['theme']
): React.ComponentProps<typeof RNCalendar>['theme'] {
if (isThemeDark) {
return {
backgroundColor: NAV_THEME.dark.background,
calendarBackground: NAV_THEME.dark.card,
textSectionTitleColor: NAV_THEME.dark.text,
selectedDayBackgroundColor: SKY_500,
selectedDayTextColor: '#000000',
todayTextColor: SKY_500,
dayTextColor: NAV_THEME.dark.text,
textDisabledColor: '#ffffff30',
monthTextColor: NAV_THEME.dark.text,
textMonthFontWeight: '500',
arrowColor: SKY_500,
...customTheme,
};
}
return {
backgroundColor: NAV_THEME.light.background,
calendarBackground: NAV_THEME.light.card,
textSectionTitleColor: NAV_THEME.light.text,
selectedDayBackgroundColor: SKY_600,
selectedDayTextColor: '#ffffff',
todayTextColor: SKY_600,
dayTextColor: '#2d4150',
monthTextColor: NAV_THEME.light.text,
textMonthFontWeight: '500',
arrowColor: SKY_600,
...customTheme,
};
}
LocaleConfig.locales['en'] = {
monthNames: [
'January',
'Febuary',
'March',
'April',
'May',
'June',
'July',
'August',
'Septemeber',
'October',
'November',
'December',
],
monthNamesShort: [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sept',
'Oct',
'Nov',
'Dec',
],
dayNames: [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'],
today: 'Today',
};
LocaleConfig.locales['fr'] = {
monthNames: [
'Janvier',
'Février',
'Mars',
'Avril',
'Mai',
'Juin',
'Juillet',
'Août',
'Septembre',
'Octobre',
'Novembre',
'Décembre',
],
monthNamesShort: [
'Janv.',
'Févr.',
'Mars',
'Avril',
'Mai',
'Juin',
'Juil.',
'Août',
'Sept.',
'Oct.',
'Nov.',
'Déc.',
],
dayNames: [
'Dimanche',
'Lundi',
'Mardi',
'Mercredi',
'Jeudi',
'Vendredi',
'Samedi',
],
dayNamesShort: ['Dim.', 'Lun.', 'Mar.', 'Mer.', 'Jeu.', 'Ven.', 'Sam.'],
today: "Aujourd'hui",
};
export { Calendar, LocaleConfig };