Browse Source

trying to fix ios problem with permissions

master
analuizaff 4 years ago
parent
commit
67c72c941a
  1. 9
      src/app/components/ImageInput.js

9
src/app/components/ImageInput.js

@ -16,7 +16,7 @@ import colors from "../config/colors";
function ImageInput({ imageUri, onChangeImage }) {
useEffect(() => {
requestPermission();
requestPermissionCamera();
//requestPermissionCamera();
}, []);
const [modalVisible, setModalVisible] = useState(false);
@ -26,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 = () => {
@ -91,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}>

Loading…
Cancel
Save