Browse Source

Arregle mi error del Home

gilberto.cancel 2 years ago
parent
commit
074b3f0fb2
1 changed files with 81 additions and 129 deletions
  1. 81
    129
      screens/main/Home_page.js

+ 81
- 129
screens/main/Home_page.js View File

@@ -37,6 +37,7 @@ export function Home_page({navigation}) {
37 37
   const notificationListener = useRef();
38 38
   const responseListener = useRef();
39 39
 
40
+
40 41
   useEffect(() => {
41 42
     registerForPushNotificationsAsync().then(token => setExpoPushToken(token));
42 43
     notificationListener.current = Notifications.addNotificationReceivedListener(notification => {
@@ -45,6 +46,7 @@ export function Home_page({navigation}) {
45 46
 
46 47
     responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
47 48
       console.log(response);
49
+      navigation.navigate('Confirm');
48 50
     });
49 51
 
50 52
     const fire = firebase.firestore()
@@ -108,6 +110,10 @@ export function Home_page({navigation}) {
108 110
         })
109 111
   }
110 112
 
113
+  const dimensions = Dimensions.get('window');
114
+  const screenWidth = dimensions.width;
115
+
116
+  
111 117
   function check_user_type_INT(){
112 118
 
113 119
     
@@ -130,72 +136,48 @@ export function Home_page({navigation}) {
130 136
     }
131 137
 
132 138
   }
133
-
134
-  const dimensions = Dimensions.get('window');
135
-  const screenWidth = dimensions.width;
136 139
   
137 140
   check_user_type_INT();
138 141
   console.log(interpreter);
139 142
   if(interpreter == false){
140 143
     return (
141
-        <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
142
-          <FlatList style={{
143
-              flex: 1,
144
-              width: screenWidth,
145
-          }}
146
-            data={threads}
147
-            keyExtractor = {item => item._id}
148
-            ItemSeparatorComponent={() => <Divider />}
149
-            renderItem = {({item}) => (
150
-            <TouchableOpacity
151
-              onPress={() => navigation.navigate('Room', {thread: item})}
152
-            >
153
-              <List.Item
154
-                title={item.name}
155
-                titleNumberOfLines={1}
156
-                titleStyle={styles.listTitle}
157
-                descriptionStyle={styles.listDescription}
158
-                descriptionNumberOfLines={1}
159
-              />
160
-            </TouchableOpacity>
161
-          )}
144
+      <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
145
+      <FlatList style={{
146
+           flex: 1,
147
+           width: screenWidth,
148
+       }}
149
+        data={appointments}
150
+        keyExtractor = {item => item._id}
151
+        ItemSeparatorComponent={() => <Divider />}
152
+        renderItem = {({item}) => (
153
+        <TouchableOpacity
154
+        onPress={async () => {
155
+          navigation.navigate('Cita')
156
+        }}
157
+        >
158
+          <List.Item
159
+            title={item.Month}
160
+            titleNumberOfLines={1}
161
+            titleStyle={styles.listTitle}
162
+            descriptionStyle={styles.listDescription}
163
+            descriptionNumberOfLines={1}
162 164
           />
163
-          <FlatList style={{
164
-              flex: 1,
165
-              width: screenWidth,
166
-          }}
167
-            data={appointments}
168
-            keyExtractor = {item => item._id}
169
-            ItemSeparatorComponent={() => <Divider />}
170
-            renderItem = {({item}) => (
171
-            <TouchableOpacity
172
-            onPress={async () => {
173
-              await sendPushNotification(expoPushToken);
174
-            }}
175
-            >
176
-              <List.Item
177
-                title={item.Month}
178
-                titleNumberOfLines={1}
179
-                titleStyle={styles.listTitle}
180
-                descriptionStyle={styles.listDescription}
181
-                descriptionNumberOfLines={1}
182
-              />
183
-              <List.Item
184
-                title={item.Day}
185
-                titleNumberOfLines={1}
186
-                titleStyle={styles.listTitle}
187
-                descriptionStyle={styles.listDescription}
188
-                descriptionNumberOfLines={1}
189
-              />
190
-              <List.Item
191
-                title={item.Time}
192
-                titleNumberOfLines={1}
193
-                titleStyle={styles.listTitle}
194
-                descriptionStyle={styles.listDescription}
195
-                descriptionNumberOfLines={1}
196
-              />
197
-            </TouchableOpacity>
198
-          )}
165
+          <List.Item
166
+            title={item.Day}
167
+            titleNumberOfLines={1}
168
+            titleStyle={styles.listTitle}
169
+            descriptionStyle={styles.listDescription}
170
+            descriptionNumberOfLines={1}
171
+          />
172
+          <List.Item
173
+            title={item.Time}
174
+            titleNumberOfLines={1}
175
+            titleStyle={styles.listTitle}
176
+            descriptionStyle={styles.listDescription}
177
+            descriptionNumberOfLines={1}
178
+          />
179
+        </TouchableOpacity>
180
+      )}
199 181
           />
200 182
         <Button
201 183
             title ='Send notification'
@@ -204,11 +186,7 @@ export function Home_page({navigation}) {
204 186
             }}
205 187
           /> 
206 188
         <Button
207
-          title='CrearChat'
208
-          onPress={() => handleButtonPress()}
209
-        />
210
-        <Button
211
-          title ='Search for Interpreters'
189
+          title ='Hacer Busqueda'
212 190
           onPress= {() => navigation.navigate('Search')}
213 191
         />
214 192
         <Button
@@ -220,64 +198,43 @@ export function Home_page({navigation}) {
220 198
     }
221 199
     else{
222 200
       return (
223
-          <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
224
-            <FlatList style={{
225
-                flex: 1,
226
-                width: screenWidth,
227
-            }}
228
-              data={threads}
229
-              keyExtractor = {item => item._id}
230
-              ItemSeparatorComponent={() => <Divider />}
231
-              renderItem = {({item}) => (
232
-              <TouchableOpacity
233
-                onPress={() => navigation.navigate('Room', {thread: item})}
234
-              >
235
-                <List.Item
236
-                  title={item.name}
237
-                  titleNumberOfLines={1}
238
-                  titleStyle={styles.listTitle}
239
-                  descriptionStyle={styles.listDescription}
240
-                  descriptionNumberOfLines={1}
241
-                />
242
-              </TouchableOpacity>
243
-            )}
201
+        <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
202
+        <FlatList style={{
203
+             flex: 1,
204
+             width: screenWidth,
205
+         }}
206
+          data={appointments}
207
+          keyExtractor = {item => item._id}
208
+          ItemSeparatorComponent={() => <Divider />}
209
+          renderItem = {({item}) => (
210
+          <TouchableOpacity
211
+          onPress={async () => {
212
+            navigation.navigate('Cita')
213
+          }}
214
+          >
215
+            <List.Item
216
+              title={item.Month}
217
+              titleNumberOfLines={1}
218
+              titleStyle={styles.listTitle}
219
+              descriptionStyle={styles.listDescription}
220
+              descriptionNumberOfLines={1}
244 221
             />
245
-            <FlatList style={{
246
-                flex: 1,
247
-                width: screenWidth,
248
-            }}
249
-              data={appointments}
250
-              keyExtractor = {item => item._id}
251
-              ItemSeparatorComponent={() => <Divider />}
252
-              renderItem = {({item}) => (
253
-              <TouchableOpacity
254
-              onPress={async () => {
255
-                await sendPushNotification(expoPushToken);
256
-              }}
257
-              >
258
-                <List.Item
259
-                  title={item.Month}
260
-                  titleNumberOfLines={1}
261
-                  titleStyle={styles.listTitle}
262
-                  descriptionStyle={styles.listDescription}
263
-                  descriptionNumberOfLines={1}
264
-                />
265
-                <List.Item
266
-                  title={item.Day}
267
-                  titleNumberOfLines={1}
268
-                  titleStyle={styles.listTitle}
269
-                  descriptionStyle={styles.listDescription}
270
-                  descriptionNumberOfLines={1}
271
-                />
272
-                <List.Item
273
-                  title={item.Time}
274
-                  titleNumberOfLines={1}
275
-                  titleStyle={styles.listTitle}
276
-                  descriptionStyle={styles.listDescription}
277
-                  descriptionNumberOfLines={1}
278
-                />
279
-              </TouchableOpacity>
280
-            )}
222
+            <List.Item
223
+              title={item.Day}
224
+              titleNumberOfLines={1}
225
+              titleStyle={styles.listTitle}
226
+              descriptionStyle={styles.listDescription}
227
+              descriptionNumberOfLines={1}
228
+            />
229
+            <List.Item
230
+              title={item.Time}
231
+              titleNumberOfLines={1}
232
+              titleStyle={styles.listTitle}
233
+              descriptionStyle={styles.listDescription}
234
+              descriptionNumberOfLines={1}
235
+            />
236
+          </TouchableOpacity>
237
+        )}
281 238
             />
282 239
           <Button
283 240
             title ='Send notification'
@@ -285,11 +242,6 @@ export function Home_page({navigation}) {
285 242
             await sendPushNotification(expoPushToken);
286 243
             }}
287 244
           /> 
288
-
289
-          <Button
290
-            title='CrearChat'
291
-            onPress={() => handleButtonPress()}
292
-          />
293 245
           <Button
294 246
           title ='Availability'
295 247
           onPress= {() => navigation.navigate('Availability')}
@@ -307,8 +259,8 @@ async function sendPushNotification(expoPushToken) {
307 259
   const message = {
308 260
     to: expoPushToken,
309 261
     sound: 'default',
310
-    title: 'Original Title',
311
-    body: 'And here is the body!',
262
+    title: 'Freehand',
263
+    body: 'Le solicitan una cita',
312 264
     data: { someData: 'goes here' },
313 265
   };
314 266