12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import React, { PureComponent } from 'react';
- import { AppRegistry, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
- import { RNCamera } from 'react-native-camera';
-
- class ExampleApp extends PureComponent {
- render() {
-
- var rn_cam_styles_z = tglob_au.run_dev_cbs("rn_cam_styles",{that:this}) || {}
- var rn_cam_styles = rn_cam_styles_z.o
- return (
- <View style={rn_cam_styles.container || {}}>
- <RNCamera
- ref={ref => {
- this.camera = ref;
- }}
- style={rn_cam_styles.preview}
- type={RNCamera.Constants.Type.back}
- flashMode={RNCamera.Constants.FlashMode.on}
- androidCameraPermissionOptions={{
- title: 'Permission to use camera',
- message: 'We need your permission to use your camera',
- buttonPositive: 'Ok',
- buttonNegative: 'Cancel',
- }}
- androidRecordAudioPermissionOptions={{
- title: 'Permission to use audio recording',
- message: 'We need your permission to use your audio',
- buttonPositive: 'Ok',
- buttonNegative: 'Cancel',
- }}
- onGoogleVisionBarcodesDetected={({ barcodes }) => {
- console.log(barcodes);
- }}
- />
- <View style={{ flex: 0, flexDirection: 'row', justifyContent: 'center' }}>
- <TouchableOpacity onPress={this.takePicture.bind(this)} style={rn_cam_styles.capture}>
- <Text style={{ fontSize: 14 }}> SNAP </Text>
- </TouchableOpacity>
- </View>
- </View>
- );
- }
-
- takePicture = async () => {
- if (this.camera) {
- const options = { quality: 0.5, base64: true };
- const data = await this.camera.takePictureAsync(options);
- console.log(data.uri);
- }
- };
- }
-
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- flexDirection: 'column',
- backgroundColor: 'black',
- },
- preview: {
- flex: 1,
- justifyContent: 'flex-end',
- alignItems: 'center',
- },
- capture: {
- flex: 0,
- backgroundColor: '#fff',
- borderRadius: 5,
- padding: 15,
- paddingHorizontal: 20,
- alignSelf: 'center',
- margin: 20,
- },
- });
-
-
- export {ExampleApp}
|