Skip to content

Commit 3f043e0

Browse files
committed
docs: update docs
1 parent 51a625b commit 3f043e0

File tree

3 files changed

+74
-36
lines changed

3 files changed

+74
-36
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ const styles = StyleSheet.create({
5555
});
5656
```
5757

58+
## Screenshots
59+
60+
![Image](assets/example.png?raw=true 'Image')
61+
5862
## Contributing
5963

6064
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

assets/example.png

78.1 KB
Loading

example/src/App.tsx

Lines changed: 70 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,87 @@
11
import * as React from "react";
2-
import { StyleSheet } from "react-native";
2+
import { ScrollView, StyleSheet, Text } from "react-native";
33
import CodeHighlighter from "react-native-code-highlighter";
4+
import { SafeAreaView } from "react-native-safe-area-context";
45
import { atomOneDarkReasonable as hljsStyle } from "react-syntax-highlighter/dist/esm/styles/hljs";
56

67
const CODE_STR = `
7-
import * as React from "react";
8-
import { StyleSheet } from "react-native";
9-
import { SafeAreaView } from "react-native-safe-area-context";
10-
import CodeHighlighter from "react-native-code-highlighter";
11-
import { darcula as hljsStyle } from "react-syntax-highlighter/dist/esm/styles/hljs";
12-
import React, {
13-
useMemo,
14-
type FunctionComponent,
15-
type ReactNode,
16-
type CSSProperties,
17-
} from "react";
18-
import {
19-
Text,
20-
View,
21-
ScrollView,
22-
type ViewStyle,
23-
type TextStyle,
24-
} from "react-native";
25-
import SyntaxHighlighter, {
26-
type SyntaxHighlighterProps,
27-
} from "react-syntax-highlighter";
28-
// import { trimNewlines } from "trim-newlines";
29-
import {
30-
getRNStylesFromHljsStyle,
31-
type HighlighterStyleSheet,
32-
} from "./../utils/styles";
8+
import React from 'react';
9+
import {SectionList, StyleSheet, Text, View} from 'react-native';
10+
11+
const styles = StyleSheet.create({
12+
container: {
13+
flex: 1,
14+
paddingTop: 22,
15+
},
16+
sectionHeader: {
17+
paddingTop: 2,
18+
paddingLeft: 10,
19+
paddingRight: 10,
20+
paddingBottom: 2,
21+
fontSize: 14,
22+
fontWeight: 'bold',
23+
backgroundColor: 'rgba(247,247,247,1.0)',
24+
},
25+
item: {
26+
padding: 10,
27+
fontSize: 18,
28+
height: 44,
29+
},
30+
});
31+
32+
const SectionListBasics = () => {
33+
return (
34+
<View style={styles.container}>
35+
<SectionList
36+
sections={[
37+
{title: 'D', data: ['Devin', 'Dan', 'Dominic']},
38+
{
39+
title: 'J',
40+
data: [
41+
'Jackson',
42+
'James',
43+
'Jillian',
44+
'Jimmy',
45+
'Joel',
46+
'John',
47+
'Julie',
48+
],
49+
},
50+
]}
51+
renderItem={({item}) => <Text style={styles.item}>{item}</Text>}
52+
renderSectionHeader={({section}) => (
53+
<Text style={styles.sectionHeader}>{section.title}</Text>
54+
)}
55+
keyExtractor={item => \`basicListEntry-$\{item\}\`}
56+
/>
57+
</View>
58+
);
59+
};
60+
61+
export default SectionListBasics;
3362
`;
3463

3564
export default function App() {
3665
return (
37-
<CodeHighlighter
38-
containerStyle={styles.codeContainer}
39-
textStyle={styles.text}
40-
hljsStyle={hljsStyle}
41-
language="typescript"
42-
>
43-
{CODE_STR}
44-
</CodeHighlighter>
66+
<SafeAreaView>
67+
<Text>Example from https://reactnative.dev/docs/using-a-listview</Text>
68+
<ScrollView>
69+
<CodeHighlighter
70+
containerStyle={styles.codeContainer}
71+
textStyle={styles.text}
72+
hljsStyle={hljsStyle}
73+
language="typescript"
74+
>
75+
{CODE_STR}
76+
</CodeHighlighter>
77+
</ScrollView>
78+
</SafeAreaView>
4579
);
4680
}
4781

4882
const styles = StyleSheet.create({
4983
codeContainer: {
50-
padding: 16,
84+
paddingHorizontal: 16,
5185
minWidth: "100%",
5286
},
5387
text: {

0 commit comments

Comments
 (0)