ソースを参照

auto commit

app
jfinn 3年前
コミット
d27861086f
1個のファイルの変更69行の追加6行の削除
  1. 69
    6
      mdev/rn_cam.native.js

+ 69
- 6
mdev/rn_cam.native.js ファイルの表示

@@ -1,12 +1,75 @@
1
+import React, { PureComponent } from 'react';
2
+import { AppRegistry, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
+import { RNCamera } from 'react-native-camera';
1 4
 
5
+class ExampleApp extends PureComponent {
6
+  render() {
2 7
 
8
+  	var rn_cam_styles = tglob_au.run_dev_cbs("rn_cam_styles",{that:this}) || {}
9
+    return (
10
+      <View style={rn_cam_styles.container || {}}>
11
+        <RNCamera
12
+          ref={ref => {
13
+            this.camera = ref;
14
+          }}
15
+          style={rn_cam_styles.preview}
16
+          type={RNCamera.Constants.Type.back}
17
+          flashMode={RNCamera.Constants.FlashMode.on}
18
+          androidCameraPermissionOptions={{
19
+            title: 'Permission to use camera',
20
+            message: 'We need your permission to use your camera',
21
+            buttonPositive: 'Ok',
22
+            buttonNegative: 'Cancel',
23
+          }}
24
+          androidRecordAudioPermissionOptions={{
25
+            title: 'Permission to use audio recording',
26
+            message: 'We need your permission to use your audio',
27
+            buttonPositive: 'Ok',
28
+            buttonNegative: 'Cancel',
29
+          }}
30
+          onGoogleVisionBarcodesDetected={({ barcodes }) => {
31
+            console.log(barcodes);
32
+          }}
33
+        />
34
+        <View style={{ flex: 0, flexDirection: 'row', justifyContent: 'center' }}>
35
+          <TouchableOpacity onPress={this.takePicture.bind(this)} style={rn_cam_styles.capture}>
36
+            <Text style={{ fontSize: 14 }}> SNAP </Text>
37
+          </TouchableOpacity>
38
+        </View>
39
+      </View>
40
+    );
41
+  }
3 42
 
43
+  takePicture = async () => {
44
+    if (this.camera) {
45
+      const options = { quality: 0.5, base64: true };
46
+      const data = await this.camera.takePictureAsync(options);
47
+      console.log(data.uri);
48
+    }
49
+  };
50
+}
4 51
 
52
+const styles = StyleSheet.create({
53
+  container: {
54
+    flex: 1,
55
+    flexDirection: 'column',
56
+    backgroundColor: 'black',
57
+  },
58
+  preview: {
59
+    flex: 1,
60
+    justifyContent: 'flex-end',
61
+    alignItems: 'center',
62
+  },
63
+  capture: {
64
+    flex: 0,
65
+    backgroundColor: '#fff',
66
+    borderRadius: 5,
67
+    padding: 15,
68
+    paddingHorizontal: 20,
69
+    alignSelf: 'center',
70
+    margin: 20,
71
+  },
72
+});
5 73
 
6
-console.log("RN_CAM")
7 74
 
8
-console.log("RN_CAM2")
9
-
10
-
11
-
12
-export {}
75
+export {ExampleApp}

読み込み中…
キャンセル
保存