@oguzhnatly/react-native-custom-qr-codes 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +32 -0
- package/.github/workflows/publish.yml +69 -0
- package/CONTRIBUTING.md +14 -0
- package/LICENSE +21 -0
- package/README.md +181 -0
- package/index.d.ts +32 -0
- package/index.js +1 -0
- package/lib/QRCode.js +529 -0
- package/lib/QRCodeGenerator.js +1862 -0
- package/lib/styles/codeStyles/circle.js +31 -0
- package/lib/styles/codeStyles/diamond.js +35 -0
- package/lib/styles/codeStyles/dot.js +31 -0
- package/lib/styles/codeStyles/index.js +36 -0
- package/lib/styles/codeStyles/ninja.js +132 -0
- package/lib/styles/codeStyles/sharp.js +118 -0
- package/lib/styles/codeStyles/square.js +32 -0
- package/lib/styles/index.js +45 -0
- package/lib/styles/innerEyeStyles/circle.js +31 -0
- package/lib/styles/innerEyeStyles/diamond.js +35 -0
- package/lib/styles/innerEyeStyles/index.js +31 -0
- package/lib/styles/innerEyeStyles/none.js +8 -0
- package/lib/styles/innerEyeStyles/square.js +32 -0
- package/lib/styles/outerEyeStyles/circle.js +31 -0
- package/lib/styles/outerEyeStyles/diamond.js +35 -0
- package/lib/styles/outerEyeStyles/index.js +30 -0
- package/lib/styles/outerEyeStyles/none.js +8 -0
- package/lib/styles/outerEyeStyles/square.js +32 -0
- package/package.json +39 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
name: Install and type check
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Setup Node.js
|
|
21
|
+
uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: '20'
|
|
24
|
+
cache: 'npm'
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm install
|
|
28
|
+
|
|
29
|
+
- name: Verify types
|
|
30
|
+
run: |
|
|
31
|
+
test -f index.d.ts || (echo "index.d.ts missing" && exit 1)
|
|
32
|
+
echo "Types verified"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
paths:
|
|
8
|
+
- 'package.json'
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
name: Publish
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
contents: write
|
|
16
|
+
id-token: write
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Setup Node.js
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '20'
|
|
26
|
+
|
|
27
|
+
- name: Upgrade npm
|
|
28
|
+
run: npm install -g npm@latest
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: npm install
|
|
32
|
+
|
|
33
|
+
- name: Check if version changed
|
|
34
|
+
id: version_check
|
|
35
|
+
run: |
|
|
36
|
+
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
|
37
|
+
PUBLISHED_VERSION=$(npm view $(node -p "require('./package.json').name") version 2>/dev/null || echo "0.0.0")
|
|
38
|
+
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
39
|
+
echo "published=$PUBLISHED_VERSION" >> $GITHUB_OUTPUT
|
|
40
|
+
if [ "$CURRENT_VERSION" != "$PUBLISHED_VERSION" ]; then
|
|
41
|
+
echo "changed=true" >> $GITHUB_OUTPUT
|
|
42
|
+
else
|
|
43
|
+
echo "changed=false" >> $GITHUB_OUTPUT
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
- name: Publish to npm
|
|
47
|
+
if: steps.version_check.outputs.changed == 'true'
|
|
48
|
+
run: |
|
|
49
|
+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
|
50
|
+
npm publish --provenance --access public
|
|
51
|
+
env:
|
|
52
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
53
|
+
|
|
54
|
+
- name: Create GitHub release
|
|
55
|
+
if: steps.version_check.outputs.changed == 'true'
|
|
56
|
+
uses: softprops/action-gh-release@v2
|
|
57
|
+
with:
|
|
58
|
+
tag_name: v${{ steps.version_check.outputs.current }}
|
|
59
|
+
name: v${{ steps.version_check.outputs.current }}
|
|
60
|
+
body: |
|
|
61
|
+
## @oguzhnatly/react-native-custom-qr-codes v${{ steps.version_check.outputs.current }}
|
|
62
|
+
|
|
63
|
+
Published to npm: https://www.npmjs.com/package/@oguzhnatly/react-native-custom-qr-codes
|
|
64
|
+
generate_release_notes: true
|
|
65
|
+
make_latest: true
|
|
66
|
+
|
|
67
|
+
- name: Skip (version unchanged)
|
|
68
|
+
if: steps.version_check.outputs.changed == 'false'
|
|
69
|
+
run: echo "Version ${{ steps.version_check.outputs.current }} is already published. Bump package.json version to trigger a new release."
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for taking the time to try and make this project better!
|
|
4
|
+
|
|
5
|
+
## Reporting Bugs & Feature Requests
|
|
6
|
+
|
|
7
|
+
If you have found an issue, create an issue on the repo- but make sure to:
|
|
8
|
+
* Describe what does happen
|
|
9
|
+
* Describe what should happen instead
|
|
10
|
+
*i.e. In what way the functionality is different from desired.*
|
|
11
|
+
|
|
12
|
+
If you would like to request a feature, then by all means and we will try to implement it if reasonable.
|
|
13
|
+
|
|
14
|
+
If you would like to submit a feature request or report a bug, we encourage you to first look through the [issues](https://github.com/nating/react-native-custom-qr-codes/issues) and [pull requests](https://github.com/nating/react-native-custom-qr-codes/pulls) before filing a new issue.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Geoffrey Natin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# 🔲 react-native-custom-qr-codes
|
|
2
|
+
|
|
3
|
+
Fully customizable QR code component for React Native with TypeScript support and RTL layout compatibility. Style the code pieces, eye shapes, colors, gradients, logos, and background images however you need.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@oguzhnatly/react-native-custom-qr-codes)
|
|
6
|
+
[](https://www.npmjs.com/package/@oguzhnatly/react-native-custom-qr-codes)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://github.com/oguzhnatly/react-native-custom-qr-codes)
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<img alt="QR Code Example 1" src="https://raw.githubusercontent.com/oguzhnatly/react-native-custom-qr-codes/master/assets/qr-code-1.png" width="200">
|
|
12
|
+
<img alt="QR Code Example 2" src="https://raw.githubusercontent.com/oguzhnatly/react-native-custom-qr-codes/master/assets/qr-code-2.png" width="200">
|
|
13
|
+
<img alt="QR Code Example 3" src="https://raw.githubusercontent.com/oguzhnatly/react-native-custom-qr-codes/master/assets/qr-code-3.png" width="200">
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- ✅ Full TypeScript support with typed props
|
|
21
|
+
- ✅ RTL layout support
|
|
22
|
+
- ✅ Multiple code piece styles: square, circle, dot, diamond, sharp, ninja
|
|
23
|
+
- ✅ Independent eye shape control (outer and inner separately)
|
|
24
|
+
- ✅ Linear gradient foreground colors
|
|
25
|
+
- ✅ Logo overlay in the center of the QR code
|
|
26
|
+
- ✅ Background image fill for code pieces
|
|
27
|
+
- ✅ Configurable error correction level
|
|
28
|
+
- ✅ iOS and Android
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npm install @oguzhnatly/react-native-custom-qr-codes
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
yarn add @oguzhnatly/react-native-custom-qr-codes
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This package depends on `react-native-svg`. If you are not using Expo, install and link it manually:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm install react-native-svg
|
|
46
|
+
cd ios && pod install
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For manual linking instructions see the [react-native-svg documentation](https://github.com/software-mansion/react-native-svg#installation).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { QRCode } from '@oguzhnatly/react-native-custom-qr-codes';
|
|
57
|
+
|
|
58
|
+
<QRCode content="https://github.com/oguzhnatly" />
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Props
|
|
64
|
+
|
|
65
|
+
| Prop | Type | Default | Description |
|
|
66
|
+
|---|---|---|---|
|
|
67
|
+
| `content` | `string` | `'No Content'` | The string to encode in the QR code |
|
|
68
|
+
| `size` | `number` | `250` | Width and height of the component in pixels |
|
|
69
|
+
| `padding` | `number` | `1` | Padding between the edge and the QR code in piece units |
|
|
70
|
+
| `color` | `string` | `'black'` | Foreground color of the QR code |
|
|
71
|
+
| `backgroundColor` | `string` | `'white'` | Background color of the component |
|
|
72
|
+
| `codeStyle` | `string` | `'square'` | Style of the centre QR code pieces. See values below |
|
|
73
|
+
| `outerEyeStyle` | `string` | `'square'` | Style of the outer frame of the QR code eyes |
|
|
74
|
+
| `innerEyeStyle` | `string` | `'square'` | Style of the inner dot of the QR code eyes |
|
|
75
|
+
| `ecl` | `string` | `'L'` | Error correction level. Higher levels allow logo overlays. `L` `M` `Q` `H` |
|
|
76
|
+
| `logo` | `ImageSource` | none | Image source to display in the center of the QR code. Requires a higher `ecl` |
|
|
77
|
+
| `logoSize` | `number` | none | Size of the logo overlay in pixels |
|
|
78
|
+
| `linearGradient` | `ColorValue[]` | none | Two colors used for a linear gradient on the foreground |
|
|
79
|
+
| `gradientDirection` | `number[]` | `[0,0,170,0]` | Numbers defining the [gradient orientation](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Gradients) |
|
|
80
|
+
| `backgroundImage` | `ImageSource` | none | Image used as the fill pattern for QR code pieces. Eye styling is disabled when this is used |
|
|
81
|
+
| `isRTL` | `boolean` | `false` | Enables right-to-left layout rendering |
|
|
82
|
+
|
|
83
|
+
### `codeStyle` values
|
|
84
|
+
|
|
85
|
+
`square` `circle` `dot` `diamond` `sharp` `ninja`
|
|
86
|
+
|
|
87
|
+
### `outerEyeStyle` values
|
|
88
|
+
|
|
89
|
+
`square` `circle` `circles` `diamond` `rounded`
|
|
90
|
+
|
|
91
|
+
### `innerEyeStyle` values
|
|
92
|
+
|
|
93
|
+
`square` `circle` `circles` `diamond` `rounded`
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Examples
|
|
98
|
+
|
|
99
|
+
### Code styles
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
<QRCode content="https://example.com" codeStyle="square" />
|
|
103
|
+
<QRCode content="https://example.com" codeStyle="circle" />
|
|
104
|
+
<QRCode content="https://example.com" codeStyle="dot" />
|
|
105
|
+
<QRCode content="https://example.com" codeStyle="diamond" />
|
|
106
|
+
<QRCode content="https://example.com" codeStyle="sharp" />
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
<img src="./assets/example-code-styles.png" height="220" />
|
|
110
|
+
|
|
111
|
+
### Eye styles
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
<QRCode content="https://example.com" outerEyeStyle="square" innerEyeStyle="square" />
|
|
115
|
+
<QRCode content="https://example.com" outerEyeStyle="circle" innerEyeStyle="circle" />
|
|
116
|
+
<QRCode content="https://example.com" outerEyeStyle="diamond" innerEyeStyle="diamond" />
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
<img src="./assets/example-outer-eye-styles.png" height="220" />
|
|
120
|
+
<img src="./assets/example-inner-eye-styles.png" height="220" />
|
|
121
|
+
|
|
122
|
+
### Logo overlay
|
|
123
|
+
|
|
124
|
+
Use `ecl="H"` to ensure the QR code remains scannable with a logo covering the center:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
<QRCode
|
|
128
|
+
content="https://example.com"
|
|
129
|
+
logo={require('./logo.png')}
|
|
130
|
+
logoSize={60}
|
|
131
|
+
ecl="H"
|
|
132
|
+
/>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
<img src="./assets/example-logo.png" height="220" />
|
|
136
|
+
|
|
137
|
+
### Linear gradient
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
<QRCode
|
|
141
|
+
content="https://example.com"
|
|
142
|
+
linearGradient={['rgb(255,0,0)', 'rgb(0,100,255)']}
|
|
143
|
+
/>
|
|
144
|
+
|
|
145
|
+
<QRCode
|
|
146
|
+
content="https://example.com"
|
|
147
|
+
linearGradient={['rgb(255,0,0)', 'rgb(0,100,255)']}
|
|
148
|
+
gradientDirection={[0, 170, 0, 0]}
|
|
149
|
+
/>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
<img src="./assets/example-linear-gradient.png" height="220" />
|
|
153
|
+
|
|
154
|
+
### Background image
|
|
155
|
+
|
|
156
|
+
Eye styling is not available when using `backgroundImage`:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<QRCode
|
|
160
|
+
content="https://example.com"
|
|
161
|
+
backgroundImage={require('./texture.png')}
|
|
162
|
+
ecl="H"
|
|
163
|
+
/>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
<img src="./assets/example-background-image.png" height="220" />
|
|
167
|
+
|
|
168
|
+
### RTL support
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
<QRCode
|
|
172
|
+
content="https://example.com"
|
|
173
|
+
isRTL={true}
|
|
174
|
+
/>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## License
|
|
180
|
+
|
|
181
|
+
MIT © [Oguzhan Atalay](https://github.com/oguzhnatly)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ColorValue, ImageProps } from "react-native";
|
|
2
|
+
|
|
3
|
+
export function QRCode({
|
|
4
|
+
content,
|
|
5
|
+
size,
|
|
6
|
+
padding,
|
|
7
|
+
color,
|
|
8
|
+
gradientDirection,
|
|
9
|
+
backgroundColor,
|
|
10
|
+
codeStyle,
|
|
11
|
+
outerEyeStyle,
|
|
12
|
+
innerEyeStyle,
|
|
13
|
+
logoSize,
|
|
14
|
+
ecl,
|
|
15
|
+
}: {
|
|
16
|
+
content?: string;
|
|
17
|
+
size?: number;
|
|
18
|
+
padding?: number;
|
|
19
|
+
color?: string;
|
|
20
|
+
linearGradient?: Array<ColorValue>;
|
|
21
|
+
gradientDirection?: Array<number>;
|
|
22
|
+
backgroundColor?: string;
|
|
23
|
+
innerEyeStyle?: "circle" | "circles" | "diamond" | "rounded" | "square";
|
|
24
|
+
outerEyeStyle?: "circle" | "circles" | "diamond" | "rounded" | "square";
|
|
25
|
+
codeStyle?: "circle" | "diamond" | "dot" | "ninja" | "sharp" | "square";
|
|
26
|
+
logo?: ImageProps["source"] | string;
|
|
27
|
+
backgroundImage?: ImageProps["source"];
|
|
28
|
+
logoSize?: number;
|
|
29
|
+
ecl?: "L" | "M" | "Q" | "H";
|
|
30
|
+
svg?: any;
|
|
31
|
+
isRTL?: boolean;
|
|
32
|
+
});
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as QRCode } from './lib/QRCode';
|