import { View, Text, Checkbox, TextField, TouchableOpacity, Modal, Dialog, Button, ButtonSize, } from "react-native-ui-lib"; import React, { useEffect, useState } from "react"; import { useToDosContext } from "@/contexts/ToDosContext"; import { Ionicons } from "@expo/vector-icons"; import PointsSlider from "@/components/shared/PointsSlider"; import { IToDo } from "@/hooks/firebase/types/todoData"; import { ImageBackground } from "react-native"; const ToDoItem = (props: { item: IToDo; isSettings?: boolean }) => { const { updateToDo } = useToDosContext(); const [editing, setEditing] = useState(false); const [points, setPoints] = useState(props.item.points); const [pointsModalVisible, setPointsModalVisible] = useState(false); const handlePointsChange = (text: string) => { const numericValue = parseInt(text, 10); if (!isNaN(numericValue) && numericValue >= 0 && numericValue <= 100) { setPoints(numericValue); } else if (text === "") { setPoints(0); } }; return ( {!editing ? ( { if (props.isSettings) { setEditing(true); } }} > {props.item.title} ) : ( { updateToDo({ id: props.item.id, title: text }); }} onSubmitEditing={() => { setEditing(false); }} onBlur={() => { setEditing(false); }} /> )} { updateToDo({ id: props.item.id, done: !props.item.done }); }} /> {props.item.points && props.item.points > 0 ? ( { if (props.isSettings) { setPointsModalVisible(true); } }} > {props.item.points} points ) : ( )} setPointsModalVisible(false)} containerStyle={{ padding: 20, borderRadius: 15, backgroundColor: "white", }} children={ Reward points {points && ( )}