|
|
@ -1,4 +1,4 @@ |
|
|
|
import React, { useEffect } from "react"; |
|
|
|
import React, { useEffect, useState } from "react"; |
|
|
|
import { |
|
|
|
View, |
|
|
|
StyleSheet, |
|
|
@ -12,12 +12,11 @@ import { |
|
|
|
import { MaterialCommunityIcons } from "@expo/vector-icons"; |
|
|
|
import * as ImagePicker from "expo-image-picker"; |
|
|
|
import colors from "../config/colors"; |
|
|
|
import { useState } from "react/cjs/react.development"; |
|
|
|
|
|
|
|
function ImageInput({ imageUri, onChangeImage }) { |
|
|
|
useEffect(() => { |
|
|
|
requestPermission(); |
|
|
|
requestPermissionCamera(); |
|
|
|
//requestPermissionCamera();
|
|
|
|
}, []); |
|
|
|
const [modalVisible, setModalVisible] = useState(false); |
|
|
|
|
|
|
@ -27,7 +26,10 @@ function ImageInput({ imageUri, onChangeImage }) { |
|
|
|
}; |
|
|
|
const requestPermissionCamera = async () => { |
|
|
|
const { granted } = await ImagePicker.requestCameraPermissionsAsync(); |
|
|
|
if (!granted) alert("Você precisa habilitar permissão para acessar a câmera."); |
|
|
|
if(granted) { |
|
|
|
launchCamera(); |
|
|
|
} |
|
|
|
else if (!granted) alert("Você precisa habilitar permissão para acessar a câmera."); |
|
|
|
}; |
|
|
|
|
|
|
|
const handlePress = () => { |
|
|
@ -92,7 +94,7 @@ function ImageInput({ imageUri, onChangeImage }) { |
|
|
|
<View style={styles.modalView}> |
|
|
|
<View> |
|
|
|
<Text style={styles.modalLabel}>Selecione uma imagem</Text> |
|
|
|
<TouchableOpacity style={{ width: 300 }} onPress={launchCamera}> |
|
|
|
<TouchableOpacity style={{ width: 300 }} onPress={requestPermissionCamera}> |
|
|
|
<Text style={styles.modalText}>Câmera</Text> |
|
|
|
</TouchableOpacity> |
|
|
|
<TouchableOpacity style={{ width: 300 }} onPress={launchImageLibrary}> |
|
|
|