Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

easyqrcode-react-native

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easyqrcode-react-native

React Native QRCode generation component. Can get standard base64 image data url text or save image to file. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.

  • 4.0.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

EasyQRCode React Native

A QRCode component for React Native. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support Angular, Vue.js, React, Next.js framework. Support binary(hex) data mode.

Table of contents

Choose what you need

ProjectSupport
EasyQRCodeJSRunning with DOM on CLIENT-SIDE . Browser(IE6+, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.), Electron, NW.js, ETC.
EasyQRCodeJS-NodeJSRunning without DOM on SERVER-SIDE. Save image to file(PNG/JPEG/SVG) or get data url text. NodeJS, Electron, NW.js, ETC.
EasyQRCode-React-NativeA QRCode generator for React Native. Generate QRCode image or get base64 data url text.

Feature

  • English

    • Required Patterns that support dot style

    • Support unicode character set: 😊❤️👍👨‍💻 Hello, こんにちは, こんにちは, Γεια, Привет, नमस्ते, สวัสดี, Привіт, سلام, Здравей, ສະບາຍດີ, Përshëndetje, Բարեւ, 你好

    • Support for Quiet Zone settings

    • Support custom Position Pattern inner fill and outer border color

    • Support custom Alignment Pattern inner fill and outer border color

    • Support custom Timing Patterns vertical, horizontal color

    • Support Logo images (including transparent PNG images)

    • Support Background Image

    • Support for title, subtitle settings

    • Support binary(hex) data mode

    • Support TypeScript

  • 中文

    • 支持点形风格的 Required Patterns

    • 支持 Unicode 字符集: 😊❤️👍👨‍💻 Hello, こんにちは, こんにちは, Γεια, Привет, नमस्ते, สวัสดี, Привіт, سلام, Здравей, ສະບາຍດີ, Përshëndetje, Բարեւ, 你好

    • 支持 Quiet Zone 设置

    • 支持自定义 Position Pattern 内填充和外边框颜色

    • 支持自定义 Alignment Pattern 内填充和外边框颜色

    • 支持自定义 Timing Patterns 垂直,水平颜色

    • 支持 Logo 图片(包括背景透明的 PNG 图片)

    • 支持 Background Image 背景图片

    • 支持标题,副标题设置

    • 二进制数据模式支持

    • TypeScript 支持

Try It!

Try It!

Demo preview

Demo preview

QR Code Structure

QR Code Structure

Installation

npm install react-native-webview
react-native link react-native-webview

npm install easyqrcode-react-native

Basic Usages

import React, { Component } from 'react';
import {
  View
} from 'react-native';

// 1. Import 
import {QRCode, Canvas} from 'easyqrcode-react-native';

class App extends  Component{
    
    // 3. Generate QRCode
    generateQRCode = (canvas) => {
        if (canvas !== null){
            // QRCode options
            var options = {
                text: "www.easyproject.cn/donation",
        	};
        	// Create QRCode Object
        	var qrCode = new QRCode(canvas, options);
        }
      }
    
   render() { 
      return (
          <View>
            {/* 2. QRCode Canvas  */}
            <Canvas ref={this.generateQRCode}/>
          </View>
      );
  }
};

export default App;

QRCode API

Object

var qrcode = new QRCode(canvas_object, options_object);

Options

 var options_object = {
    // ====== Basic
    text: "https://github.com/ushelp/EasyQRCodeJS",
    width: 256,
    height: 256,
    colorDark : "#000000",
    colorLight : "#ffffff",
    correctLevel : QRCode.CorrectLevel.H, // L, M, Q, H
    
    // ====== dotScale
    /*
    dotScale: 1, // For body block, must be greater than 0, less than or equal to 1. default is 1
    
    dotScaleTiming: 1, // Dafault for timing block , must be greater than 0, less than or equal to 1. default is 1
    dotScaleTiming_H: undefined, // For horizontal timing block, must be greater than 0, less than or equal to 1. default is 1
    dotScaleTiming_V: undefined, // For vertical timing block, must be greater than 0, less than or equal to 1. default is 1
    
    dotScaleA: 1, // Dafault for alignment block, must be greater than 0, less than or equal to 1. default is 1
    dotScaleAO: undefined, // For alignment outer block, must be greater than 0, less than or equal to 1. default is 1
    dotScaleAI: undefined, // For alignment inner block, must be greater than 0, less than or equal to 1. default is 1
    */
   
    // ====== Quiet Zone
    /*
    quietZone: 0,
    quietZoneColor: "rgba(0,0,0,0)",
    */

    // ====== Logo
    /*
    logo: "https://avatars1.githubusercontent.com/u/4082017?s=160&v=4",  //  support: Static Image Resources, Network Images, Base64 Uri Data Images
    logoWidth: 80, // fixed logo width. default is `width/3.5`
    logoHeight: 80, // fixed logo height. default is `heigth/3.5`
    logoMaxWidth: undefined, // Maximum logo width. if set will ignore `logoWidth` value
    logoMaxHeight: undefined, // Maximum logo height. if set will ignore `logoHeight` value
    logoBackgroundColor: '#fffff', // Logo backgroud color, Invalid when `logBgTransparent` is true; default is '#ffffff'
    logoBackgroundTransparent: false, // Whether use transparent image, default is false
    */

    // ====== Backgroud Image
    /*
    backgroundImage: '', // support: Static Image Resources, Network Images, Base64 Uri Data Images
    backgroundImageAlpha: 1, // Background image transparency, value between 0 and 1. default is 1. 
    autoColor: false, // Automatic color adjustment(for data block)
    autoColorDark: "rgba(0, 0, 0, .6)", // Automatic color: dark CSS color
    autoColorLight: "rgba(255, 255, 255, .7)", // Automatic color: light CSS color
    */
    
    // ====== Colorful
    // === Posotion Pattern(Eye) Color
    /*
    PO: '#e1622f', // Global Posotion Outer color. if not set, the defaut is `colorDark`
    PI: '#aa5b71', // Global Posotion Inner color. if not set, the defaut is `colorDark`
    PO_TL:'', // Posotion Outer color - Top Left 
    PI_TL:'', // Posotion Inner color - Top Left 
    PO_TR:'', // Posotion Outer color - Top Right 
    PI_TR:'', // Posotion Inner color - Top Right 
    PO_BL:'', // Posotion Outer color - Bottom Left 
    PI_BL:'', // Posotion Inner color - Bottom Left 
    */
    // === Alignment Color
    /*
    AO: '', // Alignment Outer. if not set, the defaut is `colorDark`
    AI: '', // Alignment Inner. if not set, the defaut is `colorDark`
    */
    // === Timing Pattern Color
    /*
    timing: '#e1622f', // Global Timing color. if not set, the defaut is `colorDark`
    timing_H: '', // Horizontal timing color
    timing_V: '', // Vertical timing color
    */
    
    // ====== Title
    /*
    title: 'QR Title', // content 
    titleFont: "normal normal bold 18px Arial", //font. default is "bold 16px Arial"
    titleColor: "#004284", // color. default is "#000"
    titleBackgroundColor: "#fff", // background color. default is "#fff"
    titleHeight: 70, // height, including subTitle. default is 0
    titleTop: 25, // draws y coordinates. default is 30
    */
   
    // ====== SubTitle
    /*
    subTitle: 'QR subTitle', // content
    subTitleFont: "normal normal normal 14px Arial", // font. default is "14px Arial"
    subTitleColor: "#004284", // color. default is "4F4F4F"
    subTitleTop: 40, // draws y coordinates. default is 0
    */
   
    // ===== Event Handler
    /*
    onRenderingStart: undefined,
    onRenderingEnd: undefined,
    */
   
    // ===== Versions
    /*
    version: 0, // The symbol versions of QR Code range from Version 1 to Version 40. default 0 means automatically choose the closest version based on the text length.
    */     
   
    // ===== Binary(hex) data mode
    /*
    binary: false, // Whether it is binary mode, default is text mode. 
    */ 
   
    // =====  UTF-8 without BOM
    /*
    utf8WithoutBOM: true
    */      
}
OptionRequiredTypeDefaultsDescription
Basic options------------
textYString''Text
widthNNumber256Width
heightNNumber256Height
colorDarkNString#000000Dark CSS color, rgba(0,0,0,0)
colorLightNString#ffffffLight CSS color, rgba(0,0,0,0)
correctLevelNEnumQRCode.CorrectLevel.HQRCode.CorrectLevel.H
QRCode.CorrectLevel.Q
QRCode.CorrectLevel.M
QRCode.CorrectLevel.L
dotScaleNNumber1.0Dot style required Patterns. Ranges: 0-1.0
Dot style------------
dotScaleNNumber1.0Dot style scale. Ranges: 0-1.0
dotScaleTimingNNumber1.0Dot style scale for timing. Ranges: 0-1.0
dotScaleTiming_VNNumberundefinedDot style scale for horizontal timing. Ranges: 0-1.0
dotScaleTiming_HNNumberundefinedDot style scale for vertical timing. Ranges: 0-1.0
dotScaleANNumber1.0Dot style scale for alignment. Ranges: 0-1.0
dotScaleAONNumberundefinedDot style scale for alignment outer. Ranges: 0-1.0
dotScaleAINNumberundefinedDot style scale for alignment inner. Ranges: 0-1.0
Quiet Zone------------
quietZoneNNumber0Quiet Zone size
quietZoneColorNStringrgba(0,0,0,0)Background CSS color to Quiet Zone
Logo options------------
logoNStringundefinedsupport: Static Image Resources, Network Images(http://, https://, ftp://), Base64 Uri Data Images
logoWidthNNumberwidth/3.5Fixed logo width.
logoHeightNNumberheight/3.5fixed logo height.
logoMaxWidthNNumberundefinedMaximum logo width. if set will ignore logoWidth value.
logoMaxHeightNNumberundefinedMaximum logo height. if set will ignore logoHeight value.
logoBackgroundTransparentNBooleanfalseWhether the background transparent image(PNG) shows transparency. When true, logoBackgroundColor is invalid
logoBackgroundColorNString#ffffffSet Background CSS Color when image background transparent. Valid when logoBackgroundTransparent is false
Backgroud Image options------------
backgroundImageNStringundefinedBackground Image Path or Base64 encoded Image. If use relative address, relative to easy.qrcode.min.js
backgroundImageAlphaNNumber1.0Background image transparency. Ranges: 0-1.0
autoColorNBooleanfalseAutomatic color adjustment(for data block)
autoColorDarkNStringrgba(0, 0, 0, .6)Automatic color: dark CSS color
autoColorLightNStringrgba(255, 255, 255, .7)Automatic color: light CSS color
Posotion Pattern Color options------------
PONStringundefinedGlobal Posotion Outer CSS color. if not set, the defaut is colorDark
PINStringundefinedGlobal Posotion Inner CSS color. if not set, the defaut is colorDark
PO_TLNStringundefinedPosotion Outer CSS color - Top Left
PI_TLNStringundefinedPosotion Inner CSS color - Top Left
PO_TRNStringundefinedPosotion Outer CSS color - Top Right
PI_TRNStringundefinedPosotion Inner CSS color - Top Right
PO_BLNStringundefinedPosotion Outer CSS color - Bottom Left
PI_BLNStringundefinedPosotion Inner CSS color - Bottom Left
Alignment Color options------------
AONStringundefinedAlignment Outer CSS color. if not set, the defaut is colorDark
AINStringundefinedAlignment Inner CSS color. if not set, the defaut is colorDark
Timing Pattern Color options------------
timingNStringundefinedGlobal Timing CSS color. if not set, the defaut is colorDark
timing_HNStringundefinedHorizontal timing CSS color
timing_VNStringundefinedVertical timing CSS color
Title options------------
titleNString''
titleFontNStringnormal normal bold 16px ArialCSS Font
titleColorNString#000000CSS color
titleBackgroundColorNString#ffffffCSS color
titleHeightNNumber0Title Height, Include subTitle
titleTopNNumber30draws y coordinates.
SubTitle options------------
subTitleNString''
subTitleFontNStringnormal normal normal 14px ArialCSS Font
subTitleColorNString#4F4F4FCSS color
subTitleTopNNumber0draws y coordinates. default is 0
Event Handler options------------
onRenderingStart(qrCodeOptions)NFunctionundefinedCallback function when the rendering start. can use to hide loading state or handling.
onRenderingEnd(qrCodeOptions, base64DataFn)NFunctionundefinedCallback function when the rendering ends. base64DataFn parameter is the base64 data execution function of QRCode, returns a Promise that resolves to DataURL.
Version options------------
versionNNumber0The symbol versions of QR Code range from Version 1 to Version 40. default 0 means automatically choose the closest version based on the text length. Information capacity and versions of QR Codes NOTE: If you set a value less than the minimum version available for text, the minimum version is automatically used.
Tooltip options------------
tooltipNBooleanfalseWhether set the QRCode Text as the title attribute value of the QRCode div.
UTF-8 options------------
utf8WithoutBOMNBooleantrueUse UTF-8 without BOM. set to false value will use BOM in UFT-8.
Binary(hex) data model options------------
binaryNBooleanfalseWhether it is binary mode, default is text mode.

Method

  • makeCode(text)

    qrcode.makeCode("https://github.com/ushelp/EasyQRCodeJS"); // make another code text.
    

How to load Images?

You can use Static Image Resources, Network Images, Base64 Data Uri Resources to load images.

// Static Image Resources
const logoImage = Image.resolveAssetSource(require('./logo.png')).uri;

// Network Images
const logoImage = "https://avatars1.githubusercontent.com/u/4082017?s=160&v=4";

// Base64 Data Uri Resources
const logoImage = "data:image/png;base64,iVBORw0KGgoAAAAN...";

var options = {
    // ...
    logo: logoImage

    // ...
}

Get Base64 data of QRCode

Use onRenderingEnd(qrCodeOptions, base64DataFn) to get Base64 data url of the QRCode. base64DataFn parameter is the base64 data execution function of QRCode, returns a Promise that resolves to DataURL.

var options = {
    
    // ...
    
    onRenderingEnd: function(qrCodeOptions, base64DataFn){
        
        base64DataFn().then(base64DataURL=>{
            console.log(base64DataURL);
        })
        
    }
    
    // ...
} 

If you encounter Tainted canvases may not be exported error. Please convert your images(logo, background, ...) to Base64 Data URL.

Error: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

License

MIT License

EasyQRCode-React-Native-Premium

Let you draw freely!

EasyQRCodeJS-Premium is a more powerful and comprehensive enterprise version. You can use Canvas to customize any element, such as eye frame shape, eyeball shape, QR code block shape, and more. Also supports excavation (to prevent the QRcode overlap with the logo), random block mode.

If you need more functions, we can provide you with customized development of API libraries or products. please contact me to buy the business enterprise edition.

EasyQRCodeJS-Premium 是功能更加强大和全面的商业/企业版本。让您可以在 QRCode 中通过 Canvas 自定义任何喜欢的元素,例如 Eye frame 形状, Eye ball 形状, QR Body block 形状等等。 还支持 Logo 挖取(excavation,防止二维码与 Logo 重叠)和 Random bolock mode.

如果您需要更多功能,我们可以为您提供 API 库或产品的定制开发。请联系我购买商业/企业版本。

Premium demo preview

End

Email:inthinkcolor@gmail.com

http://www.easyproject.cn

Donation/捐助:


支付宝/微信/QQ/云闪付/PayPal 扫码支付
支付宝/微信/QQ/云闪付/PayPal

我们相信,每个人的点滴贡献,都将是推动产生更多、更好免费开源产品的一大步。

感谢慷慨捐助,以支持服务器运行和鼓励更多社区成员。

We believe that the contribution of each bit by bit, will be driven to produce more and better free and open source products a big step.

Thank you donation to support the server running and encourage more community members.

Keywords

FAQs

Package last updated on 05 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc