|
|
@ -0,0 +1,54 @@ |
|
|
|
import React from "react"; |
|
|
|
import { StyleSheet, Text, View, SafeAreaView, Image, Button } from "react-native"; |
|
|
|
import * as ImagePicker from "expo-image-picker"; |
|
|
|
import { useState, useEffect } from "react"; |
|
|
|
import * as Permissions from 'expo-permissions'; |
|
|
|
function LaunchCamera() { |
|
|
|
const [image, setImage] = useState(); |
|
|
|
|
|
|
|
const takePicture = async () => { |
|
|
|
await Permissions.askAsync(Permissions.CAMERA); |
|
|
|
const { cancelled, uri } = await ImagePicker.launchCameraAsync({ |
|
|
|
allowsEditing: false, |
|
|
|
}); |
|
|
|
setImage({ image: uri }); |
|
|
|
}; |
|
|
|
|
|
|
|
const handlePress = () => { |
|
|
|
takePicture(); |
|
|
|
}; |
|
|
|
|
|
|
|
return ( |
|
|
|
<View style={styles.container}> |
|
|
|
<Image style={styles.image} source={{ uri: image }} /> |
|
|
|
<View style={styles.row}> |
|
|
|
<Button title="Camera" onPress={handlePress} /> |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
const styles = StyleSheet.create({ |
|
|
|
container: { |
|
|
|
flex: 1, |
|
|
|
backgroundColor: '#ffffff', |
|
|
|
alignItems: 'center', |
|
|
|
justifyContent: 'center', |
|
|
|
}, |
|
|
|
text: { |
|
|
|
fontSize: 21, |
|
|
|
}, |
|
|
|
row: { |
|
|
|
flexDirection: 'row' |
|
|
|
}, |
|
|
|
image: { |
|
|
|
width: 300, height: 300, backgroundColor: 'gray' |
|
|
|
}, |
|
|
|
button: { |
|
|
|
padding: 13, |
|
|
|
margin: 15, |
|
|
|
backgroundColor: '#dddddd', |
|
|
|
}, |
|
|
|
}) |
|
|
|
|
|
|
|
export default LaunchCamera; |