|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
|
2
|
import React, {useState, useEffect} from 'react'
|
2
|
3
|
import { Button, Text, View, StyleSheet} from 'react-native'
|
3
|
4
|
import {FlatList, ListViewBase } from 'react-native'
|
|
@@ -8,6 +9,7 @@ import firebase from 'firebase';
|
8
|
9
|
import { styles } from "../../config/styles";
|
9
|
10
|
import { TextInput, TouchableWithoutFeedback, Keyboard, ImageBackground} from "react-native";
|
10
|
11
|
|
|
12
|
+
|
11
|
13
|
import { connect } from 'react-redux'
|
12
|
14
|
import { bindActionCreators } from 'redux'
|
13
|
15
|
import { fetchUser } from '../../redux/actions/index'
|
|
@@ -15,14 +17,12 @@ import { fetchUser } from '../../redux/actions/index'
|
15
|
17
|
export function Home_page({navigation}) {
|
16
|
18
|
const [threads, setThreads] = useState([]);
|
17
|
19
|
const [loading, setLoading] = useState(true);
|
18
|
|
-
|
19
|
|
- const [roomName, setRoomName] = useState('');
|
20
|
20
|
|
21
|
21
|
useEffect(() => {
|
22
|
22
|
|
23
|
23
|
const fire = firebase.firestore()
|
24
|
24
|
.collection('THREADS')
|
25
|
|
- .where("members", "array-contains", firebase.auth().currentUser.uid)
|
|
25
|
+
|
26
|
26
|
.onSnapshot(querySnapshot => {
|
27
|
27
|
const threads = querySnapshot.docs.map(documentSnapshot => {
|
28
|
28
|
return{
|
|
@@ -47,24 +47,9 @@ export function Home_page({navigation}) {
|
47
|
47
|
if (loading) {
|
48
|
48
|
return <Loading />;
|
49
|
49
|
}
|
50
|
|
-
|
51
|
|
-
|
52
|
|
- function handleButtonPress2() {
|
53
|
|
- firebase.firestore()
|
54
|
|
- .collection('THREADS')
|
55
|
|
- .add({
|
56
|
|
- name: 'NombreFecha',
|
57
|
|
- members: [
|
58
|
|
- firebase.auth().currentUser.uid,
|
59
|
|
- 'BhlrNDOqLOYSSlaEDK0nxZpQ2tD3'
|
60
|
|
- ]
|
61
|
|
- })
|
62
|
|
- //.then(() => {
|
63
|
|
- //navigation.navigate('allChats');
|
64
|
|
- //});
|
65
|
|
- }
|
66
|
50
|
|
67
|
51
|
return (
|
|
52
|
+ <View>
|
68
|
53
|
<ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
|
69
|
54
|
<FlatList
|
70
|
55
|
data={threads}
|
|
@@ -78,6 +63,7 @@ export function Home_page({navigation}) {
|
78
|
63
|
>
|
79
|
64
|
<List.Item
|
80
|
65
|
title={item.name}
|
|
66
|
+ description='Item description'
|
81
|
67
|
titleNumberOfLines={1}
|
82
|
68
|
titleStyle={styles.listTitle}
|
83
|
69
|
descriptionStyle={styles.listDescription}
|
|
@@ -87,16 +73,9 @@ export function Home_page({navigation}) {
|
87
|
73
|
)}
|
88
|
74
|
/>
|
89
|
75
|
|
90
|
|
- <TextInput
|
91
|
|
- labelName='Room Name'
|
92
|
|
- placeholder="new chat room"
|
93
|
|
- onChangeText={(text) => setRoomName(text)}
|
94
|
|
- clearButtonMode='while-editing'
|
95
|
|
- />
|
96
|
|
-
|
97
|
76
|
<Button
|
98
|
|
- title='CrearChat'
|
99
|
|
- onPress={() => handleButtonPress2()}
|
|
77
|
+ title='Ver mensajes'
|
|
78
|
+ onPress={() => navigation.navigate('Add')}
|
100
|
79
|
/>
|
101
|
80
|
|
102
|
81
|
<Button
|
|
@@ -104,12 +83,16 @@ export function Home_page({navigation}) {
|
104
|
83
|
onPress= {() => navigation.navigate('Room')}
|
105
|
84
|
/>
|
106
|
85
|
</ImageBackground>
|
|
86
|
+ </View>
|
107
|
87
|
);
|
108
|
88
|
}
|
109
|
89
|
|
110
|
90
|
const mapStateToProps = (store) => ({
|
111
|
91
|
currentUser: store.userState.currentUser
|
112
|
92
|
})
|
113
|
|
-const mapDispatchProps = (dispatch) => bindActionCreators({fetchUser}, dispatch);
|
|
93
|
+const mapDispatchProps = (dispatch) => bindActiontors({fetchUser}, dispatch);
|
|
94
|
+
|
|
95
|
+export default connect(mapStateToProps, mapDispatchProps)(Home_page);
|
|
96
|
+
|
|
97
|
+
|
114
|
98
|
|
115
|
|
-export default connect(mapStateToProps, mapDispatchProps)(Home_page);
|