Fixed 250 padding bottom jusko lord damn thicc & added public toggle to editnote

This commit is contained in:
keannu125 2023-04-16 19:41:13 +08:00
parent 3ee11b888a
commit 2559c72cd9
5 changed files with 109 additions and 53 deletions

View 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>
);
}

View file

@ -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}

View file

@ -65,4 +65,5 @@ export interface UpdateNoteParams {
id: number;
title: string;
content: string;
public: boolean;
}

View file

@ -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>
);
}

View file

@ -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",