├── .expo-shared └── assets.json ├── .gitignore ├── App.js ├── app.json ├── assets ├── adaptive-icon.png ├── favicon.png ├── icon.png └── splash.png ├── babel.config.js ├── package-lock.json └── package.json /.expo-shared/assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true, 3 | "40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true 4 | } 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .expo/ 3 | dist/ 4 | npm-debug.* 5 | *.jks 6 | *.p8 7 | *.p12 8 | *.key 9 | *.mobileprovision 10 | *.orig.* 11 | web-build/ 12 | 13 | # macOS 14 | .DS_Store 15 | -------------------------------------------------------------------------------- /App.js: -------------------------------------------------------------------------------- 1 | import { StatusBar } from 'expo-status-bar'; 2 | import { StyleSheet, Text, View, SafeAreaView, Button, Image } from 'react-native'; 3 | import { useEffect, useRef, useState } from 'react'; 4 | import { Camera } from 'expo-camera'; 5 | import { shareAsync } from 'expo-sharing'; 6 | import * as MediaLibrary from 'expo-media-library'; 7 | 8 | export default function App() { 9 | let cameraRef = useRef(); 10 | const [hasCameraPermission, setHasCameraPermission] = useState(); 11 | const [hasMediaLibraryPermission, setHasMediaLibraryPermission] = useState(); 12 | const [photo, setPhoto] = useState(); 13 | 14 | useEffect(() => { 15 | (async () => { 16 | const cameraPermission = await Camera.requestCameraPermissionsAsync(); 17 | const mediaLibraryPermission = await MediaLibrary.requestPermissionsAsync(); 18 | setHasCameraPermission(cameraPermission.status === "granted"); 19 | setHasMediaLibraryPermission(mediaLibraryPermission.status === "granted"); 20 | })(); 21 | }, []); 22 | 23 | if (hasCameraPermission === undefined) { 24 | return Requesting permissions... 25 | } else if (!hasCameraPermission) { 26 | return Permission for camera not granted. Please change this in settings. 27 | } 28 | 29 | let takePic = async () => { 30 | let options = { 31 | quality: 1, 32 | base64: true, 33 | exif: false 34 | }; 35 | 36 | let newPhoto = await cameraRef.current.takePictureAsync(options); 37 | setPhoto(newPhoto); 38 | }; 39 | 40 | if (photo) { 41 | let sharePic = () => { 42 | shareAsync(photo.uri).then(() => { 43 | setPhoto(undefined); 44 | }); 45 | }; 46 | 47 | let savePhoto = () => { 48 | MediaLibrary.saveToLibraryAsync(photo.uri).then(() => { 49 | setPhoto(undefined); 50 | }); 51 | }; 52 | 53 | return ( 54 | 55 | 56 |