-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMovieList.js
46 lines (43 loc) · 1.34 KB
/
MovieList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import { View, Text, TouchableOpacity, FlatList, StyleSheet } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import Poster from './Poster';
function Separator() {
return <View style={{ marginRight: 8 }} />;
}
export default function MovieList(props) {
const navigation = useNavigation();
return (
<View style={styles.container}>
<Text style={styles.title}>{props.title}</Text>
<FlatList
contentContainerStyle={styles.listContainer}
horizontal
data={props.data}
ItemSeparatorComponent={Separator}
showsHorizontalScrollIndicator={false}
keyExtractor={(_, index) => String(index)}
renderItem={({ item, index }) => (
<TouchableOpacity onPress={() => navigation.navigate('Details', { id: item.id })}>
<Poster path={item.poster_path} />
</TouchableOpacity>
)}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
marginBottom: 20,
},
listContainer: {
paddingLeft: 8,
},
title: {
color: '#E6E6E6',
fontSize: 15,
fontWeight: 'bold',
marginLeft: 8,
marginBottom: 8,
},
});