mock add new reminder

This commit is contained in:
ivic00
2024-08-05 22:00:40 +02:00
parent 3955a85bc7
commit 807f37fa0c
2 changed files with 107 additions and 31 deletions

View File

@ -20,7 +20,15 @@ import { TouchableOpacity } from "react-native-gesture-handler";
interface ReminderModalProps { interface ReminderModalProps {
visible: boolean; visible: boolean;
onClose: () => void; onClose: () => void;
/*onSave: (reminderText: string) => void;*/ onSave: (newReminder: Reminder) => void;
}
interface Reminder {
title: string;
date: Date;
done: boolean;
isAutoRepeat: boolean;
remindIn: string;
} }
interface reminderOptions { interface reminderOptions {
@ -29,7 +37,7 @@ interface reminderOptions {
} }
const AddReminderModal = (props: ReminderModalProps) => { const AddReminderModal = (props: ReminderModalProps) => {
const { visible, onClose /*, onSave*/ } = props; const { visible, onClose , onSave } = props;
const [reminderTitle, setReminderTitle] = useState<string>(""); const [reminderTitle, setReminderTitle] = useState<string>("");
const [time, setTime] = useState(new Date()); const [time, setTime] = useState(new Date());
const [autoRepeat, setAutoRepeat] = useState<boolean>(false); const [autoRepeat, setAutoRepeat] = useState<boolean>(false);
@ -45,6 +53,18 @@ const AddReminderModal = (props: ReminderModalProps) => {
{ label: "Remind me 1 day before", value: "1-day-before" }, { label: "Remind me 1 day before", value: "1-day-before" },
]; ];
const handleSave = () => {
const newReminder: Reminder = {
title: reminderTitle,
date: time,
done: false,
isAutoRepeat: autoRepeat,
remindIn: reminder
};
onSave(newReminder);
onClose();
};
const handleDateTimeChange = (selectedTime: Date) => { const handleDateTimeChange = (selectedTime: Date) => {
setTime(selectedTime); setTime(selectedTime);
}; };
@ -78,13 +98,17 @@ const AddReminderModal = (props: ReminderModalProps) => {
<View style={styles.iconTitle}> <View style={styles.iconTitle}>
<View <View
style={{ style={{
height: 25, height: 27,
width: 25, width: 27,
marginRight: 10, marginRight: 10,
borderRadius: 50, borderRadius: 50,
backgroundColor: "#fcf4eb", backgroundColor: "#fcf4eb",
alignItems: "center",
justifyContent: "center",
}} }}
/> >
<Feather name="scissors" size={14} color="black" />
</View>
<TextField <TextField
value={reminderTitle} value={reminderTitle}
onChangeText={(text) => setReminderTitle(text)} onChangeText={(text) => setReminderTitle(text)}
@ -97,35 +121,39 @@ const AddReminderModal = (props: ReminderModalProps) => {
<View style={styles.inner}> <View style={styles.inner}>
<Text text70>Reminder Time</Text> <Text text70>Reminder Time</Text>
<View style={styles.inputsBetween}> <View style={styles.inputsBetween}>
<Feather name="calendar" size={20} color="black" />
<DateTimePicker <DateTimePicker
migrateDialog migrateDialog
value={time} value={time}
mode="date" mode="date"
leadingAccessory={
<View>
<Feather name="calendar" size={20} color="black" />
<View style={{ marginRight: "75%" }} />
</View>
}
onChange={handleDateTimeChange} onChange={handleDateTimeChange}
text70 text70
/> />
</View> </View>
<TouchableOpacity> <TouchableOpacity>
<View style={styles.inputsBetween}> <View style={styles.inputsBetween}>
<AntDesign name="clockcircleo" size={20} color="black" />
<DateTimePicker <DateTimePicker
migrateDialog migrateDialog
value={time} value={time}
mode="time" mode="time"
is24Hour={false} is24Hour={false}
onChange={handleDateTimeChange} onChange={handleDateTimeChange}
leadingAccessory={
<View>
<AntDesign name="clockcircleo" size={20} color="black" />
<View style={{ marginRight: "70%" }} />
</View>
}
text70 text70
/> />
</View> </View>
</TouchableOpacity> </TouchableOpacity>
<View style={styles.inputsStart}> <View style={styles.inputsStart}>
<Feather
name="bell"
size={19}
color="black"
style={{ marginRight: 7 }}
/>
<Picker <Picker
text70 text70
value={reminder} value={reminder}
@ -133,10 +161,18 @@ const AddReminderModal = (props: ReminderModalProps) => {
useDialog useDialog
fieldType="form" fieldType="form"
placeholder="Select a reminder" placeholder="Select a reminder"
leadingAccessory={
<Feather
name="bell"
size={19}
color="black"
style={{ marginRight: 7 }}
/>
}
trailingAccessory={ trailingAccessory={
<Feather <Feather
name="chevron-down" name="chevron-down"
style={{ marginLeft: "auto" }} style={{ marginLeft: "25%" }}
size={22} size={22}
color="black" color="black"
/> />
@ -183,14 +219,15 @@ const AddReminderModal = (props: ReminderModalProps) => {
<Button <Button
label="Cancel" label="Cancel"
style={styles.button} style={styles.button}
color='black' color="black"
onPress={onClose}
/> />
<Button <Button
label="Save" label="Save"
borderRadius={5} borderRadius={5}
backgroundColor="#00c87e" backgroundColor="#00c87e"
style={{width: '49%'}} style={{ width: "49%" }}
onPress={handleSave}
/> />
</View> </View>
</View> </View>
@ -214,7 +251,7 @@ const styles = StyleSheet.create({
borderRadius: 5, borderRadius: 5,
padding: 0, padding: 0,
marginHorizontal: 0, marginHorizontal: 0,
width:'49%' width: "49%",
}, },
inner: { inner: {
paddingHorizontal: 20, paddingHorizontal: 20,

View File

@ -3,36 +3,72 @@ import { StyleSheet } from "react-native";
import { Button, Card, Checkbox, Text, View } from "react-native-ui-lib"; import { Button, Card, Checkbox, Text, View } from "react-native-ui-lib";
import AddReminderModal from "./addReminderModal"; import AddReminderModal from "./addReminderModal";
import ButtonOutlined from "@/components/ui/ButtonOutlined"; import ButtonOutlined from "@/components/ui/ButtonOutlined";
import AntDesign from "@expo/vector-icons/AntDesign";
import Feather from "@expo/vector-icons/Feather";
import { ScrollView } from "react-native-gesture-handler";
interface Reminder { interface Reminder {
title: string; title: string;
date: string; date: Date;
time: string;
done: boolean; done: boolean;
isAutoRepeat: boolean;
remindIn: string;
} }
const dateTimeDisplay = (date: Date) => {
const day = String(date.getDate()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, "0");
const year = date.getFullYear();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
return (
<Text text80>
{`${day}/${month}/${year}`}{" "}
<AntDesign name="star" size={14} color="lightgray" />{" "}
{`${hours}:${minutes}`}
</Text>
);
};
const RemindersList = () => { const RemindersList = () => {
const [isModalVisible, setIsModalVisible] = useState(false); const [isModalVisible, setIsModalVisible] = useState(false);
const [reminders, setReminders] = useState<Reminder[]>([ const [reminders, setReminders] = useState<Reminder[]>([
{ {
title: "Shaving Time", title: "Shaving Time",
date: "26/02/2023", date: new Date(2023, 1, 30, 9, 30),
time: "09:30",
done: true, done: true,
isAutoRepeat: true,
remindIn: "just-in-time",
}, },
{ {
title: "Gonna get a food order", title: "Gonna get a food order",
date: "27/02/2023", date: new Date(2023, 1, 27),
time: "10:30",
done: false, done: false,
isAutoRepeat: true,
remindIn: "just-in-time",
}, },
]); ]);
const handleModalClose = () => {
setIsModalVisible(false);
};
const addReminder = (newReminder: Reminder) => {
setReminders([...reminders, newReminder]);
};
return ( return (
<View style={styles.listContainer}> <ScrollView
showsVerticalScrollIndicator={false}
showsHorizontalScrollIndicator={false}
style={styles.listContainer}
>
<AddReminderModal <AddReminderModal
visible={isModalVisible} visible={isModalVisible}
onClose={() => setIsModalVisible(false)} onClose={handleModalClose}
onSave={addReminder}
/> />
<View <View
style={{ style={{
@ -54,12 +90,12 @@ const RemindersList = () => {
<Card key={index} style={{ marginBottom: 10, padding: 15 }}> <Card key={index} style={{ marginBottom: 10, padding: 15 }}>
<View style={styles.card} row> <View style={styles.card} row>
<View row> <View row>
<View style={styles.icon} /> <View style={styles.icon}>
<Feather name="scissors" size={24} color="black" />
</View>
<View> <View>
<Text text70BL>{reminder.title}</Text> <Text text70BL>{reminder.title}</Text>
<Text text80> {dateTimeDisplay(reminder.date)}
{reminder.date} {reminder.time}
</Text>
</View> </View>
</View> </View>
<Checkbox <Checkbox
@ -77,7 +113,7 @@ const RemindersList = () => {
</Card> </Card>
))} ))}
</View> </View>
</View> </ScrollView>
); );
}; };
@ -90,6 +126,7 @@ const styles = StyleSheet.create({
marginLeft: "8%", marginLeft: "8%",
marginTop: "4%", marginTop: "4%",
marginRight: "4%", marginRight: "4%",
maxHeight: '71%'
}, },
button: { button: {
backgroundColor: "white", backgroundColor: "white",
@ -113,6 +150,8 @@ const styles = StyleSheet.create({
height: 45, height: 45,
width: 45, width: 45,
backgroundColor: "#fcf4eb", backgroundColor: "#fcf4eb",
alignItems: "center",
justifyContent: "center",
marginRight: 10, marginRight: 10,
}, },
}); });