From 35898d8ff7638d4fd0c94cc698ad53271b06e34c Mon Sep 17 00:00:00 2001 From: analuizaff Date: Mon, 28 Dec 2020 17:11:31 -0300 Subject: [PATCH] trying to launch camera --- src/App.js | 3 ++ src/app/components/LaunchCamera.js | 54 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/app/components/LaunchCamera.js diff --git a/src/App.js b/src/App.js index 0eb3621..9216542 100644 --- a/src/App.js +++ b/src/App.js @@ -8,6 +8,8 @@ import openDatabase from "./app/database/database-connection"; import initDatabase from "./app/database/database-init"; import FlashMessage from "react-native-flash-message"; +import LaunchCamera from "./app/components/LaunchCamera"; + export default function App() { global.userDataBase = openDatabase(); initDatabase(global.userDataBase); @@ -17,5 +19,6 @@ export default function App() { + /**/ ); } diff --git a/src/app/components/LaunchCamera.js b/src/app/components/LaunchCamera.js new file mode 100644 index 0000000..d7bb02c --- /dev/null +++ b/src/app/components/LaunchCamera.js @@ -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 ( + + + +