From 5826900f034930c18236a9b345f67b44a49fe558 Mon Sep 17 00:00:00 2001 From: Royce Chua Date: Mon, 21 Jun 2021 21:23:46 +0800 Subject: [PATCH] Add feature to make search item navigatable to movie detail screen --- .../home/components/SearchResults.tsx | 100 ++++++++++-------- 1 file changed, 56 insertions(+), 44 deletions(-) diff --git a/src/features/home/components/SearchResults.tsx b/src/features/home/components/SearchResults.tsx index ed4e803..1d5d48c 100644 --- a/src/features/home/components/SearchResults.tsx +++ b/src/features/home/components/SearchResults.tsx @@ -1,9 +1,11 @@ import moment from 'moment'; import React from 'react'; import { ActivityIndicator, FlatList, StyleSheet, Text, View, Image } from 'react-native'; +import { TouchableOpacity } from 'react-native-gesture-handler'; import { Badge, Card } from 'react-native-paper'; import { useQuery } from 'react-query'; import Spacer from '../../../common/components/Spacer'; +import { navigate } from '../../../navigation/RootNavigation'; import API from '../../../services/API'; import Res from '../../../themes/Res'; import theme from '../../../themes/themes'; @@ -21,57 +23,67 @@ const SearchResults : React.FC = (props: Props) => { { keepPreviousData: true, staleTime: 5000 } ); + // navigate to movie detail screen + const handleViewMovieDetails = (movie: any) => { + navigate('MovieDetail', { + movie, + type: 'movieDetail' + }); + }; + return ( item.id.toString()} renderItem={({ item, index }) => ( - - - - - - - - - {item.title || - item.original_title || - item.original_name} - - - {moment(item.release_date).format( - 'MMMM DD, YYYY' - )} - + handleViewMovieDetails(item)}> + + + + + - - {item.overview || - 'No Movie Overview Available'} - - {item.adult ? ( - - Adult - - ) : null} - - - + + + {item.title || + item.original_title || + item.original_name} + + + {moment(item.release_date).format( + 'MMMM DD, YYYY' + )} + + + + {item.overview || + 'No Movie Overview Available'} + + {item.adult ? ( + + Adult + + ) : null} + + + + )} ItemSeparatorComponent={() => } ListEmptyComponent={