Projekt

Obecné

Profil

Stáhnout (7.11 KB) Statistiky
| Větev: | Tag: | Revize:
1 091dec61 Fantič
import { Center, Box, VStack, Button, HStack, Text, Image, ScrollView, View, Spacer, Card, Heading } from "native-base"
2 852de08e Fantič
import React from "react"
3 b88520f8 Fantič
import { Item } from "../../types/item"
4
import { Note } from "../../types/note"
5 a7a9a204 Fantič
import LoadingBox from "../loading/LoadingBox"
6 cb25df10 Fantič
import NotesListView from "../notes/NotesListView"
7 b88520f8 Fantič
8
interface ItemDetailProps {
9
    item: Item,
10 852de08e Fantič
    itemLoading: boolean,
11
    notes: Note[],
12
    notesLoading: boolean
13 b88520f8 Fantič
}
14
15
const ItemDetail = (props: { item: Item }) => {
16
    const item = props.item;
17 852de08e Fantič
18 b88520f8 Fantič
    return (
19 091dec61 Fantič
        <ScrollView flex="1">
20
            <Box width="90%" marginLeft="5%">
21
                {
22
                    item && (
23 852de08e Fantič
                        <VStack>
24 091dec61 Fantič
                            <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 852de08e Fantič
                                    <Image size={250} alt="image" source={{ uri: `http:147.228.173.159/static/images/${item.imageUrl}` }} />
58 091dec61 Fantič
                                </Center>)}
59
                            {item.fullView && (
60
                                <Card shadow="1" marginTop="5%" marginBottom="5%">
61
                                    {item.authorName &&
62
                                        <HStack>
63 191f2cc7 Fantič
                                            <Text italic  marginTop="2.5%">
64 091dec61 Fantič
                                                <Text color="light.500">Author name: </Text>
65
                                                {item.authorName}
66
                                            </Text>
67
                                        </HStack>}
68
                                    {item.title &&
69
                                        <HStack>
70 191f2cc7 Fantič
                                            <Text italic  marginTop="2.5%">
71 091dec61 Fantič
                                                <Text color="light.500">Title: </Text>
72
                                                {item.title}
73
                                            </Text>
74
                                        </HStack>}
75
                                    {item.institution &&
76
                                        <HStack>
77 191f2cc7 Fantič
                                            <Text italic  marginTop="2.5%">
78 091dec61 Fantič
                                                <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 191f2cc7 Fantič
                                            <Text italic  marginTop="2.5%">
85 091dec61 Fantič
                                                <Text color="light.500">Repository: </Text>
86
                                                {item.repository}
87
                                            </Text>
88
                                        </HStack>}
89
                                    {item.provenance &&
90
                                        <HStack>
91 191f2cc7 Fantič
                                            <Text italic  marginTop="2.5%">
92 091dec61 Fantič
                                                <Text color="light.500">Provenance: </Text>
93
                                                {item.provenance}
94
                                            </Text>
95
                                        </HStack>}
96
                                    {item.description &&
97
                                        <HStack>
98 191f2cc7 Fantič
                                            <Text italic  marginTop ="2.5%">
99 091dec61 Fantič
                                                <Text color="light.500">Description: </Text>
100
                                                {item.description}
101
                                            </Text>
102
                                        </HStack>}
103
                                </Card>)}
104 852de08e Fantič
                        </VStack>
105 091dec61 Fantič
                    )
106
                }
107
            </Box>
108
        </ScrollView>
109 b88520f8 Fantič
    );
110
}
111
112
113
114
const ItemView = (props: ItemDetailProps) => {
115
116
    // item shown / note shown
117
    const [itemShown, setItemShown] = React.useState(true);
118
119 091dec61 Fantič
    const { itemLoading, notesLoading } = props;
120 852de08e Fantič
121 b88520f8 Fantič
    const handleItemClick = () => {
122
        setItemShown(true);
123
    }
124
125
    const handleNotesClick = () => {
126
        setItemShown(false);
127
    }
128
129
    return (
130 852de08e Fantič
        <Box display="flex" flex={1} flexDirection="column" justifyContent="space-between">
131 b88520f8 Fantič
            {itemShown ? (
132 091dec61 Fantič
                itemLoading ?
133
                    <LoadingBox text="Item loading" />
134
                    :
135
                    <ItemDetail item={props.item} />
136 b88520f8 Fantič
            ) : (
137 091dec61 Fantič
                notesLoading ?
138
                    <LoadingBox text="Notes loading" />
139
                    :
140
                    <NotesListView notes={props.notes} />
141 b88520f8 Fantič
            )}
142 852de08e Fantič
143
            {/* item notes switch tab */}
144
            <HStack alignItems="center">
145 091dec61 Fantič
                <Button
146 852de08e Fantič
                    variant={itemShown ? "subtle" : "outline"}
147
                    w="50%"
148 b88520f8 Fantič
                    onPress={handleItemClick}
149
                >
150
                    Item
151
                </Button>
152 091dec61 Fantič
                <Button
153 852de08e Fantič
                    variant={itemShown ? "outline" : "subtle"}
154
                    w="50%"
155 b88520f8 Fantič
                    onPress={handleNotesClick}
156
                >
157
                    Notes
158
                </Button>
159
            </HStack>
160 852de08e Fantič
        </Box>
161 b88520f8 Fantič
    )
162
}
163
164
export default ItemView