diff --git a/src/Interfaces/Interfaces.tsx b/src/Interfaces/Interfaces.tsx index f03a912..3f31b60 100644 --- a/src/Interfaces/Interfaces.tsx +++ b/src/Interfaces/Interfaces.tsx @@ -59,6 +59,7 @@ export interface ActivationParams { export interface AddNoteParams { title: string; content: string; + public: boolean; } export interface UpdateNoteParams { diff --git a/src/Routes/EditNote/EditNote.tsx b/src/Routes/EditNote/EditNote.tsx index b062aa0..3189e80 100644 --- a/src/Routes/EditNote/EditNote.tsx +++ b/src/Routes/EditNote/EditNote.tsx @@ -15,7 +15,7 @@ export default function EditNote({ navigation, route }: any) { const [note, setNote] = useState({ title: "", content: "", - public: true, + public: false, }); async function retrieve() { let a = await GetNote(noteId); diff --git a/src/Routes/NewNote/NewNote.tsx b/src/Routes/NewNote/NewNote.tsx index e10b50c..54a0fef 100644 --- a/src/Routes/NewNote/NewNote.tsx +++ b/src/Routes/NewNote/NewNote.tsx @@ -1,10 +1,10 @@ -import * as React from 'react'; -import {View, Text, TextInput} from 'react-native'; -import styles from '../../styles'; -import Background from '../../Components/Background/Background'; -import { SafeAreaView } from 'react-native-safe-area-context'; +import * as React from "react"; +import { View, Text, TextInput, Switch } from "react-native"; +import styles from "../../styles"; +import Background from "../../Components/Background/Background"; +import { SafeAreaView } from "react-native-safe-area-context"; import { useState } from "react"; -import {TouchableOpacity,} from "react-native"; +import { TouchableOpacity } from "react-native"; import { RootDrawerParamList } from "../../Interfaces/Interfaces"; import { useNavigation } from "@react-navigation/native"; import { useMutation, useQueryClient } from "react-query"; @@ -14,10 +14,11 @@ export default function NewNote() { const [note, setNote] = useState({ title: "", content: "", + public: false, }); const navigation = useNavigation(); - + const queryClient = useQueryClient(); const mutation = useMutation({ mutationFn: AddNote, @@ -28,54 +29,77 @@ export default function NewNote() { return ( - New Note - - - - { - setNote({ ...note, title: text }); + + New Note + + + + + { + setNote({ ...note, title: text }); + }} + maxLength={20} + /> + + + { + await setNote({ ...note, content: text }); + }} + /> + + - - - { - 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, + }); + navigation.navigate("Home"); + } catch (error) {} + console.log(note.content); }} - /> - - { - try { - await mutation.mutate({ - title: note.title, - content: note.content, - }); - navigation.navigate("Home"); - } catch (error) {} - console.log(note.content) - }}> - - SAVE - - { - navigation.navigate("Home"); - }}> - CANCEL - - - + > + SAVE + + { + navigation.navigate("Home"); + }} + > + CANCEL + + );