-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
139 lines (124 loc) · 2.74 KB
/
App.js
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import React ,{useState}from 'react';
import {
StyleSheet,
Image,
TouchableOpacity,
Button,
View,
Text,
} from 'react-native';
import {RNCamera}from "react-native-camera"
const PendingView = () =>(
<View
style={{
flex: 1,
justifyContent: "center",
alignItems:'center',
}}
>
<Text style={{fontSize:30, color:'red'}}> Loding...</Text>
</View>
)
const App = () =>{
const [image,setImage] = useState(null)
const takePicture = async (camera) =>{
try{
const options = {quality: 0.9,base64: false}
const data = await camera.takePictureAsync()
setImage(data.uri)
} catch (error){
console.warn(error)
}
}
return(
<>
<View style={styles.container}>
{image?(
<View style={styles.prew}>
<Text style={styles.camtext}>Here Is Your New Profile Pic</Text>
<Image style={styles.clicked}
source={{uri: image,width:'100%'}}/>
<Button
title="Click NewImage"
onPress={() =>{
setImage(null)
}}
/>
</View>
):(
<RNCamera
style={styles.prew}
type={RNCamera.Constants.Type.front}
captureAudio={false}
flashMode={RNCamera.Constants.FlashMode.on}
androidCameraPermissionOptions={{
title:'permission to use camera',
message:'longer text to use camera',
buttonPositive:'Ok',
buttonNegative: "Cancel",
}}
androidRecordAudioPermissionOptions={{
title:'permission to use audio',
message:'longer text to use audio',
buttonPositive:'Ok',
buttonNegative: "Cancel",
}}
>
{({camera,status})=>{
if(status !== 'READY') return <PendingView/>
return(
<View
style={{
flex:0,
flexDirection:'row',
justifyContent:'center'
}}
>
<TouchableOpacity
style={styles.capture}
onPress={() => takePicture(camera)}
>
<Text>SNAP</Text>
</TouchableOpacity>
</View>
)
}}
</RNCamera>
)}
</View>
</>
)
}
export default App;
const styles = StyleSheet.create({
container:{
flex: 1,
flexDirection:'column',
backgroundColor:'#006266'
},
prew:{
flex:1,
justifyContent:'space-around',
alignItems:"center"
},
capture:{
flex:0,
backgroundColor:'#6F1E51',
alignSelf:'center',
padding: 20
},
camtext:{
backgroundColor:'#353b48',
color:'#e1b12c',
marginBottom: 10,
width:'100%',
textAlign:'center',
paddingVertical:20,
fontSize:20,
},
clicked:{
width:300,
height:300,
borderRadius:150,
}
})