Skip to content

Commit 2db394b

Browse files
committed
fix: react-native paper integration
1 parent f3eb4b1 commit 2db394b

21 files changed

+152
-154
lines changed

demo/mobile/reactnative/App.tsx

Lines changed: 38 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,87 +9,59 @@
99
*/
1010

1111
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';
1221
import {
1322
SafeAreaView,
14-
ScrollView,
1523
StatusBar,
1624
StyleSheet,
17-
Text,
1825
useColorScheme,
19-
View,
2026
} from 'react-native';
2127

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" />
5729

5830
const App = () => {
5931
const isDarkMode = useColorScheme() === 'dark';
6032

33+
const theme = {
34+
...DefaultTheme,
35+
colors: {
36+
...DefaultTheme.colors,
37+
primary: 'tomato',
38+
accent: 'yellow',
39+
},
40+
};
41+
42+
6143
const backgroundStyle = {
62-
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
44+
backgroundColor: isDarkMode ? theme.colors.primary : theme.colors.accent,
6345
};
6446

6547
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>
9365
);
9466
};
9567

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)