Browse Source

Tratando de recuperar cambios en Home_page.js

ErnestoOrtiz2 3 years ago
parent
commit
593055b15b
1 changed files with 13 additions and 30 deletions
  1. 13
    30
      screens/main/Home_page.js

+ 13
- 30
screens/main/Home_page.js View File

1
+
1
 import React, {useState, useEffect} from 'react'
2
 import React, {useState, useEffect} from 'react'
2
 import { Button, Text, View, StyleSheet} from 'react-native'
3
 import { Button, Text, View, StyleSheet} from 'react-native'
3
 import {FlatList, ListViewBase } from 'react-native'
4
 import {FlatList, ListViewBase } from 'react-native'
8
 import { styles } from "../../config/styles";
9
 import { styles } from "../../config/styles";
9
 import { TextInput, TouchableWithoutFeedback, Keyboard, ImageBackground} from "react-native";
10
 import { TextInput, TouchableWithoutFeedback, Keyboard, ImageBackground} from "react-native";
10
 
11
 
12
+
11
 import { connect } from 'react-redux'
13
 import { connect } from 'react-redux'
12
 import { bindActionCreators } from 'redux' 
14
 import { bindActionCreators } from 'redux' 
13
 import { fetchUser } from '../../redux/actions/index'
15
 import { fetchUser } from '../../redux/actions/index'
15
 export function Home_page({navigation}) {
17
 export function Home_page({navigation}) {
16
   const [threads, setThreads] = useState([]);  
18
   const [threads, setThreads] = useState([]);  
17
   const [loading, setLoading] = useState(true);
19
   const [loading, setLoading] = useState(true);
18
-  
19
-  const [roomName, setRoomName] = useState('');
20
 
20
 
21
   useEffect(() => {
21
   useEffect(() => {
22
 
22
 
23
     const fire = firebase.firestore()
23
     const fire = firebase.firestore()
24
     .collection('THREADS')
24
     .collection('THREADS')
25
-    .where("members", "array-contains", firebase.auth().currentUser.uid)
25
+    
26
     .onSnapshot(querySnapshot => {
26
     .onSnapshot(querySnapshot => {
27
       const threads = querySnapshot.docs.map(documentSnapshot => {
27
       const threads = querySnapshot.docs.map(documentSnapshot => {
28
         return{
28
         return{
47
   if (loading) {
47
   if (loading) {
48
     return <Loading />;
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
   return (
51
   return (
52
+    <View>
68
     <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
53
     <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
69
         <FlatList
54
         <FlatList
70
           data={threads}
55
           data={threads}
78
             >
63
             >
79
             <List.Item
64
             <List.Item
80
               title={item.name}
65
               title={item.name}
66
+              description='Item description'
81
               titleNumberOfLines={1}
67
               titleNumberOfLines={1}
82
               titleStyle={styles.listTitle}
68
               titleStyle={styles.listTitle}
83
               descriptionStyle={styles.listDescription}
69
               descriptionStyle={styles.listDescription}
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
       <Button
76
       <Button
98
-        title='CrearChat'
99
-        onPress={() => handleButtonPress2()}
77
+        title='Ver mensajes'
78
+        onPress={() => navigation.navigate('Add')}
100
       />
79
       />
101
 
80
 
102
         <Button
81
         <Button
104
         onPress= {() => navigation.navigate('Room')}
83
         onPress= {() => navigation.navigate('Room')}
105
         />
84
         />
106
         </ImageBackground>
85
         </ImageBackground>
86
+      </View>
107
     );
87
     );
108
   }
88
   }
109
 
89
 
110
 const mapStateToProps = (store) => ({
90
 const mapStateToProps = (store) => ({
111
   currentUser: store.userState.currentUser
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);