import React, { useState, useEffect, useRef } from 'react'; import { View, TouchableOpacity, Text } from 'react-native'; import { Camera } from 'expo-camera'; import * as Permissions from 'expo-permissions'; import MainText from '../components/MainText'; const ScanScreen = () => { let camera = useRef(null); const [hasPermission, setHasPermission] = useState(null); const [type, setType] = useState(Camera.Constants.Type.back); useEffect(() => { (async () => { const { status } = await Permissions.askAsync(Permissions.CAMERA); setHasPermission(status === 'granted'); })(); }, []); const takePicture = async () => { let data = await camera.takePictureAsync(); }; return ( <View style={{ flex: 1 }}> <View style={{ flex: 1, justifyContent: 'flex-end', }} > <TouchableOpacity onPress={takePicture}> <Text>!!!!!!!!</Text> </TouchableOpacity> </View> <Camera style={{ flex: 1 }} type={type} ref={camera} > </Camera> </View> ); }; export default ScanScreen;
Обсуждают сегодня