1
|
import { Center, Box, VStack, Button, HStack, Text, Image, ScrollView, View, Spacer, Card, Heading } from "native-base"
|
2
|
import React from "react"
|
3
|
import { Item } from "../../types/item"
|
4
|
import { Note } from "../../types/note"
|
5
|
import LoadingBox from "../loading/LoadingBox"
|
6
|
import NotesListView from "../notes/NotesListView"
|
7
|
|
8
|
interface ItemDetailProps {
|
9
|
item: Item,
|
10
|
itemLoading: boolean,
|
11
|
notes: Note[],
|
12
|
notesLoading: boolean
|
13
|
}
|
14
|
|
15
|
const ItemDetail = (props: { item: Item }) => {
|
16
|
const item = props.item;
|
17
|
|
18
|
return (
|
19
|
<ScrollView flex="1">
|
20
|
<Box width="90%" marginLeft="5%">
|
21
|
{
|
22
|
item && (
|
23
|
<VStack>
|
24
|
<HStack marginTop="5%">
|
25
|
<VStack width="75%">
|
26
|
<Text>
|
27
|
{item.authorDisplayName ? item.authorDisplayName : item.authorName}
|
28
|
</Text>
|
29
|
<Heading size="sm">
|
30
|
{item.workName}
|
31
|
</Heading>
|
32
|
|
33
|
</VStack>
|
34
|
<Box width="25%">
|
35
|
<Button variant="outline" size="md">
|
36
|
{item.concordances[0].id}
|
37
|
</Button>
|
38
|
</Box>
|
39
|
</HStack>
|
40
|
<Card shadow="1" marginTop="5%">
|
41
|
{item.inventoryItem &&
|
42
|
<VStack>
|
43
|
<Text italic>
|
44
|
<Text color="light.500">Inventory item: </Text>
|
45
|
{item.inventoryItem}
|
46
|
</Text>
|
47
|
<Text italic marginTop="2.5%">
|
48
|
{item.searchSubjects.map((subject, index) => (
|
49
|
index < item.searchSubjects.length -1 ? (subject + ", ") : (subject)
|
50
|
))}
|
51
|
</Text>
|
52
|
</VStack>}
|
53
|
</Card>
|
54
|
{item.fullView && item.imageUrl && (
|
55
|
<Center background="primary.100" marginTop="5%">
|
56
|
<Text>Resembling object</Text>
|
57
|
<Image size={250} alt="image" source={{ uri: `http:147.228.173.159/static/images/${item.imageUrl}` }} />
|
58
|
</Center>)}
|
59
|
{item.fullView && (
|
60
|
<Card shadow="1" marginTop="5%" marginBottom="5%">
|
61
|
{item.authorName &&
|
62
|
<HStack>
|
63
|
<Text italic marginTop="2.5%">
|
64
|
<Text color="light.500">Author name: </Text>
|
65
|
{item.authorName}
|
66
|
</Text>
|
67
|
</HStack>}
|
68
|
{item.title &&
|
69
|
<HStack>
|
70
|
<Text italic marginTop="2.5%">
|
71
|
<Text color="light.500">Title: </Text>
|
72
|
{item.title}
|
73
|
</Text>
|
74
|
</HStack>}
|
75
|
{item.institution &&
|
76
|
<HStack>
|
77
|
<Text italic marginTop="2.5%">
|
78
|
<Text color="light.500">Institution: </Text>
|
79
|
{item.institution.name}, Inv. No. {item.institution.inventoryNumber}, {item.institution.city} {"(" + item.institution.country + ")"}
|
80
|
</Text>
|
81
|
</HStack>}
|
82
|
{item.repository &&
|
83
|
<HStack>
|
84
|
<Text italic marginTop="2.5%">
|
85
|
<Text color="light.500">Repository: </Text>
|
86
|
{item.repository}
|
87
|
</Text>
|
88
|
</HStack>}
|
89
|
{item.provenance &&
|
90
|
<HStack>
|
91
|
<Text italic marginTop="2.5%">
|
92
|
<Text color="light.500">Provenance: </Text>
|
93
|
{item.provenance}
|
94
|
</Text>
|
95
|
</HStack>}
|
96
|
{item.description &&
|
97
|
<HStack>
|
98
|
<Text italic marginTop ="2.5%">
|
99
|
<Text color="light.500">Description: </Text>
|
100
|
{item.description}
|
101
|
</Text>
|
102
|
</HStack>}
|
103
|
</Card>)}
|
104
|
</VStack>
|
105
|
)
|
106
|
}
|
107
|
</Box>
|
108
|
</ScrollView>
|
109
|
);
|
110
|
}
|
111
|
|
112
|
|
113
|
|
114
|
const ItemView = (props: ItemDetailProps) => {
|
115
|
|
116
|
// item shown / note shown
|
117
|
const [itemShown, setItemShown] = React.useState(true);
|
118
|
|
119
|
const { itemLoading, notesLoading } = props;
|
120
|
|
121
|
const handleItemClick = () => {
|
122
|
setItemShown(true);
|
123
|
}
|
124
|
|
125
|
const handleNotesClick = () => {
|
126
|
setItemShown(false);
|
127
|
}
|
128
|
|
129
|
return (
|
130
|
<Box display="flex" flex={1} flexDirection="column" justifyContent="space-between">
|
131
|
{itemShown ? (
|
132
|
itemLoading ?
|
133
|
<LoadingBox text="Item loading" />
|
134
|
:
|
135
|
<ItemDetail item={props.item} />
|
136
|
) : (
|
137
|
notesLoading ?
|
138
|
<LoadingBox text="Notes loading" />
|
139
|
:
|
140
|
<NotesListView notes={props.notes} />
|
141
|
)}
|
142
|
|
143
|
{/* item notes switch tab */}
|
144
|
<HStack alignItems="center">
|
145
|
<Button
|
146
|
variant={itemShown ? "subtle" : "outline"}
|
147
|
w="50%"
|
148
|
onPress={handleItemClick}
|
149
|
>
|
150
|
Item
|
151
|
</Button>
|
152
|
<Button
|
153
|
variant={itemShown ? "outline" : "subtle"}
|
154
|
w="50%"
|
155
|
onPress={handleNotesClick}
|
156
|
>
|
157
|
Notes
|
158
|
</Button>
|
159
|
</HStack>
|
160
|
</Box>
|
161
|
)
|
162
|
}
|
163
|
|
164
|
export default ItemView
|