diff --git a/App.js b/App.js index 09f879b..d9bfe5f 100644 --- a/App.js +++ b/App.js @@ -1,11 +1,66 @@ -import { StatusBar } from 'expo-status-bar'; -import { StyleSheet, Text, View } from 'react-native'; +import React, {useState} from 'react'; +import { KeyboardAvoidingView, StyleSheet, Text, View, TextInput, TouchableOpacity, Keyboard, ScrollView } from 'react-native'; +import Task from './components/Todo'; export default function App() { + const [task, setTask] = useState(); + const [taskItems, setTaskItems] = useState([]); + + const handleAddTask = () => { + Keyboard.dismiss(); + setTaskItems([...taskItems, task]) + setTask(null); + } + + const completeTask = (index) => { + let itemsCopy = [...taskItems]; + itemsCopy.splice(index, 1); + setTaskItems(itemsCopy) + } + return ( - Open up App.js to start working on your app! - + {/* Added this scroll view to enable scrolling when list gets longer than the page */} + + + {/* Today's Tasks */} + + Today's tasks + + {/* This is where the tasks will go! */} + { + taskItems.map((item, index) => { + return ( + completeTask(index)}> + + + ) + }) + } + + + + + + {/* Write a task */} + {/* Uses a keyboard avoiding view which ensures the keyboard does not cover the items on screen */} + + setTask(text)} /> + handleAddTask()}> + + + + + + + ); } @@ -13,8 +68,45 @@ export default function App() { const styles = StyleSheet.create({ container: { flex: 1, - backgroundColor: '#fff', - alignItems: 'center', + backgroundColor: '#E8EAED', + }, + tasksWrapper: { + paddingTop: 80, + paddingHorizontal: 20, + }, + sectionTitle: { + fontSize: 24, + fontWeight: 'bold' + }, + items: { + marginTop: 30, + }, + writeTaskWrapper: { + position: 'absolute', + bottom: 60, + width: '100%', + flexDirection: 'row', + justifyContent: 'space-around', + alignItems: 'center' + }, + input: { + paddingVertical: 15, + paddingHorizontal: 15, + backgroundColor: '#FFF', + borderRadius: 60, + borderColor: '#C0C0C0', + borderWidth: 1, + width: 250, + }, + addWrapper: { + width: 60, + height: 60, + backgroundColor: '#FFF', + borderRadius: 60, justifyContent: 'center', + alignItems: 'center', + borderColor: '#C0C0C0', + borderWidth: 1, }, -}); + addText: {}, +}); \ No newline at end of file diff --git a/components/Todo.js b/components/Todo.js new file mode 100644 index 0000000..348454d --- /dev/null +++ b/components/Todo.js @@ -0,0 +1,52 @@ +import React from 'react'; +import { View, Text, StyleSheet, TouchableOpacity } from 'react-native'; + +const Task = (props) => { + + return ( + + + + {props.text} + + + + ) +} + +const styles = StyleSheet.create({ + item: { + backgroundColor: '#FFF', + padding: 15, + borderRadius: 10, + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + marginBottom: 20, + }, + itemLeft: { + flexDirection: 'row', + alignItems: 'center', + flexWrap: 'wrap' + }, + square: { + width: 24, + height: 24, + backgroundColor: '#55BCF6', + opacity: 0.4, + borderRadius: 5, + marginRight: 15, + }, + itemText: { + maxWidth: '80%', + }, + circular: { + width: 12, + height: 12, + borderColor: '#55BCF6', + borderWidth: 2, + borderRadius: 5, + }, +}); + +export default Task; \ No newline at end of file