import React from "react"; import {StyleSheet, View, TouchableOpacity, Text} from "react-native"; import {Ionicons} from "@expo/vector-icons"; import moment from "moment"; import {useDB} from "../context/DBcontex"; function Todo({item, color, listId}) { const {deleteTodo, toggleTodoCompleted} = useDB() const onDelete = async () => { await deleteTodo(listId, item) } const toggleCompleted = async () => { await toggleTodoCompleted(listId, item) } return ( toggleCompleted()}> {item.title} {moment(item.createdAt.toDate()).calendar()} onDelete()} > ); } const styles = StyleSheet.create({ container: { marginVertical: 10, borderRadius: 10, padding: 5, }, todoTitle: { fontSize: 22, flex: 1, alignSelf: 'center' }, todoDate: { flex: 1, alignSelf: 'center', fontSize: 10, color: 'white' }, todoInfo: { flex: 1, justifyContent: 'space-between', paddingVertical: 5, } }); export default Todo;