-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathApp.tsx
More file actions
106 lines (93 loc) · 2.52 KB
/
App.tsx
File metadata and controls
106 lines (93 loc) · 2.52 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
100
101
102
103
104
105
106
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
*/
import React, {useState} from 'react';
import {SafeAreaView, StatusBar, useColorScheme, View, Text, StyleSheet} from 'react-native';
import {NewAppScreen} from '@react-native/new-app-screen';
import {CalendarView} from 'xaml-calendar-view';
type SectionProps = {
title: string;
children?: React.ReactNode;
};
function Section({title, children}: SectionProps): React.JSX.Element {
return (
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>{title}</Text>
{typeof children === 'string' ? (
<Text style={styles.sectionDescription}>{children}</Text>
) : (
children
)}
</View>
);
}
function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
// Adjust this type if your native event uses a different shape.
// Many RNW components emit strings or numbers; you can swap to Date if you convert it.
const [selectedDate, setSelectedDate] = useState<string | undefined>(undefined);
return (
<SafeAreaView style={{flex: 1}}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor="transparent"
translucent
/>
{/* Your app content below the new screen */}
<View
style={[
styles.content,
{backgroundColor: isDarkMode ? '#000000' : '#FFFFFF'},
]}
>
<Section title="Calendar">
<Text style={styles.sectionDescription}>
Showing a CalendarView here (displayMode=1 for month view).
</Text>
<CalendarView
style={{width: 400, height: 400}}
displayMode="1"
onSelectedDatesChanged={e => {
setSelectedDate(e.nativeEvent.startDate);
}}
/>
</Section>
<Section title="Selected date">
<Text style={styles.sectionDescription}>
{selectedDate ?? '—'}
</Text>
</Section>
</View>
{/* New RN welcome screen */}
<NewAppScreen />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
content: {
paddingHorizontal: 24,
paddingVertical: 16,
},
sectionContainer: {
marginTop: 16,
},
sectionTitle: {
fontSize: 20,
fontWeight: '600',
marginBottom: 6,
},
sectionDescription: {
fontSize: 16,
fontWeight: '400',
},
});
export default App;