-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGifList.tsx
38 lines (36 loc) · 1 KB
/
GifList.tsx
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
import React, { FunctionComponent } from 'react';
import { Gif } from './GifsQuery';
import { FlatList, TouchableOpacity } from 'react-native';
import { Card } from 'react-native-paper';
const GifList: FunctionComponent<{
gifs: Gif[];
onEndReached: () => void;
onCardPress?: (id) => void;
}> = ({ gifs, onEndReached, onCardPress }) => {
return (
<FlatList
style={{ width: '100%', backgroundColor: '#F2F2F2' }}
data={gifs}
keyExtractor={item => item.id}
renderItem={({ item: gif }) => (
<TouchableOpacity
onPress={() => {
if (onCardPress) {
onCardPress(gif.id);
}
}}
>
<Card
style={{ marginHorizontal: 10, marginVertical: 5 }}
elevation={5}
>
<Card.Cover source={{ uri: gif.urlSmall }} />
<Card.Title title={gif.title} />
</Card>
</TouchableOpacity>
)}
onEndReached={onEndReached}
/>
);
};
export default GifList;