|
9 | 9 | */
|
10 | 10 |
|
11 | 11 | import React from 'react';
|
| 12 | +import { |
| 13 | + DefaultTheme, |
| 14 | + Provider as PaperProvider, |
| 15 | + Avatar, |
| 16 | + Button, |
| 17 | + Card, |
| 18 | + Title, |
| 19 | + Paragraph |
| 20 | +} from 'react-native-paper'; |
12 | 21 | import {
|
13 | 22 | SafeAreaView,
|
14 |
| - ScrollView, |
15 | 23 | StatusBar,
|
16 | 24 | StyleSheet,
|
17 |
| - Text, |
18 | 25 | useColorScheme,
|
19 |
| - View, |
20 | 26 | } from 'react-native';
|
21 | 27 |
|
22 |
| -import { |
23 |
| - Colors, |
24 |
| - DebugInstructions, |
25 |
| - Header, |
26 |
| - LearnMoreLinks, |
27 |
| - ReloadInstructions, |
28 |
| -} from 'react-native/Libraries/NewAppScreen'; |
29 |
| - |
30 |
| -const Section: React.FC<{ |
31 |
| - title: string; |
32 |
| -}> = ({children, title}) => { |
33 |
| - const isDarkMode = useColorScheme() === 'dark'; |
34 |
| - return ( |
35 |
| - <View style={styles.sectionContainer}> |
36 |
| - <Text |
37 |
| - style={[ |
38 |
| - styles.sectionTitle, |
39 |
| - { |
40 |
| - color: isDarkMode ? Colors.white : Colors.black, |
41 |
| - }, |
42 |
| - ]}> |
43 |
| - {title} |
44 |
| - </Text> |
45 |
| - <Text |
46 |
| - style={[ |
47 |
| - styles.sectionDescription, |
48 |
| - { |
49 |
| - color: isDarkMode ? Colors.light : Colors.dark, |
50 |
| - }, |
51 |
| - ]}> |
52 |
| - {children} |
53 |
| - </Text> |
54 |
| - </View> |
55 |
| - ); |
56 |
| -}; |
| 28 | +const LeftContent = (props: any) => <Avatar.Icon {...props} icon="folder" /> |
57 | 29 |
|
58 | 30 | const App = () => {
|
59 | 31 | const isDarkMode = useColorScheme() === 'dark';
|
60 | 32 |
|
| 33 | + const theme = { |
| 34 | + ...DefaultTheme, |
| 35 | + colors: { |
| 36 | + ...DefaultTheme.colors, |
| 37 | + primary: 'tomato', |
| 38 | + accent: 'yellow', |
| 39 | + }, |
| 40 | + }; |
| 41 | + |
| 42 | + |
61 | 43 | const backgroundStyle = {
|
62 |
| - backgroundColor: isDarkMode ? Colors.darker : Colors.lighter, |
| 44 | + backgroundColor: isDarkMode ? theme.colors.primary : theme.colors.accent, |
63 | 45 | };
|
64 | 46 |
|
65 | 47 | return (
|
66 |
| - <SafeAreaView style={backgroundStyle}> |
67 |
| - <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} /> |
68 |
| - <ScrollView |
69 |
| - contentInsetAdjustmentBehavior="automatic" |
70 |
| - style={backgroundStyle}> |
71 |
| - <Header /> |
72 |
| - <View |
73 |
| - style={{ |
74 |
| - backgroundColor: isDarkMode ? Colors.black : Colors.white, |
75 |
| - }}> |
76 |
| - <Section title="Step One"> |
77 |
| - Edit <Text style={styles.highlight}>App.tsx</Text> to change this |
78 |
| - screen and then come back to see your edits. |
79 |
| - </Section> |
80 |
| - <Section title="See Your Changes"> |
81 |
| - <ReloadInstructions /> |
82 |
| - </Section> |
83 |
| - <Section title="Debug"> |
84 |
| - <DebugInstructions /> |
85 |
| - </Section> |
86 |
| - <Section title="Learn More"> |
87 |
| - Read the docs to discover what to do next: |
88 |
| - </Section> |
89 |
| - <LearnMoreLinks /> |
90 |
| - </View> |
91 |
| - </ScrollView> |
92 |
| - </SafeAreaView> |
| 48 | + <PaperProvider theme={theme}> |
| 49 | + <SafeAreaView style={backgroundStyle}> |
| 50 | + <StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} /> |
| 51 | + <Card> |
| 52 | + <Card.Title title="Card Title" subtitle="Card Subtitle" left={LeftContent} /> |
| 53 | + <Card.Content> |
| 54 | + <Title>Card title</Title> |
| 55 | + <Paragraph>Card content</Paragraph> |
| 56 | + </Card.Content> |
| 57 | + <Card.Cover source={{ uri: 'https://picsum.photos/700' }} /> |
| 58 | + <Card.Actions> |
| 59 | + <Button>Cancel</Button> |
| 60 | + <Button>Ok</Button> |
| 61 | + </Card.Actions> |
| 62 | + </Card> |
| 63 | + </SafeAreaView> |
| 64 | + </PaperProvider> |
93 | 65 | );
|
94 | 66 | };
|
95 | 67 |
|
|
0 commit comments