1.1.3 • Published 2 years ago

react-native-qr-code-styling v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Native QR Code Styling

Version

React Native library for generating QR codes with a logo and styling based on qr-code-styling

If you have issues / suggestions / notes / questions, please open an issue or contact me. Let's create a cool library together.

Examples

Installation

npm install react-native-qr-code-styling

Usage

import QRGenerator from 'react-native-qr-code-styling'

const viewDataBase64 = (e: string) => {};
<QRGenerator
  width={300}
  height={300}
  type={'svg'}
  value="https://github.com/huytrinh68/react-native-qr-code-styling"
  dotOptions={{
    type: 'classy-rounded',
    color: 'green',
    gradient: {
      type: 'linear',
      rotation: 100,
      colorStops: [
        {offset: 0, color: '#845EC2'},
        {offset: 0.8, color: '#0081CF'},
        {offset: 1, color: '#008F7A'},
      ],
    },
  }}
  cornerDotOptions={{
    type: 'dots',
    gradient: {
      type: 'linear',
      rotation: 100,
      colorStops: [
        {offset: 0, color: '#845EC2'},
        {offset: 0.8, color: '#0081CF'},
        {offset: 1, color: '#008F7A'},
      ],
    },
  }}
  cornerSquareOptions={{
    type: 'extra-rounded',
    gradient: {
      type: 'linear',
      rotation: 100,
      colorStops: [
        {offset: 0, color: '#845EC2'},
        {offset: 0.8, color: '#0081CF'},
        {offset: 1, color: '#008F7A'},
      ],
    },
  }}
  backgroundOptions={{
    color: 'transparent',
  }}
  getBase64DataImage={viewDataBase64}
  image={
    'https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Instagram-Icon.png/1025px-Instagram-Icon.png'
  }
  imageOptions={{hideBackgroundDots: false, imageSize: 0.5, margin: 0}}
/>

API Documentation

This document follows the original documentation created by Denys Kozak. Please refer to the original version for further details.

PropertyTypeDefault ValueDescription
widthnumber300Size of canvas
heightnumber300Size of canvas
typestring ('canvas' 'svg')canvasThe type of the element that will be rendered
datastringThe date will be encoded to the QR code
imagestringThe image will be copied to the center of the QR code
qrOptionsobjectOptions will be passed to qrcode-generator lib
imageOptionsobjectSpecific image options, details see below
dotOptionsobjectDots styling options
cornersSquareOptionsobjectSquare in the corners styling options
cornerDotOptionsobjectDots in the corners styling options
backgroundOptionsobjectQR background styling options

qrOptions structure

PropertyTypeDefault Value
typeNumbernumber (0 - 40)0
modestring ('Numeric' 'Alphanumeric' 'Byte' 'Kanji')
errorCorrectionLevelstring ('L' 'M' 'Q' 'H')'Q'

imageOptions structure

PropertyTypeDefault ValueDescription
hideBackgroundDotsbooleantrueHide all dots covered by the image
imageSizenumber0.4Coefficient of the image size. Not recommended to use ove 0.5. Lower is better
marginnumber0Margin of the image in px
crossOriginstring('anonymous' 'use-credentials')Set "anonymous" if you want to download QR code from other origins.

dotsOptions structure

PropertyTypeDefault ValueDescription
colorstring'#000'Color of QR dots
gradientobjectGradient of QR dots
typestring ('rounded' 'dots' 'classy' 'classy-rounded' 'square' 'extra-rounded')'square'Style of QR dots

backgroundOptions structure

PropertyTypeDefault Value
colorstring'#fff'
gradientobject

cornersSquareOptions structure

PropertyTypeDefault ValueDescription
colorstringColor of Corners Square
gradientobjectGradient of Corners Square
typestring ('dot' 'square' 'extra-rounded')Style of Corners Square

cornersDotOptions structure

PropertyTypeDefault ValueDescription
colorstringColor of Corners Dot
gradientobjectGradient of Corners Dot
typestring ('dot' 'square')Style of Corners Dot

Gradient structure

dotOptions.gradient

backgroundOptions.gradient

cornersSquareOptions.gradient

cornersDotOptions.gradient

PropertyTypeDefault ValueDescription
typestring ('linear' 'radial')"linear"Type of gradient spread
rotationnumber0Rotation of gradient in radians (Math.PI === 180 degrees)
colorStopsarray of objectsGradient colors. Example [{ offset: 0, color: 'blue' }, { offset: 1, color: 'red' }]

Gradient colorStops structure

dotOptions.gradient.colorStops[]

backgroundOptions.gradient.colorStops[]

cornersSquareOptions.gradient.colorStops[]

cornersDotOptions.gradient.colorStops[]

PropertyTypeDefault ValueDescription
offsetnumber (0 - 1)Position of color in gradient range
colorstringColor of stop in gradient range

QRGenerator methods

`QRGenerator.getBase64DataImage() => string

ParamTypeDefault ValueDescription
base64stringData of QR Code as base64

License

MIT License. Copyright (c) 2023 Huy Trinh

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago