Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react native qr code scanner

'use strict';

import React, { Component } from 'react';

import {
  AppRegistry,
  StyleSheet,
  Text,
  TouchableOpacity,
  Linking
} from 'react-native';

import QRCodeScanner from 'react-native-qrcode-scanner';
import { RNCamera } from 'react-native-camera';

class ScanScreen extends Component {
  onSuccess = e => {
    Linking.openURL(e.data).catch(err =>
      console.error('An error occured', err)
    );
  };

  render() {
    return (
      <QRCodeScanner
        onRead={this.onSuccess}
        flashMode={RNCamera.Constants.FlashMode.torch}
        topContent={
          <Text style={styles.centerText}>
            Go to{' '}
            <Text style={styles.textBold}>wikipedia.org/wiki/QR_code</Text> on
            your computer and scan the QR code.
          </Text>
        }
        bottomContent={
          <TouchableOpacity style={styles.buttonTouchable}>
            <Text style={styles.buttonText}>OK. Got it!</Text>
          </TouchableOpacity>
        }
      />
    );
  }
}

const styles = StyleSheet.create({
  centerText: {
    flex: 1,
    fontSize: 18,
    padding: 32,
    color: '#777'
  },
  textBold: {
    fontWeight: '500',
    color: '#000'
  },
  buttonText: {
    fontSize: 21,
    color: 'rgb(0,122,255)'
  },
  buttonTouchable: {
    padding: 16
  }
});

AppRegistry.registerComponent('default', () => ScanScreen);
Comment

PREVIOUS NEXT
Code Example
Javascript :: printing in javascript 
Javascript :: vuejs accessing props from data 
Javascript :: undefined value check in javascript 
Javascript :: angular number validation 
Javascript :: stringbuffer javascript 
Javascript :: material-ui add icon to switch when on 
Javascript :: how to change class by is in js by toggle 
Javascript :: javascript post 
Javascript :: map && arrow function in javascript 
Javascript :: javascript document get by attribute 
Javascript :: how to get country code in react native 
Javascript :: discord.js purge 
Javascript :: how to unfreeze object in javascript 
Javascript :: show uploaded image in react/nextjs 
Javascript :: js Destructuring in React 
Javascript :: running webpack application on production server 
Javascript :: add new value to array of object javascript using spread 
Javascript :: append to array in js 
Javascript :: mdn javascript 
Javascript :: js parse bool 
Javascript :: break loop timeout javascript 
Javascript :: pattern printing in javascript 
Javascript :: eliminar duplicados javascript 
Javascript :: browser support fetch api 
Javascript :: vue js multiple dynamic classes 
Javascript :: function syntax js 
Javascript :: JS copy image 
Javascript :: nextjs use dotnenv 
Javascript :: vuejs cordoba pantalla en blanco 
Python :: pandemonium 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =