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,58 +61,74 @@ 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
|
style={styles.title}
|
||||||
style={styles.title}
|
placeholder="Title"
|
||||||
placeholder="Title"
|
placeholderTextColor="white"
|
||||||
placeholderTextColor="white"
|
value={note.title}
|
||||||
value={note.title}
|
onChangeText={(text) => {
|
||||||
onChangeText={(text) => {
|
setNote({ ...note, title: 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);
|
|
||||||
}}
|
}}
|
||||||
>
|
maxLength={20}
|
||||||
<Text style={styles.savenote}>SAVE</Text>
|
/>
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity
|
|
||||||
style={styles.cancelbtn}
|
|
||||||
onPress={() => {
|
|
||||||
navigation.navigate("Home");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={styles.cancel}>CANCEL</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
</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>
|
</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