Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

bar code react native

import React, { Component } from 'react';import {Text,View,StyleSheet,Alert,TouchableOpacity,Image} from 'react-native';import Camera from 'react-native-camera';export default class BarcodeScan extends Component {constructor(props) {super(props);this.handleTourch = this.handleTourch.bind(this);this.state = {torchOn: false}}onBarCodeRead = (e) => {Alert.alert("Barcode value is" + e.data, "Barcode type is" + e.type);}render() {return (<View style={styles.container}><Camerastyle={styles.preview}torchMode={this.state.torchOn ? Camera.constants.TorchMode.on : Camera.constants.TorchMode.off}onBarCodeRead={this.onBarCodeRead}ref={cam => this.camera = cam}aspect={Camera.constants.Aspect.fill}><Text style={{backgroundColor: 'white'}}>BARCODE SCANNER</Text></Camera><View style={styles.bottomOverlay}><TouchableOpacity onPress={() => this.handleTourch(this.state.torchOn)}><Image style={styles.cameraIcon}source={this.state.torchOn === true ? require('../../images/flasher_on.png') : require('../../images/flasher_off.png')} /></TouchableOpacity></View></View>)}handleTourch(value) {if (value === true) {this.setState({ torchOn: false });} else {this.setState({ torchOn: true });}}}const styles = StyleSheet.create({container: {flex: 1,flexDirection: 'row',},preview: {flex: 1,justifyContent: 'flex-end',alignItems: 'center'},cameraIcon: {margin: 5,height: 40,width: 40},bottomOverlay: {position: "absolute",width: "100%",flex: 20,flexDirection: "row",justifyContent: "space-between"},});
Comment

PREVIOUS NEXT
Code Example
Javascript :: number and type operators in javascript 
Javascript :: The attribute name of [ *ngFor ] must be in lowercase.(attr-lowercase) in VSCode 
Javascript :: Amazon Cognito domain on amplify not pulling 
Javascript :: app.post isnt a function 
Javascript :: how to pass custom parameter onchage 
Javascript :: Get Multipal Tab Value to One App Script 
Javascript :: absolute sum javascript 
Javascript :: Multiple destinations with gulp js 
Javascript :: get raw sql query from codeigniter query builder 
Javascript :: nodejs string value check === and !== 
Javascript :: DeleteAsync 
Javascript :: vscode autosuggest background 
Javascript :: handle fetch error 
Javascript :: matmenu in angular 
Javascript :: change iphone return in keyboard to search in react native 
Javascript :: npm view parent package 
Javascript :: js get word before question mark 
Javascript :: react native map not loading 
Javascript :: how to calculate number with arithmetic operators in javascript 
Javascript :: turn any function into promise 
Javascript :: jquery top 20 function 
Javascript :: React custom hook refetch data 
Javascript :: convert componentDidUpdate into useEffect 
Javascript :: what does the syntax () = {} mean 
Javascript :: fb like image window js 
Javascript :: javascript map set shorthand 
Javascript :: this in js class method 
Javascript :: jsmodule not installed vuejs webstorm 
Javascript :: scrollto element by id 
Javascript :: javascript babel run 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =