Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete button addition to note #123

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
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
38 changes: 24 additions & 14 deletions lib/screens/AddNoteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,30 @@ const AddNoteScreen: React.FC<AddNoteScreenProps> = ({ navigation, route }) => {
const saveNote = async () => {
const locationPermissionGranted = await checkLocationPermission();
if (titleText === "") {
if (!promptedMissingTitle) {
setPromptedMissingTitle(true);
Alert.alert(
"Title is empty",
"Please enter a title to save the note, or press back again to confirm not saving the note.",
);
return;
} else {
navigation.goBack();
return;
}
Alert.alert(
"Title is empty",
"Please enter a title to save the note.",
);
return;
}
if (!locationPermissionGranted) {
return; // Stop saving the note if location permission is not granted
Alert.alert(
"Delete Note",
"Location permissions required to save. Are you sure you want to delete this note?",
[
{
text: "Cancel",
onPress: () => console.log("Cancel Pressed"),
style: "cancel"
},
{
text: "Delete",
onPress: () => navigation.goBack()
}
],
{ cancelable: false }
);
return;
}
else {
try {
Expand All @@ -200,8 +210,8 @@ const AddNoteScreen: React.FC<AddNoteScreenProps> = ({ navigation, route }) => {
let latitude, longitude;

if (Platform.OS === 'ios') {
latitude = location?.latitude.toString();
longitude = location?.longitude.toString();
latitude = userLocation.coords.latitude.toString();
longitude = userLocation.coords.longitude.toString();
} else if (Platform.OS === 'android') {
latitude = userLocation.coords.latitude.toString();
longitude = userLocation.coords.longitude.toString();
Expand Down
9 changes: 8 additions & 1 deletion lib/utils/S3_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function uploadMedia(uri: string, mediaType: string): Promise<string> {
console.log("File size:", file.size);

data.append("file", file);
} else {
} else if(Platform.OS == "ios") {
let base64 = await FileSystem.readAsStringAsync(uri, {
encoding: FileSystem.EncodingType.Base64,
});
Expand All @@ -57,6 +57,13 @@ async function uploadMedia(uri: string, mediaType: string): Promise<string> {
name: uniqueName,
});
}
else if (Platform.OS == "android"){
data.append("file", {
uri: uri,
type: "video/mp4",
name: uniqueName,
});
}

return fetch(S3_PROXY_PREFIX + "uploadFile", {
method: "POST",
Expand Down
Loading