This repository was archived by the owner on May 10, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathApp.js
More file actions
74 lines (72 loc) · 1.86 KB
/
Copy pathApp.js
File metadata and controls
74 lines (72 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { StatusBar } from 'expo-status-bar';
import { useState } from 'react';
import { Pressable, StyleSheet, Text, TextInput, View, Alert } from 'react-native';
export default function App() {
const [text, setText] = useState('');
const [taskVal, setTaskVal] = useState([]);
function getText(val) {
setText(val);
}
function getTextClick() {
setTaskVal([...taskVal, text]);
// console.log(taskVal);
}
return (
<View style={styles.container}>
<Text>Add your task to start working!</Text>
<View style={styles.content}>
<TextInput placeholder='Enter the task: ' style={styles.inputBox} onChangeText={getText}></TextInput>
<Pressable style={styles.btnParent} onPress={getTextClick}><Text>Add</Text></Pressable>
</View>
<View style={styles.tasksList}>
{taskVal.map((task, index) => {
if (task != '')
return <View style={styles.taskTile} key={index}><Text>{task}</Text></View>
else {
Alert.alert('CantBeeDun', 'Cant add empty task!!', [{text: 'OK'}]);
}
})}
</View>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'flex-start',
paddingVertical: 50
},
content: {
width: '80%',
flexDirection: 'row',
borderBottomColor: '#cccccc',
borderBottomWidth: 2
},
inputBox: {
marginVertical: 20,
borderWidth: 2,
borderColor: '#cccccc',
padding: 8,
width: '80%',
marginRight: 10
},
btnParent: {
backgroundColor: '#cccccc',
alignSelf: 'center',
padding: 14
},
tasksList: {
width: '80%'
},
taskTile: {
backgroundColor: '#cccccc',
width: '100%',
height: 58,
justifyContent: 'center',
marginVertical: 10,
paddingHorizontal: 20
}
});