From 2559c72cd99fc4412fea1708a202c3b147d41fb1 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sun, 16 Apr 2023 19:41:13 +0800 Subject: [PATCH] Fixed 250 padding bottom jusko lord damn thicc & added public toggle to editnote --- src/Components/PublicNote/PublicNote.tsx | 37 +++++++ src/Components/PublicNotes/Notes.tsx | 3 +- src/Interfaces/Interfaces.tsx | 1 + src/Routes/EditNote/EditNote.tsx | 118 +++++++++++++---------- src/styles.tsx | 3 +- 5 files changed, 109 insertions(+), 53 deletions(-) create mode 100644 src/Components/PublicNote/PublicNote.tsx diff --git a/src/Components/PublicNote/PublicNote.tsx b/src/Components/PublicNote/PublicNote.tsx new file mode 100644 index 0000000..9eef3cc --- /dev/null +++ b/src/Components/PublicNote/PublicNote.tsx @@ -0,0 +1,37 @@ +import * as React from "react"; +import { View, Text, TextInput, ScrollView } from "react-native"; +import styles from "../../styles"; +import { NoteProps, RootDrawerParamList } from "../../Interfaces/Interfaces"; +import ButtonCentered from "../Buttons/ButtonCentered/ButtonCentered"; +import { useQueryClient, useMutation } from "react-query"; +import { DeleteNote } from "../Api/Api"; +import { useNavigation } from "@react-navigation/native"; + +export default function PublicNote(props: NoteProps) { + const navigation = useNavigation(); + const queryClient = useQueryClient(); + const mutation = useMutation({ + mutationFn: DeleteNote, + onSuccess: () => { + queryClient.invalidateQueries("notes"); + queryClient.invalidateQueries("public_notes"); + }, + }); + return ( + + + + + + + {props.content} + + + + ); +} diff --git a/src/Components/PublicNotes/Notes.tsx b/src/Components/PublicNotes/Notes.tsx index efc4850..82ab0c1 100644 --- a/src/Components/PublicNotes/Notes.tsx +++ b/src/Components/PublicNotes/Notes.tsx @@ -8,6 +8,7 @@ import { RootState } from "../../Features/Redux/Store/Store"; import { NoteProps, RootDrawerParamList } from "../../Interfaces/Interfaces"; import { useNavigation } from "@react-navigation/native"; import Note from "../Note/Note"; +import PublicNote from "../PublicNote/PublicNote"; export default function PublicNotes() { const navigation = useNavigation(); @@ -39,7 +40,7 @@ export default function PublicNotes() { {notes.map((note: NoteProps, index: number) => { return ( - Edit Note - - - - { - setNote({ ...note, title: text }); - }} - maxLength={20} - /> - - - { - await setNote({ ...note, content: text }); - }} - /> - - { - try { - await mutation.mutate({ - title: note.title, - content: note.content, - id: noteId, - }); - navigation.navigate("Home"); - } catch (error) {} - console.log(note.content); + + + { + setNote({ ...note, title: text }); }} - > - SAVE - - { - navigation.navigate("Home"); - }} - > - CANCEL - + maxLength={20} + /> - + + { + await setNote({ ...note, content: text }); + }} + /> + + + setNote({ ...note, public: !note.public })} + value={note.public} + /> + + Public? + + + { + try { + await mutation.mutate({ + title: note.title, + content: note.content, + public: note.public, + id: noteId, + }); + navigation.navigate("Home"); + } catch (error) {} + console.log(note.content); + }} + > + SAVE + + { + navigation.navigate("Home"); + }} + > + CANCEL + + ); } diff --git a/src/styles.tsx b/src/styles.tsx index c53a371..a77b043 100644 --- a/src/styles.tsx +++ b/src/styles.tsx @@ -180,7 +180,8 @@ const styles = StyleSheet.create({ addnotecont: { marginTop: 30, marginLeft: 22, - height: 500, + paddingBottom: 30, + minHeight: 500, width: 350, borderRadius: 25, backgroundColor: "black",