|
|
@ -1,16 +1,31 @@
|
|
|
|
import * as React from 'react';
|
|
|
|
import * as React from 'react';
|
|
|
|
import {Button,TouchableOpacity,ScrollView,View, Text, StyleSheet, Image, ImageBackground, SafeAreaView} from 'react-native';
|
|
|
|
import {
|
|
|
|
|
|
|
|
Button,
|
|
|
|
|
|
|
|
TouchableOpacity,
|
|
|
|
|
|
|
|
ScrollView,
|
|
|
|
|
|
|
|
View,
|
|
|
|
|
|
|
|
Text,
|
|
|
|
|
|
|
|
StyleSheet,
|
|
|
|
|
|
|
|
Image,
|
|
|
|
|
|
|
|
ImageBackground,
|
|
|
|
|
|
|
|
SafeAreaView,
|
|
|
|
|
|
|
|
ActivityIndicator
|
|
|
|
|
|
|
|
} from 'react-native';
|
|
|
|
import {RootStackScreenProps} from "../types";
|
|
|
|
import {RootStackScreenProps} from "../types";
|
|
|
|
import Rive from 'rive-react-native';
|
|
|
|
import Rive from 'rive-react-native';
|
|
|
|
import {useEffect, useRef} from "react";
|
|
|
|
import {useEffect, useRef, useState} from "react";
|
|
|
|
import {RiveViewManager} from "rive-react-native/lib/typescript/Rive.js";
|
|
|
|
import {RiveViewManager} from "rive-react-native/lib/typescript/Rive.js";
|
|
|
|
import {useSafeAreaInsets} from "react-native-safe-area-context";
|
|
|
|
import {useSafeAreaInsets} from "react-native-safe-area-context";
|
|
|
|
import {getTrendingID, } from "../redux/actions/actionGetTrendingID";
|
|
|
|
import {addMovieToWatchLater, getTrendingID, removeMovieTrending,} from "../redux/actions/actionGetTrendingID";
|
|
|
|
import {useDispatch, useSelector} from 'react-redux';
|
|
|
|
import {useDispatch, useSelector} from 'react-redux';
|
|
|
|
import Movie from "../model/Movie.js";
|
|
|
|
import Movie from "../model/Movie";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function HomeScreen({ navigation }: RootStackScreenProps<'Home'>) {
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
const trendingMovies = useSelector(state => state.appReducer.trendingMovies);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log("liste [0]: ", trendingMovies[0]);
|
|
|
|
|
|
|
|
|
|
|
|
export default function App({ navigation }: RootStackScreenProps<'Home'>) {
|
|
|
|
|
|
|
|
const riveRef = useRef();
|
|
|
|
|
|
|
|
const insets = useSafeAreaInsets();
|
|
|
|
const insets = useSafeAreaInsets();
|
|
|
|
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
const styles = StyleSheet.create({
|
|
|
@ -31,7 +46,6 @@ export default function App({ navigation }: RootStackScreenProps<'Home'>) {
|
|
|
|
marginRight:'auto',
|
|
|
|
marginRight:'auto',
|
|
|
|
borderRadius: 15,
|
|
|
|
borderRadius: 15,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
image: {
|
|
|
|
image: {
|
|
|
|
position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center', alignItems: 'center',
|
|
|
|
position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center', alignItems: 'center',
|
|
|
@ -58,25 +72,23 @@ export default function App({ navigation }: RootStackScreenProps<'Home'>) {
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
const trendingMovies = useSelector(state => state.appReducer.trendingMovies);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
|
|
|
|
let firstelement: Movie = trendingMovies[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
const loadTrendingID = async () => {
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
|
|
await dispatch(getTrendingID());
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
loadTrendingID();
|
|
|
|
|
|
|
|
firstelement = trendingMovies[0];
|
|
|
|
|
|
|
|
}, [dispatch]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
type ItemProps = {
|
|
|
|
const onPress = () => this.setState({trendingMovies: trendingMovies.shift()}) ;
|
|
|
|
movie : Movie
|
|
|
|
return (
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function addWatchLater(props: Movie){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//dispatch(addMovieToWatchLater(props));
|
|
|
|
|
|
|
|
dispatch(removeMovieTrending(props));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
<SafeAreaView style={styles.background}>
|
|
|
|
<SafeAreaView style={styles.background}>
|
|
|
|
<ImageBackground blurRadius={20}
|
|
|
|
<ImageBackground blurRadius={20}
|
|
|
|
style={{
|
|
|
|
style={{
|
|
|
@ -88,14 +100,14 @@ export default function App({ navigation }: RootStackScreenProps<'Home'>) {
|
|
|
|
opacity: 0.28
|
|
|
|
opacity: 0.28
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
source={{
|
|
|
|
source={{
|
|
|
|
uri: firstelement.poster_path,
|
|
|
|
uri: trendingMovies[0].poster_path,
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
></ImageBackground>
|
|
|
|
></ImageBackground>
|
|
|
|
<View style={styles.image}>
|
|
|
|
<View style={styles.image}>
|
|
|
|
<Image
|
|
|
|
<Image
|
|
|
|
style={styles.filmCard}
|
|
|
|
style={styles.filmCard}
|
|
|
|
source={{
|
|
|
|
source={{
|
|
|
|
uri: firstelement.poster_path,
|
|
|
|
uri: trendingMovies[0].poster_path,
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
@ -125,16 +137,15 @@ export default function App({ navigation }: RootStackScreenProps<'Home'>) {
|
|
|
|
<BadgeFilm name={"9:11"}></BadgeFilm>
|
|
|
|
<BadgeFilm name={"9:11"}></BadgeFilm>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<View>
|
|
|
|
<View>
|
|
|
|
<Text numberOfLines={1} style={{color: "white", fontSize: 28, fontWeight: "bold", paddingTop: 5}}>{firstelement.original_title}</Text>
|
|
|
|
<Text numberOfLines={1} style={{color: "white", fontSize: 28, fontWeight: "bold", paddingTop: 5}}>{trendingMovies[0].original_title}</Text>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<Text style={{color: "grey", fontSize: 20, fontWeight: "bold"}}>{firstelement.release_date}</Text>
|
|
|
|
<Text style={{color: "grey", fontSize: 20, fontWeight: "bold"}}>{trendingMovies[0].release_date}</Text>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<View style={{ flexDirection: 'row' ,alignItems: 'center', justifyContent: "space-evenly", paddingHorizontal: 30, height: '15%', width:'100%'}}>
|
|
|
|
<View style={{ flexDirection: 'row' ,alignItems: 'center', justifyContent: "space-evenly", paddingHorizontal: 30, height: '15%', width:'100%'}}>
|
|
|
|
<TouchableOpacity onPress={onPress}>
|
|
|
|
<TouchableOpacity onPress={() => addWatchLater(trendingMovies[0])}>
|
|
|
|
<Image
|
|
|
|
<Image
|
|
|
|
source={require('../assets/images/WatchLater.png')} style={{ resizeMode:"stretch", height:'65%', aspectRatio: 1,}}
|
|
|
|
source={require('../assets/images/WatchLater.png')} style={{ resizeMode:"stretch", height:'65%', aspectRatio: 1,}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
</TouchableOpacity>
|
|
|
|
<TouchableOpacity>
|
|
|
|
<TouchableOpacity>
|
|
|
|
<Image
|
|
|
|
<Image
|
|
|
@ -149,10 +160,9 @@ export default function App({ navigation }: RootStackScreenProps<'Home'>) {
|
|
|
|
|
|
|
|
|
|
|
|
</TouchableOpacity>
|
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</SafeAreaView>
|
|
|
|
</SafeAreaView>);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
type BadgeGenreProps = {
|
|
|
|
type BadgeGenreProps = {
|
|
|
|
name : String
|
|
|
|
name : String
|
|
|
|
isSelected: Boolean
|
|
|
|
isSelected: Boolean
|
|
|
|