Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions frontend/src/screens/CameraScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,24 @@ export default function CameraScreen({
};

const handletheCapture = async () => {
if (!cameraRef.current || !isCameraOk) {
return;
}
if (!cameraRef.current || !isCameraOk) return;

const photo = await cameraRef.current.takePictureAsync();
let location = null;
// fast capture
const photo = await cameraRef.current.takePictureAsync({
quality: 0.85,
skipProcessing: true,
});

// navigate instantly
navigation.navigate("UploadConfirmationScreen", {
photo,
location: null,
});

// fetch location in background
fetchLocationInBackground(photo);
};
const fetchLocationInBackground = async (photo: any) => {
const permissionStatus = await ensureLocationPermission();

if (permissionStatus === "granted") {
Expand All @@ -89,19 +101,22 @@ export default function CameraScreen({
"Location off",
"Enable location services to add location data."
);
} else {
try {
location = await Location.getCurrentPositionAsync({});
} catch (error) {
Alert.alert("Location error", "Unable to fetch your location.");
}
return;
}
}

navigation.navigate("UploadConfirmationScreen", {
photo,
location,
});
try {
const location = await Location.getCurrentPositionAsync({
accuracy: Location.Accuracy.Balanced,
});

navigation.navigate("UploadConfirmationScreen", {
photo,
location,
});
} catch (err) {
Alert.alert("Location error", "Unable to fetch your location.");
}
}
};

const handleGalleryPick = async () => {
Expand Down