diff --git a/model/Movie.tsx b/model/Movie.tsx index e1a57b6..a8ffb26 100644 --- a/model/Movie.tsx +++ b/model/Movie.tsx @@ -5,15 +5,18 @@ class Movie { public runtime: number public vote_average : number public release_date: string - public genres: string[] = [] + public overview: string + public genres: string[] - constructor(original_title: string, poster_path: string,runtime: number, vote_average: number, release_date : string, genres : string[]) { + + constructor(original_title: string, poster_path: string,runtime: number, vote_average: number, release_date : string, genres : string[], overview : string) { this.original_title = original_title; - this.poster_path = 'https://image.tmdb.org/t/p/w500'+poster_path; + this.poster_path = 'https://image.tmdb.org/t/p/w780'+poster_path; this.runtime = runtime; this.vote_average = vote_average; this.release_date = release_date; this.genres = genres; + this.overview = overview; } diff --git a/redux/actions/actionGetTrendingID.tsx b/redux/actions/actionGetTrendingID.tsx index 8cd7793..01d23a1 100644 --- a/redux/actions/actionGetTrendingID.tsx +++ b/redux/actions/actionGetTrendingID.tsx @@ -47,7 +47,7 @@ export const getTrendingID = () => { const MovieList: Movie[] = []; Promise.all(idList.map(async elt => { try{ - const infoPromise = await fetch(config.base_url + "movie/"+elt+"?api_key=" + config.api_key); + const infoPromise = await fetch(config.base_url + "movie/"+elt+"?api_key=" + config.api_key + "&language=fr-FR"); //const infoJson = await infoPromise.json(); //console.log('infos---------', infoJson); //MovieList.push(new Movie(infoJson["original_title"], infoJson["poster_path"],infoJson["runtime"], infoJson["vote_average"], infoJson["release_date"])) @@ -67,7 +67,7 @@ export const getTrendingID = () => { }); console.log('infos---------', elt); // @ts-ignore - MovieList.push(new Movie(infoJson["original_title"], infoJson["poster_path"],infoJson["runtime"], infoJson["vote_average"], infoJson["release_date"], genreRow)) + MovieList.push(new Movie(infoJson["title"], infoJson["poster_path"],infoJson["runtime"], infoJson["vote_average"], infoJson["release_date"], genreRow, infoJson["overview"])) }) try { //console.log("tortue", MovieList) diff --git a/screens/HomeScreen.tsx b/screens/HomeScreen.tsx index 7c3c8cf..233e246 100644 --- a/screens/HomeScreen.tsx +++ b/screens/HomeScreen.tsx @@ -9,7 +9,7 @@ import { Image, ImageBackground, SafeAreaView, - ActivityIndicator, FlatList + ActivityIndicator, FlatList, Animated, Easing } from 'react-native'; import {RootStackScreenProps} from "../types"; import {useEffect, useRef, useState} from "react"; @@ -17,8 +17,6 @@ import {useSafeAreaInsets} from "react-native-safe-area-context"; import {addMovieToWatchLater, getTrendingID, removeMovieTrending,} from "../redux/actions/actionGetTrendingID"; import {useDispatch, useSelector} from 'react-redux'; import Movie from "../model/Movie"; -import Swipeable from 'react-native-gesture-handler/Swipeable'; -import {ListWidget} from "./WatchLaterScreen.js"; export default function HomeScreen({ navigation }: RootStackScreenProps<'Home'>) { // @ts-ignore @@ -95,7 +93,6 @@ export default function HomeScreen({ navigation }: RootStackScreenProps<'Home'>) function popFirstTrending(props: Movie){ dispatch(removeMovieTrending(props)); - dispatch(removeMovieTrending(props)); } function formatTime(time: number) { @@ -104,6 +101,21 @@ export default function HomeScreen({ navigation }: RootStackScreenProps<'Home'>) const minutes = time % 60; return `${hours}h ${minutes < 10 ? `0${minutes}` : minutes}m`; } + let rotateValueHolder = new Animated.Value(0); + + function startImageRotateFunction(){ + rotateValueHolder.setValue(0); + Animated.timing(rotateValueHolder, { + toValue: 0.5, + duration: 800, + easing: Easing.linear, + useNativeDriver: true, + }).start();} + + const RotateData = rotateValueHolder.interpolate({ + inputRange: [0, 1], + outputRange: ['0deg', '360deg'], + }); return( <> @@ -161,21 +173,23 @@ export default function HomeScreen({ navigation }: RootStackScreenProps<'Home'>) {trendingMovies[0].release_date} - + addWatchLater(trendingMovies[0])}> - popFirstTrending(trendingMovies[0])}> - popFirstTrending(trendingMovies[0]) }> + diff --git a/screens/WatchLaterScreen.tsx b/screens/WatchLaterScreen.tsx index 1df7f1a..0f63b5a 100644 --- a/screens/WatchLaterScreen.tsx +++ b/screens/WatchLaterScreen.tsx @@ -12,6 +12,9 @@ import {getTrendingID, getWatchLater, getWatchLaterMovies} from "../redux/action import Movie from "../model/Movie"; import Swipeable from "react-native-gesture-handler/Swipeable"; export default function WatchLaterScreen({ navigation }: RootTabScreenProps<'WatchLater'>) { + const [search, setSearch] = useState(''); + const [filteredDataSource, setFilteredDataSource] = useState([]); + const [masterDataSource, setMasterDataSource] = useState([]); const insets = useSafeAreaInsets(); const styles = StyleSheet.create({ container: { @@ -50,13 +53,23 @@ export default function WatchLaterScreen({ navigation }: RootTabScreenProps<'Wat console.log("test11111:", watchLaterMovies); loadWatchLater(); }, [dispatch]); - const leftContent = Pull to activate; - - const rightButtons = [ - Button 1, - Button 2 - ]; + const searchFilterFunction = (text : string) => { + if (text) { + const newData = watchLaterMovies.filter(function (item : Movie) { + const itemData = item.original_title + ? item.original_title.toUpperCase() + : ''.toUpperCase(); + const textData = text.toUpperCase(); + return itemData.indexOf(textData) > -1; + }); + setFilteredDataSource(newData); + setSearch(text); + } else { + setFilteredDataSource(masterDataSource); + setSearch(text); + } + }; return ( @@ -69,10 +82,12 @@ export default function WatchLaterScreen({ navigation }: RootTabScreenProps<'Wat /> - + searchFilterFunction(text)} + value={search} + > item.original_title} renderItem={({item}) => } /> @@ -136,7 +151,10 @@ return ( }}>{props.movie.original_title} {formatTime(props.movie.runtime)} - + } + />