Skip to content

Commit 4720135

Browse files
committed
Add logoBorderRadius
1 parent 1fec0f8 commit 4720135

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
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

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)