forked from cemaden-educacao/WPD-MobileApp
analuizaff
4 years ago
3 changed files with 43 additions and 78 deletions
@ -1,57 +0,0 @@ |
|||||
import React from "react"; |
|
||||
import { StyleSheet, Text, View, SafeAreaView, Image, Button, TouchableWithoutFeedback } from "react-native"; |
|
||||
import * as ImagePicker from "expo-image-picker"; |
|
||||
import { useState, useEffect } from "react"; |
|
||||
import * as Permissions from 'expo-permissions'; |
|
||||
import colors from "../config/colors"; |
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons"; |
|
||||
|
|
||||
function LaunchCamera() { |
|
||||
const [imageUri, setImageUri] = useState(null); |
|
||||
|
|
||||
const takePicture = async () => { |
|
||||
await Permissions.askAsync(Permissions.CAMERA); |
|
||||
const { cancelled, uri } = await ImagePicker.launchCameraAsync({ |
|
||||
allowsEditing: false, |
|
||||
}); |
|
||||
setImageUri(uri); |
|
||||
}; |
|
||||
|
|
||||
const handlePress = () => { |
|
||||
takePicture(); |
|
||||
}; |
|
||||
|
|
||||
return ( |
|
||||
<TouchableWithoutFeedback onPress={handlePress}> |
|
||||
<View style={styles.container}> |
|
||||
{!imageUri && ( |
|
||||
<MaterialCommunityIcons |
|
||||
color={colors.medium} |
|
||||
name="camera-plus" |
|
||||
size={40} |
|
||||
/> |
|
||||
)} |
|
||||
{imageUri && <Image source={{ uri: imageUri }} style={styles.image} />} |
|
||||
</View> |
|
||||
</TouchableWithoutFeedback> |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
const styles = StyleSheet.create({ |
|
||||
container: { |
|
||||
alignItems: "center", |
|
||||
backgroundColor: colors.light, |
|
||||
borderRadius: 15, |
|
||||
height: 100, |
|
||||
justifyContent: "center", |
|
||||
marginVertical: 10, |
|
||||
overflow: "hidden", |
|
||||
width: 100, |
|
||||
}, |
|
||||
image: { |
|
||||
height: "100%", |
|
||||
width: "100%", |
|
||||
}, |
|
||||
}); |
|
||||
|
|
||||
export default LaunchCamera; |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue