Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 6020775f

Přidáno uživatelem Fantič před více než 1 rok

re #10917: ZoomableImage init

Zobrazit rozdíly:

src/components/item/ItemView.tsx
1
import { Center, Box, VStack, Button, HStack, Text, Image, ScrollView, View, Spacer, Card, Heading, Switch, Flex, ChevronLeftIcon, ChevronRightIcon, Divider, Pressable, CircleIcon, IconButton } from "native-base"
1
import { Center, Box, VStack, Button, HStack, Text, Image, ScrollView, View, Spacer, Card, Heading, Switch, Flex, ChevronLeftIcon, ChevronRightIcon, Divider, Pressable, CircleIcon, IconButton, useToast } from "native-base"
2 2
import React, { useCallback, useEffect, useState } from "react"
3 3
import { Certainty, Item, RelationshipType } from "../../types/item"
4 4
import { Note } from "../../types/note"
......
18 18
import { CertaintyWithColors } from "../../stores/reducers/itemSlice"
19 19
import { LeftArrowIcon, RightArrowIcon } from "../general/Icons"
20 20
import { ZoomableImage } from "./ZoomableImage"
21
import { InfoToast } from "../toast/InfoToast"
21 22

  
22 23
interface ItemDetailProps {
23 24
    item: Item,
......
29 30

  
30 31
const ItemDetail = (props: ItemDetailProps) => {
31 32
    const item = props.item;
32

  
33
    const toast = useToast();
33 34
    const [selectedImage, setSelectedImage] = useState<number>(0);
34 35

  
35 36
    const [images, setImages] = useState<{ imageUrl: string, title: string }[]>([]);
......
48 49
                :
49 50
                (
50 51
                    <ScrollView flex="1" paddingLeft={2.5} paddingRight={2.5} marginTop={2.5}>
52

  
51 53
                        <VStack>
52
                            <HStack marginLeft={2.5} alignItems={"center"}>
53
                                <VStack flex={1} marginTop={3.5}>
54

  
55
                            <VStack flex={1} marginTop={3.5} marginLeft={1.5} >
56
                                <HStack alignItems="center" height="auto">
54 57
                                    <Text fontSize={13} color="#4D4D4D">
55 58
                                        {item.authorDisplayName ? item.authorDisplayName : item.authorName}
56 59
                                    </Text>
57
                                    <Heading marginTop={1} fontSize={18} color="#4D4D4D">
60
                                    <HStack marginRight={0} marginLeft="auto" width={70}>
61
                                        <Button disabled={!item.prevItem} padding={1} marginLeft="auto" variant="ghost" size="xs"
62
                                            onPress={() => {
63
                                                if (item.prevItem) {
64
                                                    console.log(item.prevItem)
65
                                                    props.navigation.navigate("Item", { itemId: item.prevItem.toString() })
66
                                                }
67
                                                else {
68
                                                    toast.show({
69
                                                        render: ({
70
                                                            id
71
                                                        }) => {
72
                                                            return <InfoToast text={"No previous item..."} onClose={() => toast.close(id)} />;
73
                                                        },
74
                                                        duration: 3000
75
                                                    });
76
                                                }
77
                                            }}
78
                                            leftIcon={<ChevronLeftIcon size="md" />}>
79
                                        </Button>
80
                                        <Button disabled={!item.nextItem}  marginLeft="auto" padding={1} marginRight={2.5} variant="ghost" size="xs"
81
                                            onPress={() => {
82

  
83
                                                if (item.nextItem) {
84
                                                    props.navigation.navigate("Item", { itemId: item.nextItem.toString() })
85
                                                }
86
                                                else {
87
                                                    toast.show({
88
                                                        render: ({
89
                                                            //@ts-ignore
90
                                                            id
91
                                                        }) => {
92
                                                            return <InfoToast text={"No next item..."} onClose={() => toast.close(id)} />;
93
                                                        },
94
                                                        duration: 3000
95
                                                    });
96
                                                }
97
                                            }}
98
                                            leftIcon={<ChevronRightIcon size="md" />}>
99
                                        </Button>
100
                                    </HStack>
101
                                </HStack>
102
                                <HStack alignItems="center" height="auto" marginTop={1}>
103
                                    <Heading marginBottom="auto" fontSize={18} color="#4D4D4D">
58 104
                                        {item.workName}
59 105
                                    </Heading>
60

  
61
                                </VStack>
62
                                <Box marginLeft="auto" marginTop={1.5} alignItems={"end"}> {/* marginLeft: "auto" pushes the Box to the right */}
63
                                    <Button variant="outline" backgroundColor={"#F4DFAB"} borderRadius={8} size="sm" padding={0.5} paddingLeft={2} paddingRight={2} >
106
                                    <Button marginLeft="auto" marginTop="auto" marginRight={2.5} variant="outline" backgroundColor={"#F4DFAB"} borderRadius={8} size="sm" padding={0.5} paddingLeft={2} paddingRight={2} >
64 107
                                        <Text color="#654B07" fontSize={12}>
65 108
                                            {item?.concordances?.[0]?.id}
66 109
                                        </Text>
67 110
                                    </Button>
68
                                </Box>
69
                            </HStack>
70

  
71

  
72

  
111
                                </HStack>
112
                            </VStack>
73 113

  
74 114
                            <View marginTop={5} backgroundColor="#F5F4F1" borderRadius={10} borderColor="#F5F4F1" padding={2}>
75 115
                                {item.inventoryItem &&

Také k dispozici: Unified diff