Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Last active September 9, 2019 08:43
Show Gist options
  • Save amandeepmittal/bfcb3c2e91aad8f24c40dc82abc69ed9 to your computer and use it in GitHub Desktop.
Save amandeepmittal/bfcb3c2e91aad8f24c40dc82abc69ed9 to your computer and use it in GitHub Desktop.
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