-
-
Save amandeepmittal/bfcb3c2e91aad8f24c40dc82abc69ed9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import { | |
StyleSheet, | |
Text, | |
View, | |
TouchableOpacity, | |
TextInput | |
} from 'react-native'; | |
import Icon from 'react-native-vector-icons/Feather'; | |
export default function App() { | |
const [value, setValue] = useState(''); | |
const [todos, setTodos] = useState([]); | |
addTodo = () => { | |
if (value.length > 0) { | |
setTodos([...todos, { text: value, key: Date.now(), checked: false }]); | |
setValue(''); | |
} | |
}; | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.header}>Todo List</Text> | |
<View style={styles.textInputContainer}> | |
<TextInput | |
style={styles.textInput} | |
multiline={true} | |
placeholder="What do you want to do today?" | |
placeholderTextColor="#abbabb" | |
value={value} | |
onChangeText={value => setValue(value)} | |
/> | |
<TouchableOpacity onPress={() => addTodo()}> | |
> | |
<Icon name="plus" size={30} color="blue" style={{ marginLeft: 15 }} /> | |
</TouchableOpacity> | |
</View> | |
</View> | |
); | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'flex-start', | |
alignItems: 'center', | |
backgroundColor: '#F5FCFF' | |
}, | |
header: { | |
marginTop: '15%', | |
fontSize: 20, | |
color: 'red', | |
paddingBottom: 10 | |
}, | |
textInputContainer: { | |
flexDirection: 'row', | |
alignItems: 'baseline', | |
borderColor: 'black', | |
borderBottomWidth: 1, | |
paddingRight: 10, | |
paddingBottom: 10 | |
}, | |
textInput: { | |
flex: 1, | |
height: 20, | |
fontSize: 18, | |
fontWeight: 'bold', | |
color: 'black', | |
paddingLeft: 10, | |
minHeight: '3%' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment