mirror of
https://github.com/lemeow125/Reactnative-notesapp.git
synced 2024-11-16 22:19:26 +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,58 +61,74 @@ 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
|
||||
style={styles.title}
|
||||
placeholder="Title"
|
||||
placeholderTextColor="white"
|
||||
value={note.title}
|
||||
onChangeText={(text) => {
|
||||
setNote({ ...note, title: text });
|
||||
}}
|
||||
maxLength={20}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.typehere}>
|
||||
<TextInput
|
||||
style={styles.typeinput}
|
||||
placeholder="Type here...."
|
||||
placeholderTextColor="white"
|
||||
value={note.content}
|
||||
multiline={true}
|
||||
onChangeText={async (text) => {
|
||||
await setNote({ ...note, content: text });
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
style={styles.savebtn}
|
||||
onPress={async () => {
|
||||
try {
|
||||
await mutation.mutate({
|
||||
title: note.title,
|
||||
content: note.content,
|
||||
id: noteId,
|
||||
});
|
||||
navigation.navigate("Home");
|
||||
} catch (error) {}
|
||||
console.log(note.content);
|
||||
<View style={styles.addnotecont}>
|
||||
<View style={styles.tle}>
|
||||
<TextInput
|
||||
style={styles.title}
|
||||
placeholder="Title"
|
||||
placeholderTextColor="white"
|
||||
value={note.title}
|
||||
onChangeText={(text) => {
|
||||
setNote({ ...note, title: text });
|
||||
}}
|
||||
>
|
||||
<Text style={styles.savenote}>SAVE</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
style={styles.cancelbtn}
|
||||
onPress={() => {
|
||||
navigation.navigate("Home");
|
||||
}}
|
||||
>
|
||||
<Text style={styles.cancel}>CANCEL</Text>
|
||||
</TouchableOpacity>
|
||||
maxLength={20}
|
||||
/>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
<View style={styles.typehere}>
|
||||
<TextInput
|
||||
style={styles.typeinput}
|
||||
placeholder="Type here...."
|
||||
placeholderTextColor="white"
|
||||
value={note.content}
|
||||
multiline={true}
|
||||
onChangeText={async (text) => {
|
||||
await setNote({ ...note, content: text });
|
||||
}}
|
||||
/>
|
||||
</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 () => {
|
||||
try {
|
||||
await mutation.mutate({
|
||||
title: note.title,
|
||||
content: note.content,
|
||||
public: note.public,
|
||||
id: noteId,
|
||||
});
|
||||
navigation.navigate("Home");
|
||||
} catch (error) {}
|
||||
console.log(note.content);
|
||||
}}
|
||||
>
|
||||
<Text style={styles.savenote}>SAVE</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity
|
||||
style={styles.cancelbtn}
|
||||
onPress={() => {
|
||||
navigation.navigate("Home");
|
||||
}}
|
||||
>
|
||||
<Text style={styles.cancel}>CANCEL</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</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