-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReview.js
166 lines (157 loc) · 4.9 KB
/
Review.js
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import React, { Component } from 'react';
import { StyleSheet, View, TouchableOpacity } from 'react-native';
import {
Container, Header, Body, Right, Left, Button, Icon, Radio, List,
ListItem, Text, Content, CheckBox, Item, Input, Toast, Badge, ScrollableTab
} from 'native-base';
import { getData, setData } from './Storage';
import { getDateInfo } from './utils';
export default class Home extends Component {
constructor(props) {
super(props);
const { date } = this.props.route.params;
this.state = {
todaysTasks: [],
tasks: [],
date: date,
today: getDateInfo(date)
};
}
async componentDidMount() {
const tasks = await getData(this.state.date);
const todaysTasks = await getData(new Date());
console.log('got these tasks: ', tasks);
console.log('todays tasks', todaysTasks);
this.setState({ todaysTasks, tasks })
}
async componentDidUpdate(nextProps, prevState) {
const tasks = await getData(this.state.date);
const todaysTasks = await getData(new Date());
console.log('got these tasks: ', tasks);
console.log('todays tasks', todaysTasks);
return {
todaysTasks, tasks
}
}
getId = () => {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1) + Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1)
}
addTaskToToday = (task) => {
const todaysDate = new Date();
const todaysTasks = [...this.state.todaysTasks, {
id: this.getId(),
task: task.task,
size: task.size,
done: false
}]
// console.log('setting these tasks to today: ', todaysTasks, todaysDate);
setData(todaysDate, todaysTasks);
Toast.show({
text: "Task added to today!",
buttonText: "Okay",
duration: 1500
});
}
render() {
const { today } = this.state;
return (
<Container>
<Header style={styles.header} androidStatusBarColor="#393D5E">
</Header>
<Content style={styles.content}>
<View style={{ padding: 20 }}>
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<Text style={{ fontSize: 40, color: '#efefefaa' }}>REVIEW TASKS</Text>
</View>
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', marginTop: 10 }}>
<Text style={{ fontSize: 60, color: '#efefef' }}>{today.date}</Text>
<View style={{ marginLeft: 5 }}>
<Text style={{ fontSize: 24, color: '#efefefdd' }}>{today.month}</Text>
<Text style={{ fontSize: 24, color: '#efefef88' }}>{today.day}</Text>
</View>
</View>
</View>
<List>
{this.state.tasks.map(task => {
return (
<TouchableOpacity style={styles.item} key={task.id} onLongPress={() => this.deleteTask(task)}>
<View style={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}>
<Badge style={{ marginRight: 10, backgroundColor: (task.size == 'small') ? "#ffec3d" : (task.size == 'medium') ? "#ffa940" : "#ff4d4f" }}></Badge>
<Text style={{ color: '#efefef', textDecorationLine: task.done ? 'line-through' : 'none' }}>{task.task}</Text>
</View>
<Right>
<Icon type="MaterialIcons" name="add-box" style={{ color: '#efefefaa', fontSize: 40 }} onPress={() => this.addTaskToToday(task)} />
</Right>
</TouchableOpacity>
);
})}
</List>
<View style={styles.deleteText}>
<Text style={{ color: '#01010155' }}>click 'plus' to add task to today's list</Text>
</View>
</Content>
</Container>
)
}
}
const styles = StyleSheet.create({
item: {
backgroundColor: '#3F4674',
height: 60,
color: '#efefef',
padding: 10,
display: 'flex',
flexDirection: 'row',
alignItems: 'center', // #5C89C3
justifyContent: 'space-between',
borderRadius: 10,
marginLeft: 20,
marginTop: 10,
},
addItem: {
backgroundColor: '#3F4674',
height: 60,
color: '#efefef',
padding: 10,
display: 'flex',
flexDirection: 'row',
alignItems: 'center', // #5C89C3
justifyContent: 'space-between',
marginLeft: 20,
marginTop: 10,
color: '#efefef'
},
floatingButton: {
position: 'absolute',
bottom: '10%',
left: '42%',
borderRadius: 40,
},
content: {
width: '95%',
backgroundColor: '#393D5E',
color: '#efefef'
},
header: {
backgroundColor: '#393D5E',
display: 'none'
},
right: {
display: 'flex',
flexDirection: 'row',
minWidth: 120,
justifyContent: 'space-between'
},
deleteText: {
marginTop: 10,
color: '#11111111',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: '100%'
}
})