Added app reducer, fixed package issues, begun camera screen updates
This commit is contained in:
@@ -7,16 +7,36 @@ import {
|
||||
MaterialCommunityIcons,
|
||||
} from "@expo/vector-icons";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import * as FileSystem from "expo-file-system";
|
||||
import * as Permissions from "expo-permissions";
|
||||
import * as MediaLibrary from "expo-media-library";
|
||||
|
||||
export default function ScreenCamera() {
|
||||
const navigation = useNavigation();
|
||||
const [hasPermission, setHasPermission] = useState(null);
|
||||
const [rollPermision, setRollPermission] = useState(null);
|
||||
const [type, setType] = useState(Camera.Constants.Type.back);
|
||||
const cameraRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
//Ensure local photo direcotry exists.
|
||||
console.log(
|
||||
"ScreenCamera -> FileSystem.documentDirectory ",
|
||||
FileSystem.documentDirectory
|
||||
);
|
||||
|
||||
await FileSystem.makeDirectoryAsync(
|
||||
FileSystem.documentDirectory + "photos"
|
||||
).catch((e) => {
|
||||
console.log(e, "Directoryc already exists");
|
||||
});
|
||||
|
||||
const { status } = await Camera.requestPermissionsAsync();
|
||||
setHasPermission(status === "granted");
|
||||
// camera roll
|
||||
const { cam_roll } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
|
||||
setRollPermission(cam_roll === "granted");
|
||||
})();
|
||||
}, []);
|
||||
|
||||
@@ -31,8 +51,29 @@ export default function ScreenCamera() {
|
||||
const handleTakePicture = async () => {
|
||||
console.log("Taking the picture!");
|
||||
if (cameraRef.current) {
|
||||
let photo = await cameraRef.current.takePictureAsync();
|
||||
console.log("The Photo", photo);
|
||||
const options = {
|
||||
//quality: 0.5,
|
||||
//base64: true,
|
||||
//skipProcessing: true,
|
||||
};
|
||||
|
||||
let photo = await cameraRef.current.takePictureAsync(options);
|
||||
console.log("ScreenCamera -> photo", photo);
|
||||
const filename = new Date().getTime() + ".jpg";
|
||||
|
||||
await FileSystem.copyAsync({
|
||||
from: photo.uri,
|
||||
to: FileSystem.documentDirectory + "photos/" + filename,
|
||||
});
|
||||
|
||||
console.log(
|
||||
"List of Files",
|
||||
await FileSystem.readDirectoryAsync(FileSystem.documentDirectory),
|
||||
await FileSystem.readDirectoryAsync(
|
||||
FileSystem.documentDirectory + "photos"
|
||||
)
|
||||
);
|
||||
//const asset = await MediaLibrary.createAssetAsync(photo.uri);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user