Skip to content

Commit 72b3b7f

Browse files
committed
Merge branch 'release/5.0.3'
2 parents 7d4c879 + fbebd9c commit 72b3b7f

4 files changed

Lines changed: 894 additions & 371 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ color | 'black' | Color of the QR code
9898
logo | null | Image source object. Ex. {uri: 'base64string'} or {require('pathToImage')}
9999
logoSize | 20% of size | Size of the imprinted logo. Bigger logo = less error correction in QR code
100100
logoBackgroundColor | backgroundColor | The logo gets a filled quadratic background with this color. Use 'transparent' if your logo already has its own backdrop.
101+
logoMargin | 2 | logo's distance to its wrapper
102+
logoBorderRadius | null | the border-radius of logo image (Android is not supported)
101103
getRef | null | Get SVG ref for further usage
102104
ecl | 'M' | Error correction level
103105

@@ -117,7 +119,7 @@ import RNFS from "react-native-fs"
117119
this.svg.toDataURL((data) => {
118120
RNFS.writeFile(RNFS.CachesDirectoryPath+"/some-name.png", data, 'base64')
119121
.then((success) => {
120-
return CameraRoll.saveToCameraRoll(RNFS.CachesDirectoryPath+"/some-name", 'photo')
122+
return CameraRoll.saveToCameraRoll(RNFS.CachesDirectoryPath+"/some-name.png", 'photo')
121123
})
122124
.then(() => {
123125
this.setState({ busy: false, imageSaved: true })

package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "react-native-qrcode-svg",
3-
"version": "5.0.2",
3+
"version": "5.0.3",
44
"description": "A QR Code generator for React Native based on react-native-svg and javascript-qrcode.",
55
"main": "index.js",
66
"scripts": {
77
"test": "jest",
88
"test-update": "npm run test -- --updateSnapshot",
99
"lint-staged": "lint-staged",
1010
"lint": "standard 'src/**/*.js'",
11-
"2npm": "publish"
11+
"2npm": "publish",
12+
"check-update": "yarn upgrade-interactive"
1213
},
1314
"standard": {
1415
"env": [
@@ -36,24 +37,24 @@
3637
},
3738
"homepage": "https://github.com/awesomejerry/react-native-qrcode-svg#readme",
3839
"peerDependencies": {
39-
"react": "^15.4.2",
40-
"react-native": "^0.42.0",
41-
"react-native-svg": "^5.1.5"
40+
"react-native": ">=0.46.0",
41+
"react": "16.0.0-alpha.12",
42+
"react-native-svg": "^5.4.1"
4243
},
4344
"dependencies": {
4445
"prop-types": "^15.5.10",
45-
"qrcode": "^0.8.1"
46+
"qrcode": "^0.9.0"
4647
},
4748
"devDependencies": {
48-
"babel-eslint": "^7.2.2",
49-
"babel-jest": "^19.0.0",
50-
"babel-preset-react-native": "^1.9.1",
51-
"jest": "^19.0.2",
52-
"lint-staged": "^3.4.0",
49+
"babel-eslint": "^8.0.1",
50+
"babel-jest": "^21.2.0",
51+
"babel-preset-react-native": "^4.0.0",
52+
"jest": "^21.2.1",
53+
"lint-staged": "^4.2.3",
5354
"pre-commit": "^1.2.2",
5455
"publish": "^0.6.0",
55-
"react": "^15.4.2",
56-
"react-test-renderer": "^15.4.2",
57-
"standard": "^10.0.2"
56+
"react": "^16.0.0",
57+
"react-test-renderer": "^16.0.0",
58+
"standard": "^10.0.3"
5859
}
5960
}

src/index.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export default class QRCode extends PureComponent {
2828
logoBackgroundColor: PropTypes.string,
2929
/* logo's distance to its wrapper */
3030
logoMargin: PropTypes.number,
31+
/* the border-radius of logo image */
32+
logoBorderRadius: PropTypes.number,
3133
/* get svg ref for further usage */
3234
getRef: PropTypes.func,
3335
/* error correction level */
@@ -91,36 +93,32 @@ export default class QRCode extends PureComponent {
9193
return d
9294
}
9395
renderLogo () {
94-
const {
95-
size,
96-
backgroundColor,
97-
logo,
98-
logoBackgroundColor = backgroundColor,
99-
logoSize = size * 0.2,
100-
logoMargin
101-
} = this.props
96+
const { size, backgroundColor, logo, logoBackgroundColor = backgroundColor,
97+
logoSize = size * 0.2, logoMargin, logoBorderRadius } = this.props
10298
const wrapSize = logoSize + logoMargin * 2
10399
const position = size / 2 - logoSize / 2 - logoMargin
104100

101+
const viewStyle = {
102+
backgroundColor: logoBackgroundColor,
103+
width: wrapSize,
104+
height: wrapSize,
105+
position: 'absolute',
106+
left: position,
107+
top: position,
108+
padding: logoMargin,
109+
borderRadius: logoBorderRadius,
110+
overflow: 'hidden'
111+
}
112+
113+
const imageStyle = {
114+
width: logoSize,
115+
height: logoSize
116+
}
117+
105118
return (
106-
<View
107-
style={{
108-
backgroundColor: logoBackgroundColor,
109-
width: wrapSize,
110-
height: wrapSize,
111-
position: 'absolute',
112-
left: position,
113-
top: position
114-
}}
115-
>
119+
<View style={viewStyle}>
116120
<Image
117-
style={{
118-
width: logoSize,
119-
height: logoSize,
120-
position: 'absolute',
121-
left: logoMargin,
122-
top: logoMargin
123-
}}
121+
style={imageStyle}
124122
source={logo}
125123
resizeMode='contain'
126124
/>

0 commit comments

Comments
 (0)