-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathApp.tsx
More file actions
77 lines (69 loc) · 1.67 KB
/
App.tsx
File metadata and controls
77 lines (69 loc) · 1.67 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
import {
StyleSheet,
ScrollView,
SafeAreaView,
Alert,
Linking,
} from 'react-native';
import { RichTextView } from 'react-native-rich-text';
import type { HeaderConfig } from 'react-native-rich-text';
const HEADER_CONFIG: HeaderConfig = {
scale: 2.0,
isBold: true,
};
const sampleMarkdown = `#### Welcome to the React Native Markdown component!
This is a simple text with links.
Check out this [link to React Native](https://reactnative.dev) and this [GitHub repository](https://github.com/facebook/react-native).
Built with ❤️ using React Native Fabric Architecture`;
export default function App() {
const handleLinkPress = (event: { nativeEvent: { url: string } }) => {
const { url } = event.nativeEvent;
Alert.alert('Link Pressed!', `You tapped on: ${url}`, [
{
text: 'Open in Browser',
onPress: () => {
Linking.openURL(url);
},
},
{
text: 'Cancel',
style: 'cancel',
},
]);
};
return (
<SafeAreaView style={styles.container}>
<ScrollView
style={styles.scrollView}
contentContainerStyle={styles.content}
>
<RichTextView
markdown={sampleMarkdown}
style={styles.markdown}
fontSize={18}
fontFamily="Helvetica"
headerConfig={HEADER_CONFIG}
textColor="#F54927"
onLinkPress={handleLinkPress}
/>
</ScrollView>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
scrollView: {
flex: 1,
},
content: {
padding: 20,
},
markdown: {
flex: 1,
padding: 10,
borderRadius: 8,
minHeight: 250,
},
});