mirror of
https://github.com/lemeow125/Reactnative-notesapp.git
synced 2024-11-17 06:29:27 +08:00
Fixed 250 padding bottom jusko lord damn thicc & added public toggle to editnote
This commit is contained in:
parent
3ee11b888a
commit
2559c72cd9
5 changed files with 109 additions and 53 deletions
37
src/Components/PublicNote/PublicNote.tsx
Normal file
37
src/Components/PublicNote/PublicNote.tsx
Normal file
|
@ -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<RootDrawerParamList>();
|
||||
const queryClient = useQueryClient();
|
||||
const mutation = useMutation({
|
||||
mutationFn: DeleteNote,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries("notes");
|
||||
queryClient.invalidateQueries("public_notes");
|
||||
},
|
||||
});
|
||||
return (
|
||||
<View style={styles.addnotecont}>
|
||||
<View style={styles.tle}>
|
||||
<TextInput
|
||||
style={styles.title}
|
||||
value={props.title}
|
||||
maxLength={20}
|
||||
editable={false}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.typehere}>
|
||||
<ScrollView style={styles.typeinput} nestedScrollEnabled={true}>
|
||||
<Text style={styles.typeinput}>{props.content}</Text>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
|
@ -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<RootDrawerParamList>();
|
||||
|
@ -39,7 +40,7 @@ export default function PublicNotes() {
|
|||
<ScrollView contentContainerStyle={{ justifyContent: "center" }}>
|
||||
{notes.map((note: NoteProps, index: number) => {
|
||||
return (
|
||||
<Note
|
||||
<PublicNote
|
||||
id={note.id}
|
||||
key={index}
|
||||
title={note.title}
|
||||
|
|
|
@ -65,4 +65,5 @@ export interface UpdateNoteParams {
|
|||
id: number;
|
||||
title: string;
|
||||
content: string;
|
||||
public: boolean;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as React from "react";
|
||||
import { View, Text, TextInput } from "react-native";
|
||||
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";
|
||||
|
@ -61,7 +61,6 @@ export default function EditNote({ navigation, route }: any) {
|
|||
<Text style={{ ...styles.text_white, ...{ fontSize: 32 } }}>
|
||||
Edit Note
|
||||
</Text>
|
||||
<SafeAreaView>
|
||||
<View style={styles.addnotecont}>
|
||||
<View style={styles.tle}>
|
||||
<TextInput
|
||||
|
@ -87,6 +86,23 @@ export default function EditNote({ navigation, route }: any) {
|
|||
}}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "flex-start",
|
||||
marginLeft: 16,
|
||||
alignItems: "center",
|
||||
}}
|
||||
>
|
||||
<Switch
|
||||
onValueChange={() => setNote({ ...note, public: !note.public })}
|
||||
value={note.public}
|
||||
/>
|
||||
<Text style={{ ...styles.text_white, ...{ fontSize: 16 } }}>
|
||||
Public?
|
||||
</Text>
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
style={styles.savebtn}
|
||||
onPress={async () => {
|
||||
|
@ -94,6 +110,7 @@ export default function EditNote({ navigation, route }: any) {
|
|||
await mutation.mutate({
|
||||
title: note.title,
|
||||
content: note.content,
|
||||
public: note.public,
|
||||
id: noteId,
|
||||
});
|
||||
navigation.navigate("Home");
|
||||
|
@ -112,7 +129,6 @@ export default function EditNote({ navigation, route }: any) {
|
|||
<Text style={styles.cancel}>CANCEL</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</Background>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue