Skip to content

Commit

Permalink
feat: add gradient option
Browse files Browse the repository at this point in the history
  • Loading branch information
exzos28 committed May 10, 2024
1 parent 7783fd8 commit f0820b2
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 87 deletions.
93 changes: 61 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,61 +29,90 @@ import React from 'react';

import { StyleSheet, View, Text } from 'react-native';
import { QrCodeSvg } from 'react-native-qr-svg';
import { plainRenderer } from '../../src/renderers';

const SIZE = 170;
const CONTENT = 'Hello world!';

export default function App() {
return (
<View style={styles.container}>
<View style={styles.firstQr}>
<QrCodeSvg
value="Hello world!"
frameSize={200}
contentCells={5}
content={
<View>
<Text>👋</Text>
</View>
}
contentStyle={styles.box}
/>
</View>
<View style={styles.secondQr}>
<QrCodeSvg
value="Hello world!"
frameSize={200}
contentCells={5}
content={
<View>
<Text>💻</Text>
</View>
}
dotColor="#ffffff"
backgroundColor="#000000"
contentStyle={styles.box}
/>
<View style={styles.root}>
<View style={styles.content}>
<View style={styles.qr}>
<QrCodeSvg
value={CONTENT}
frameSize={SIZE}
contentCells={5}
content={
<View>
<Text style={styles.icon}>👋</Text>
</View>
}
contentStyle={styles.box}
/>
</View>
<View style={styles.qr}>
<QrCodeSvg
gradientColors={['#FF0000', '#00FF00']}
value={CONTENT}
frameSize={SIZE}
/>
</View>
<View style={[styles.qr, styles.secondQr]}>
<QrCodeSvg
value={CONTENT}
frameSize={SIZE}
contentCells={5}
content={
<View>
<Text style={styles.icon}>💻</Text>
</View>
}
dotColor="#ffffff"
backgroundColor="#000000"
contentStyle={styles.box}
/>
</View>
<View style={styles.qr}>
<QrCodeSvg
renderer={plainRenderer}
value={CONTENT}
frameSize={SIZE}
/>
</View>
</View>
</View>
);
}

const styles = StyleSheet.create({
container: {
root: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
content: {
flexDirection: 'row',
flexWrap: 'wrap',
alignItems: 'center',
justifyContent: 'center',
},
box: {
alignItems: 'center',
justifyContent: 'center',
},
firstQr: {
marginRight: 15,
icon: {
fontSize: 20,
},
secondQr: {
qr: {
padding: 15,
},
secondQr: {
backgroundColor: '#000000',
},
});


```

## Contributing 🤝
Expand Down
91 changes: 54 additions & 37 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,72 @@ import { StyleSheet, View, Text } from 'react-native';
import { QrCodeSvg } from 'react-native-qr-svg';
import { plainRenderer } from '../../src/renderers';

const SIZE = 170;
const CONTENT = 'Hello world!';

export default function App() {
return (
<View style={styles.container}>
<View style={[styles.qr, styles.firstQr]}>
<QrCodeSvg
value="Hello world!"
frameSize={200}
contentCells={5}
content={
<View>
<Text style={styles.icon}>👋</Text>
</View>
}
contentStyle={styles.box}
/>
</View>
<View style={[styles.qr, styles.secondQr]}>
<QrCodeSvg
value="Hello world!"
frameSize={200}
contentCells={5}
content={
<View>
<Text style={styles.icon}>💻</Text>
</View>
}
dotColor="#ffffff"
backgroundColor="#000000"
contentStyle={styles.box}
/>
</View>
<View style={styles.qr}>
<QrCodeSvg
renderer={plainRenderer}
value="Hello world!"
frameSize={200}
/>
<View style={styles.root}>
<View style={styles.content}>
<View style={styles.qr}>
<QrCodeSvg
value={CONTENT}
frameSize={SIZE}
contentCells={5}
content={
<View>
<Text style={styles.icon}>👋</Text>
</View>
}
contentStyle={styles.box}
/>
</View>
<View style={styles.qr}>
<QrCodeSvg
gradientColors={['#0800ff', '#ff0000']}
value={CONTENT}
frameSize={SIZE}
/>
</View>
<View style={[styles.qr, styles.secondQr]}>
<QrCodeSvg
value={CONTENT}
frameSize={SIZE}
contentCells={5}
content={
<View>
<Text style={styles.icon}>💻</Text>
</View>
}
dotColor="#ffffff"
backgroundColor="#000000"
contentStyle={styles.box}
/>
</View>
<View style={styles.qr}>
<QrCodeSvg
renderer={plainRenderer}
value={CONTENT}
frameSize={SIZE}
/>
</View>
</View>
</View>
);
}

const styles = StyleSheet.create({
container: {
root: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
content: {
flexDirection: 'row',
flexWrap: 'wrap',
alignItems: 'center',
justifyContent: 'center',
},
box: {
alignItems: 'center',
justifyContent: 'center',
Expand All @@ -62,7 +80,6 @@ const styles = StyleSheet.create({
qr: {
padding: 15,
},
firstQr: {},
secondQr: {
backgroundColor: '#000000',
},
Expand Down
Binary file modified screenshot/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f0820b2

Please sign in to comment.