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 { NoteProps, RootDrawerParamList } from "../../Interfaces/Interfaces";
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
import Note from "../Note/Note";
|
import Note from "../Note/Note";
|
||||||
|
import PublicNote from "../PublicNote/PublicNote";
|
||||||
|
|
||||||
export default function PublicNotes() {
|
export default function PublicNotes() {
|
||||||
const navigation = useNavigation<RootDrawerParamList>();
|
const navigation = useNavigation<RootDrawerParamList>();
|
||||||
|
@ -39,7 +40,7 @@ export default function PublicNotes() {
|
||||||
<ScrollView contentContainerStyle={{ justifyContent: "center" }}>
|
<ScrollView contentContainerStyle={{ justifyContent: "center" }}>
|
||||||
{notes.map((note: NoteProps, index: number) => {
|
{notes.map((note: NoteProps, index: number) => {
|
||||||
return (
|
return (
|
||||||
<Note
|
<PublicNote
|
||||||
id={note.id}
|
id={note.id}
|
||||||
key={index}
|
key={index}
|
||||||
title={note.title}
|
title={note.title}
|
||||||
|
|
|
@ -65,4 +65,5 @@ export interface UpdateNoteParams {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
content: string;
|
content: string;
|
||||||
|
public: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as React from "react";
|
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 styles from "../../styles";
|
||||||
import Background from "../../Components/Background/Background";
|
import Background from "../../Components/Background/Background";
|
||||||
import { SafeAreaView } from "react-native-safe-area-context";
|
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 } }}>
|
<Text style={{ ...styles.text_white, ...{ fontSize: 32 } }}>
|
||||||
Edit Note
|
Edit Note
|
||||||
</Text>
|
</Text>
|
||||||
<SafeAreaView>
|
|
||||||
<View style={styles.addnotecont}>
|
<View style={styles.addnotecont}>
|
||||||
<View style={styles.tle}>
|
<View style={styles.tle}>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
@ -87,6 +86,23 @@ export default function EditNote({ navigation, route }: any) {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</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
|
<TouchableOpacity
|
||||||
style={styles.savebtn}
|
style={styles.savebtn}
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
|
@ -94,6 +110,7 @@ export default function EditNote({ navigation, route }: any) {
|
||||||
await mutation.mutate({
|
await mutation.mutate({
|
||||||
title: note.title,
|
title: note.title,
|
||||||
content: note.content,
|
content: note.content,
|
||||||
|
public: note.public,
|
||||||
id: noteId,
|
id: noteId,
|
||||||
});
|
});
|
||||||
navigation.navigate("Home");
|
navigation.navigate("Home");
|
||||||
|
@ -112,7 +129,6 @@ export default function EditNote({ navigation, route }: any) {
|
||||||
<Text style={styles.cancel}>CANCEL</Text>
|
<Text style={styles.cancel}>CANCEL</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
</SafeAreaView>
|
|
||||||
</Background>
|
</Background>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,8 @@ const styles = StyleSheet.create({
|
||||||
addnotecont: {
|
addnotecont: {
|
||||||
marginTop: 30,
|
marginTop: 30,
|
||||||
marginLeft: 22,
|
marginLeft: 22,
|
||||||
height: 500,
|
paddingBottom: 30,
|
||||||
|
minHeight: 500,
|
||||||
width: 350,
|
width: 350,
|
||||||
borderRadius: 25,
|
borderRadius: 25,
|
||||||
backgroundColor: "black",
|
backgroundColor: "black",
|
||||||
|
|
Loading…
Reference in a new issue