-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGifDetailsScreen.tsx
47 lines (45 loc) · 1.22 KB
/
GifDetailsScreen.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
39
40
41
42
43
44
45
46
47
import React from 'react';
import GifQuery from './GifQuery';
import { ActivityIndicator, View, Image, Text } from 'react-native';
const GifDetailsScreen = ({ navigation }) => {
const gifId = navigation.getParam('id');
if (!gifId) {
return null;
}
return (
<GifQuery variables={{ id: gifId }}>
{({ gif }) => {
if (!gif) {
return (
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}
>
<ActivityIndicator />
</View>
);
}
return (
<View style={{ flex: 1 }}>
<Image source={{ uri: gif.url }} style={{ height: 300 }} />
<Text>{gif.title}</Text>
<Text>{gif.source}</Text>
{gif.user && gif.user.displayName && (
<Text>{gif.user.displayName}</Text>
)}
{gif.user && gif.user.avatarUrl && (
<Image
source={{ uri: gif.user.avatarUrl }}
style={{ height: 100, width: 100 }}
/>
)}
</View>
);
}}
</GifQuery>
);
};
export default GifDetailsScreen;