-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainScreen.js
110 lines (100 loc) · 3.79 KB
/
MainScreen.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
import React, { Component } from "react";
import { View, Text, Button, StyleSheet } from 'react-native';
import firestore , { doc } from '@react-native-firebase/firestore';
import { render } from "react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod";
import Load_post from "./load";
const style = StyleSheet.create({
container: {
backgroundColor: '#B9BFFF',
flex: 1
},
text: {
fontSize: 30,
color: '#21610B',
textAlign: 'center'
},
Button: {
color: 'black',
fontSize: 40,
},
input: {
height: 40,
margin: 50,
borderWidth: 5,
padding: 10,
color: 'black'
},
})
export default class MainScreen extends Component {
state = {
prevID : this.props.route.params.prevID,
doc_id : [],
doc_item : [],
}
goPostScreen = () =>{
const self = this;
const db = firestore().collection('Posts');
db.get().then((allData)=>{
const arr1 = []
const arr2 = []
allData.forEach((doc)=>{
arr1.push(doc.id);
arr2.push(doc.data());
const setid = new Set(arr1);
const setitem = new Set(arr2);
const unique_id = [...setid];
const unique_item = [...setitem]
self.setState({
doc_id : unique_id,
doc_item : unique_item,
})
});
console.log("Post로 넘길때의 Main Screen state 확인 : ", this.state);
this.props.navigation.navigate('Post',{prevID:this.state.prevID, doc_id:this.state.doc_id , doc_item:this.state.doc_item})
})
}
goEditScreen = () =>{
const self = this;
const db = firestore().collection('Posts');
db.get().then((allData)=>{
const arr1 = []
const arr2 = []
allData.forEach((doc)=>{
arr1.push(doc.id);
arr2.push(doc.data());
const setid = new Set(arr1);
const setitem = new Set(arr2);
const unique_id = [...setid];
const unique_item = [...setitem]
self.setState({
doc_id : unique_id,
doc_item : unique_item,
})
});
console.log("Edit로 넘길때의 Main Screen state 확인 : ", this.state);
this.props.navigation.navigate('Edit',{prevID:this.state.prevID, doc_id:this.state.doc_id , doc_item:this.state.doc_item})
})
}
render() {
return (
<View style={style.container}>
<Text style={{ fontSize: 30 }}>Main Screen</Text>
<Text style={{ fontSize: 30 ,color:'blue'}}> 환영합니다 {this.props.route.params.prevID} 님</Text>
<Text style={{ fontSize: 30 ,color:'blue'}}> 환영합니다 {this.state.prevID} 님</Text>
<Button onPress={() => this.goPostScreen()} title=" 게시글" />
<Button color={style.Button.color} onPress={() => this.goWriteScreen()} title="글 작성하기" />
<Button color={style.Button.color} onPress={() => this.goFilterScreen()} title="필터" />
<Button color={style.Button.color} onPress={() => this.goEditScreen()} title="내가 쓴 글 " />
</View>
)
}
goWriteScreen() {
this.props.navigation.navigate('Write',{prevID:this.state.prevID})
}
goLetterScreen() {
this.props.navigation.navigate('Letter',{prevID:this.state.prevID})
}
goFilterScreen() {
this.props.navigation.navigate('Filter',{prevID:this.state.prevID})
}
}