Projekt

Obecné

Profil

Stáhnout (1.8 KB) Statistiky
| Větev: | Tag: | Revize:
1 29f3811f Schwobik
import { Box, Center, HStack, Image, Pressable, ScrollView, Text, VStack } from "native-base"
2 e49b1f44 Schwobik
import { useEffect } from "react"
3 04928342 Schwobik
import { DrawerScreenProps } from "@react-navigation/drawer"
4 29f3811f Schwobik
import { RootDrawerParamList } from "../../pages/Navigation"
5
import { ItemPreviewMissingImage } from "./ItemPreviewMissingImage"
6 8c3203e0 Schwobik
import { ITEM_PREVIEW_IMG_PREFIX_URL } from "../../api/constants"
7 9c55d3bb Schwobik
8
interface ItemPreviewProps {
9
    caption: string
10
    title: string
11 ca53e9f1 Schwobik
    name?: string
12
    image?: string
13 04928342 Schwobik
    itemId: string
14 29f3811f Schwobik
    inventoryLabel: string
15 04928342 Schwobik
    navigation: any
16 9c55d3bb Schwobik
}
17
18
const ItemPreview = (props: ItemPreviewProps) => {
19
20
    return (
21
        <>
22 04928342 Schwobik
            <Pressable
23
                onPress={() => props.navigation.navigate("Item", {itemId: props.itemId})}
24
                key={props.itemId}
25 ca53e9f1 Schwobik
            >
26 04928342 Schwobik
                <HStack
27
                    space={ 2 }
28
                    flex={ 1 }
29 29f3811f Schwobik
                    alignItems={ "flex-start" }
30
                    key={props.itemId}
31 04928342 Schwobik
                >
32 29f3811f Schwobik
                    {props.image ? (
33 04928342 Schwobik
                    <Image
34 8c3203e0 Schwobik
                        source={ {uri: `${ITEM_PREVIEW_IMG_PREFIX_URL}${props.image}`} }
35 04928342 Schwobik
                        size={ "sm" }
36 29f3811f Schwobik
                        alt={ props.image }
37 04928342 Schwobik
                    />
38 29f3811f Schwobik
                    ) : (
39
                        <ItemPreviewMissingImage inventoryLabel={props.inventoryLabel} h={65} w={65} />
40
                    )}
41
                    <VStack h={70} maxW={"80%"}>
42 04928342 Schwobik
                        <Text fontSize={"sm"} italic>{ props.name }</Text>
43 1980ed09 Schwobik
                        <Text fontSize={"sm"} bold noOfLines={1}>{ props.caption }</Text>
44 29f3811f Schwobik
                        <Text fontSize={"2xs"} lineHeight={"2xs"} noOfLines={2}>{ props.title }</Text>
45 04928342 Schwobik
                    </VStack>
46
                </HStack>
47
            </Pressable>
48 9c55d3bb Schwobik
        </>
49
    )
50
}
51
52
export default ItemPreview