-
Notifications
You must be signed in to change notification settings - Fork 7
/
App.tsx
111 lines (106 loc) · 2.51 KB
/
App.tsx
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
107
108
109
110
111
import React from 'react';
import { StyleSheet, View, Text } from 'react-native';
import {
QrCodeSvg,
plainRenderer,
triangleRenderer,
circleRenderer,
renderCircle,
type RenderParams,
renderSquare,
type CustomRenderer,
Kind,
} from 'react-native-qr-svg';
const SIZE = 140;
const CONTENT = 'Hello world!';
const render = ({ isSquareElem, corners, cellSize }: RenderParams) => {
if (isSquareElem) {
return renderSquare(corners);
}
return renderCircle(corners.center, cellSize);
};
export const customRenderer: CustomRenderer = {
render: {
[Kind.Circle]: (params) => render(params),
[Kind.Element]: (params) => render(params),
},
};
export default function App() {
return (
<View style={styles.root}>
<View style={styles.content}>
<QrCodeSvg
style={styles.qr}
value={CONTENT}
frameSize={SIZE}
contentCells={5}
content={<Text style={styles.icon}>👋</Text>}
contentStyle={styles.box}
/>
<QrCodeSvg
style={styles.qr}
gradientColors={['#0800ff', '#ff0000']}
value={CONTENT}
frameSize={SIZE}
/>
<QrCodeSvg
style={styles.qr}
value={CONTENT}
frameSize={SIZE}
contentCells={5}
content={<Text style={styles.icon}>💻</Text>}
dotColor="#ffffff"
backgroundColor="#000000"
contentStyle={styles.box}
/>
<QrCodeSvg
style={styles.qr}
renderer={{ ...plainRenderer, options: { padding: 0 } }}
value={CONTENT}
frameSize={SIZE}
/>
<QrCodeSvg
style={styles.qr}
renderer={{ ...triangleRenderer, options: { padding: 0 } }}
value={CONTENT}
frameSize={SIZE}
/>
<QrCodeSvg
style={styles.qr}
renderer={{ ...circleRenderer, options: { padding: 0 } }}
value={CONTENT}
frameSize={SIZE}
/>
<QrCodeSvg
style={styles.qr}
renderer={customRenderer}
value={CONTENT}
frameSize={SIZE}
/>
</View>
</View>
);
}
const styles = StyleSheet.create({
root: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
content: {
flexDirection: 'row',
flexWrap: 'wrap',
alignItems: 'center',
justifyContent: 'center',
},
box: {
alignItems: 'center',
justifyContent: 'center',
},
icon: {
fontSize: 20,
},
qr: {
padding: 15,
},
});