Repository navigation
Expand file tree
/
Copy pathImagePickerComponent.js
More file actions
82 lines (75 loc) · 1.95 KB
/
Copy pathImagePickerComponent.js
File metadata and controls
82 lines (75 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import * as ImagePicker from 'expo-image-picker';
import React, { useState, useEffect } from 'react';
import { StyleSheet,Pressable,TouchableOpacity,Button,Dimensions, Image, View, Text,Alert } from 'react-native';
import callGoogleVisionAsync from "./helperFunctions.js";
const {height:SCREEN_HEIGHT, width:SCREEN_WIDTH} = Dimensions.get('window');
function ImagePickerComponent({onSubmit}) {
const pickImage = async () => {
let result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.All,
base64: true, //return base64 data.
});
if (!result.cancelled) { //if the user submits an image,
let ret= await callGoogleVisionAsync(result.base64);
onSubmit=await onSubmit(ret.text);
}
};
return (
<View>
<TouchableOpacity onPress={pickImage}>
<Text style={styles.blacktext}>갤러리에서 불러오기</Text>
</TouchableOpacity >
</View>
);
}
export default ImagePickerComponent;
const styles = StyleSheet.create({
main: {
flex:1,
backgroundColor: 'white',
},
rightView : {
flex: 1,
justifyContent: 'flex-end',
alignSelf: 'flex-end',
},
centeredView: {
flex: 1,
justifyContent: 'flex-end',
alignItems: 'center',
},
button: {
borderRadius: 20,
padding: 10,
elevation: 2,
},
buttonOpen: {
backgroundColor: '#F194FF',
},
buttonClose: {
backgroundColor: '#2196F3',
},
textStyle: {
color: 'white',
fontWeight: 'bold',
textAlign: 'center',
},
browseBtn : {
borderRadius: 20,
padding: 20,
elevation: 2,
backgroundColor: '#DADADA',
borderWidth: 1,
Stroke:'Solid #484848',
marginRight : 30,
marginTop : 100,
width : 200,
height : 40
},
blacktext : {
fontSize : 16,
color: 'black',
fontWeight: 'bold',
textAlign: 'center',
}
});