import React, {useState} from 'react';
import {View, Text, StyleSheet, FlatList, TouchableOpacity, Alert, Modal} from 'react-native';
import {Ionicons} from '@expo/vector-icons';
import {TodosModal} from "./Todos";
import {useDB} from "../context/DBcontex";
import moment from "moment";
export const Header = () => {
return (
Todo
List
by Jesse
)
}
export const HomeScreen = () => {
const [showModal, setShowModal] = useState(false)
const [currentList, setCurrentList] = useState({})
const {lists, deleteList, loading} = useDB()
if (loading) {
return (
Loading
)
}
const toggleModal = (listData = null) => {
setCurrentList(listData)
setShowModal(prev => !prev)
}
const onDelete = async (list) => {
await deleteList(list)
}
const OneListCard = ({item}) => (
{toggleModal(item)}}>
{item.title}
{moment(item.createdAt.toDate()).calendar()}
onDelete(item)}>
);
return (
{toggleModal()}}>
toggleModal()} data={currentList}/>
}
keyExtractor={(item) => item.title}
showsVerticalScrollIndicator={false}
/>
)
}
const styles = StyleSheet.create({
item: {
flexDirection: 'row',
borderRadius: 10,
paddingVertical: 12,
paddingHorizontal: 5,
marginHorizontal: 50,
marginTop: 20,
},
flatList: {},
todo: {
fontSize: 30,
fontWeight: 'bold',
color: 'grey'
},
list: {
fontSize: 30,
color: '#53abbf'
},
header: {
borderWidth: 2,
flexDirection: 'row',
marginTop: 20,
alignItems: 'center',
justifyContent: 'center'
},
container: {
flex: 1,
backgroundColor: '#14141c'
}
})