Procházet zdrojové kódy

Files temporeros para llegar a los chats exclusivos a dos usuarios.

ErnestoOrtiz2 před 3 roky
rodič
revize
19c619d39c
2 změnil soubory, kde provedl 18 přidání a 96 odebrání
  1. 16
    23
      screens/main/Home_page.js
  2. 2
    73
      screens/main/RoomScreen.js

+ 16
- 23
screens/main/Home_page.js Zobrazit soubor

@@ -49,33 +49,31 @@ export function Home_page({navigation}) {
49 49
   }
50 50
 
51 51
 
52
-  function handleButtonPress2() {
52
+  function handleButtonPress() {
53 53
       firebase.firestore()
54 54
         .collection('THREADS')
55 55
         .add({
56
-          name: 'NombreFecha',
56
+          name: 'PedroFecha',
57 57
           members: [
58 58
             firebase.auth().currentUser.uid,
59
-            'BhlrNDOqLOYSSlaEDK0nxZpQ2tD3'
59
+            '02yOZHxFcGUX4MNwjeEbAlCShdu1'
60 60
           ]
61 61
         })
62 62
         //.then(() => {
63 63
           //navigation.navigate('allChats');
64 64
          //});
65 65
   }
66
-  
66
+
67 67
   return (
68
-    <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
68
+      <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
69 69
         <FlatList
70 70
           data={threads}
71 71
           keyExtractor = {item => item._id}
72 72
           ItemSeparatorComponent={() => <Divider />}
73 73
           renderItem = {({item}) => (
74
-
75
-            <TouchableOpacity
74
+          <TouchableOpacity
76 75
             onPress={() => navigation.navigate('Room', {thread: item})}
77
-            
78
-            >
76
+          >
79 77
             <List.Item
80 78
               title={item.name}
81 79
               titleNumberOfLines={1}
@@ -85,24 +83,19 @@ export function Home_page({navigation}) {
85 83
             />
86 84
           </TouchableOpacity>
87 85
         )}
88
-      />
89
-
90
-                <TextInput
91
-                    labelName='Room Name'
92
-                    placeholder="new chat room"
93
-                    onChangeText={(text) => setRoomName(text)}
94
-                    clearButtonMode='while-editing'
95
-                />
96
-
86
+        />
87
+      <Button
88
+        title='Calendario'
89
+        onPress={() => navigation.navigate('Calendar')}
90
+      />  
97 91
       <Button
98 92
         title='CrearChat'
99
-        onPress={() => handleButtonPress2()}
93
+        onPress={() => handleButtonPress()}
100 94
       />
101
-
102
-        <Button
95
+      <Button
103 96
         title ='Hacer Busqueda'
104
-        onPress= {() => navigation.navigate('Room')}
105
-        />
97
+        onPress= {() => navigation.navigate('Busqueda')}
98
+      />
106 99
         </ImageBackground>
107 100
     );
108 101
   }

+ 2
- 73
screens/main/RoomScreen.js Zobrazit soubor

@@ -1,3 +1,4 @@
1
+
1 2
 import React, { useState, useEffect, useCallback } from 'react';
2 3
 import { GiftedChat } from 'react-native-gifted-chat';
3 4
 import firebase from 'firebase';
@@ -6,39 +7,10 @@ import { bindActionCreators } from 'redux'
6 7
 import { fetchUser } from '../../redux/actions/index'
7 8
 
8 9
 export function RoomScreen({ route }) {
9
-  //const { currentUser } = props;
10 10
   const { thread } = route.params;
11
-  /*const [messages, setMessages] = useState([
12
-    /**
13
-     * Mock message data
14
-     */
15
-    // example of system message
16
-   /* {
17
-      _id: 0,
18
-      text: 'New room created.',
19
-      createdAt: new Date().getTime(),
20
-      system: true
21
-    },
22
-    // example of chat message
23
-    {
24
-      _id: 1,
25
-      text: 'Henlo!',
26
-      createdAt: new Date().getTime(),
27
-      user: {
28
-        _id: 2,
29
-        name: 'Test User'
30
-      }
31
-    }
32
-  ]);*/
33
-
34 11
   const [messages, setMessages] = useState([])
35 12
 
36
-
37
-  /** the useEffect is used when we first render the component
38
-   *  solo va a corrar al principio.
39
-   */
40 13
   useEffect(() => {
41
-    //readUser()
42 14
     const unsubscribe = firebase.firestore() 
43 15
     .collection('THREADS')
44 16
     .doc(thread._id)
@@ -70,52 +42,9 @@ export function RoomScreen({ route }) {
70 42
     await Promise.all(writes)
71 43
   }
72 44
 
73
-  /*async function handleSend(messages, newMessage = []) {
74
-    const text = messages[0].text;
75
-    setMessages(GiftedChat.append(messages, newMessage));
76
-
77
-  //aqui podemos usar current user que no lo hemos usado, ya tenemos conectado redux
78
-    firebase.firestore() 
79
-      .collection('Users')
80
-      .doc(firebase.auth().currentUser.uid)
81
-      .collection('THREADS')
82
-      .doc(thread._id)
83
-      .collection('MESSAGES')
84
-      .add({
85
-        text,
86
-        createdAt: new Date().getTime(),
87
-      });
88
-
89
-    //Esto se ve, pero no genraliza, solo funciona desde currentUser y se graba en la otra cuenta, 
90
-    //pero la otra cuenta no puede responder porque pasa a ser current user. 
91
-    //Ademas no guarda que usuario dijo que.
92
-      firebase.firestore() 
93
-      .collection('Users')
94
-      .doc('HGGAJlcIfwdpUoYfcBKLZFcDude2')
95
-      .collection('THREADS')
96
-      .doc(thread._id)
97
-      .collection('MESSAGES')
98
-      .add({
99
-        text,
100
-        createdAt: new Date().getTime(),
101
-      });
102
-  }*/
103
-
104
-  // helper method that is sends a message
105
-  /*function handleSend(newMessage = []) {
106
-    setMessages(GiftedChat.append(messages, newMessage));
107
-  }*/
45
+  
108 46
 
109 47
   return (
110
-    /*<GiftedChat
111
-      messages={messages}
112
-      onSend={newMessage => handleSend(messages, newMessage)}
113
-      user={{ _id: 1 }}
114
-      showUserAvatar
115
-      alwaysShowSend
116
-      scrollToBottom
117
-    />*/
118
-
119 48
     <GiftedChat messages={messages} user={{ _id: 1 }} onSend={handleSend} />
120 49
   );
121 50
 }