Skip to content
This repository has been archived by the owner on Dec 11, 2018. It is now read-only.

It does not support QR Scanning in Android #4

Open
blacksunset opened this issue May 10, 2016 · 7 comments
Open

It does not support QR Scanning in Android #4

blacksunset opened this issue May 10, 2016 · 7 comments

Comments

@blacksunset
Copy link

Is there any solution ?

@bendellarocco
Copy link

+1

@jorry
Copy link

jorry commented May 15, 2016

undefined is not an object(evaluating 'CameraManger.Aspect')
how to fix it?

@ackdav
Copy link

ackdav commented Jul 8, 2016

is this issue still open?

@Cell--
Copy link

Cell-- commented Jul 28, 2016

first, you should read the 'react-native-camera' README.md
second, you should change ES5 toES6.

@Cell--
Copy link

Cell-- commented Jul 28, 2016

// this is Usage

import React, {
Component,

}from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TouchableOpacity,
NavigatorIOS,
} from 'react-native'
//var React = require('react-native');
//var {
// AppRegistry,
// StyleSheet,
// Text,
// View,
// TouchableOpacity,
// NavigatorIOS,
//} = React;

import QRCodeScreen from './QRCodeScreen';

//var QRCodeScreen = require('./QECodeScreen');

class YourComponent extends React.Component {
render() {
return (
<NavigatorIOS
style={styles.container}
initialRoute={{
title: 'Index',
backButtonTitle: 'Back',
component: Index,
}}
/>
);
}
};

class Index extends React.Component{

render() {
return (


Read QRCode


);
}

_onPressQRCode = () => {
this.props.navigator.push({
component: QRCodeScreen,
title: 'QRCode',
passProps: {
onSucess: this._onSucess,
},
});
}

_onSucess = (result) => {
console.log(result);
}

};

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F5FCFF',
},
contentContainer: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});

AppRegistry.registerComponent('YourComponent', () => YourComponent);

@Cell--
Copy link

Cell-- commented Jul 28, 2016

//this is QRCodeScreen.js

'use strict';

import React, {
Component,
}from 'react'

import {
StyleSheet,
View,
Text,
TouchableOpacity,
Vibration,
NavigatorIOS
} from 'react-native'

//var React = require('react-native');
//
//var {
// StyleSheet,
// View,
// Text,
// TouchableOpacity,
// VibrationIOS,
//} = React;

import Camera from 'react-native-camera';

export default class QRCodeScreen extends Component

{

static propTypes= {
cancelButtonVisible: React.PropTypes.bool,
cancelButtonTitle: React.PropTypes.string,
onSucess: React.PropTypes.func,
onCancel: React.PropTypes.func
}

static getDefaultProps= {

  cancelButtonVisible: false,
  cancelButtonTitle: 'Cancel'

}

_onPressCancel() {
var $this = this;
requestAnimationFrame(function() {
$this.props.navigator.pop();
if ($this.props.onCancel) {
$this.props.onCancel();
}
});
}

_onBarCodeRead = (result) => {
console.log('123234');
var $this = this;

if (this.barCodeFlag) {
  this.barCodeFlag = false;

  setTimeout(function() {
    Vibration.vibrate();
    $this.props.navigator.pop();
    $this.props.onSucess(result.data);
  }, 1000);
}

}

render(){
var cancelButton = null;
this.barCodeFlag = true;

if (this.props.cancelButtonVisible) {
  cancelButton = <CancelButton onPress={this._onPressCancel} title={this.props.cancelButtonTitle} />;
}

return (
  <Camera onBarCodeRead={this._onBarCodeRead} style={styles.camera}>
    <View style={styles.rectangleContainer}>
      <View style={styles.rectangle}/>
    </View>
    <CancelButton/>
  </Camera>
);

}
}

class CancelButton extends React.Component
{
render() {
return (


{this.props.title}


);
}
}
const styles = StyleSheet.create
({

camera: {
height: 568,
alignItems: 'center',
},

rectangleContainer: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'transparent',
},

rectangle: {
height: 250,
width: 250,
borderWidth: 2,
borderColor: '#00FF00',
backgroundColor: 'transparent',
},

cancelButton: {
//flexDirection: 'row',
justifyContent: 'center',
backgroundColor: 'white',
borderRadius: 3,
padding: 15,
width: 100,
bottom: 10,
height: 30,
},
cancelButtonText: {
fontSize: 17,
fontWeight: '500',
color: '#0097CE',
},
});

@Cell--
Copy link

Cell-- commented Jul 28, 2016

QRCodeScreen.js.zip

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants