-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
97 lines (82 loc) · 2.58 KB
/
Copy pathApp.js
File metadata and controls
97 lines (82 loc) · 2.58 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, {Component} from 'react';
import { View, Text,ActivityIndicator, FlatList ,TextInput ,Image, TouchableOpacity} from 'react-native';
import styles from './styles';
import Header from './Header';
import Item from './Item';
import {observer} from 'mobx-react';
import TodoStore from './todoStore';
const data = [
{ title:'Create new Project 1',check:true},
{ title: 'Create new Project 2', },
{ title: 'Create new Project 3', check: true },
{ title: 'Create new Project 4', },
{ title: 'Create new Project 5', check: true },
{ title: 'Create new Project 6', },
{ title: 'Create new Project 7', check: true },
]
@observer
export default class App extends Component {
constructor(props){
super(props);
this.state = {text:''
,todos:[]
}
//this.updateCheck = this.updateCheck.bind(this);
}
componentWillMount() {
TodoStore.fetchAll();
}
/*updateCheck(index,check){
const {todos} = this.state;
todos[index].check = check;
this.setState({todos});
}*/
/*removeData(index){
const {todos} = this.state;
const newTodos = todos.filter((v,i)=>index!==i);
/*const newTodos = todos.filter((v, i) => {
if (index === i) { return false }
else { return true; }
});*/
/* this.setState({todos:newTodos});
}*/
render() {
return (
<View style={styles.container}>
<Header title={"All Tasks"}/>
<TextInput
placeholder={"Durum Giriniz...."}
value={this.state.text} onChangeText={(text)=>{
this.setState({text});
}} style={{borderBottomWidth:1,borderColor:'#eee' , marginTop:-5,marginBottom:5,height:40,borderWidth:1,backgroundColor:'#FFF',padding:8}} />
<View style={styles.itemContainer}>
{TodoStore.todos ? (<FlatList
keyExtractor = {(item,index)=>index}
data={TodoStore.allTodos}
renderItem={({item,index})=>
<Item index={index} title={item.title} check={item.check}/>}
/>):<ActivityIndicator/>}
</View>
<Image
//style={{width: 50, height: 50}}
//source={require('./img/favicon.png')}
/>
<TouchableOpacity onPress={()=>{
TodoStore.addTodo(this.state.text);
this.setState({text:''});
}} style={styles.createButton}>
<Text style={styles.createButtonText}>
+
</Text>
</TouchableOpacity>
</View>
);
}
}