-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
72 lines (62 loc) · 2.14 KB
/
App.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
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import Toast from 'react-native-root-toast';
import { connect } from 'react-redux';
import { AddTodo, DeleteTodo } from './src/actions/todos';
import TodoAction from './src/components/Todo/TodoAction';
import TodoList from './src/components/Todo/TodoList';
import ToDoDetail from './src/components/Todo/TodoDetail';
import Register from './src/components/Auth/Register';
// import ScrollDemo from './src/components/Scroll/ScrollDemo';
// import HorizontalScroll from './src/components/Scroll/HorizontalScroll';
import ViewPagerExample from './src/components/Scroll/ViewPagerExample';
import BasicList from './src/components/List/BasicList';
const App = (props) => {
const [modalVisible, setModalVisible] = useState(false);
const [name, setName] = useState(false);
deleteTodo = (e) => {
props.deleteTodo(e);
}
addToDo = (name) => {
if (name.trim() === "") {
Toast.show('Name is required bro... :)', { duration: 1000, position: Toast.positions.TOP, animation: true });
return;
}
props.addToDo(name);
}
detailTodo = (todo) => {
setName(todo.name);
setModalVisible(true);
}
return (
<View style={styles.container}>
<BasicList />
{/* <ViewPagerExample /> */}
{/* <HorizontalScroll /> */}
{/* <Register /> */}
{/* <TodoAction addToDo={(name) => this.addToDo(name)} />
<View>
{props.todoList && props.todoList.length > 0 ?
<TodoList todoList={props.todoList} deleteTodo={(e) => this.deleteTodo(e)} detailTodo={(e) => this.detailTodo(e)} />
: null
}
</View>
<ToDoDetail modalVisible={modalVisible} name={name} setModalVisible={(e) => setModalVisible(e)} /> */}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
const mapStateToProps = state => ({
todoList: state.todo.todoList
});
const mapDispatchToProps = dispatch => {
return {
deleteTodo: id => dispatch(DeleteTodo(id)),
addToDo: name => dispatch(AddTodo(name))
}
}
export default connect(mapStateToProps, mapDispatchToProps)(App);