Projekt

Obecné

Profil

Stáhnout (4.45 KB) Statistiky
| Větev: | Tag: | Revize:
1
import { HStack, CircleIcon, View, ScrollView, Button, Center, Heading, Pressable, Text, Box, Container, VStack, Icon, ArrowBackIcon, ChevronLeftIcon, ChevronRightIcon } from "native-base";
2
import { CertaintyWithColors } from "../../stores/reducers/itemSlice";
3
import { Concordance } from "../../types/item";
4
import LoadingBox from "../loading/LoadingBox";
5

    
6
// custom render Tab
7
const ItemTabBar = (props: { navigationState: { routes: any[] }, concordances: Concordance[], index: number, onIndexChange: any, onBackPressed: any }) => {
8

    
9
    const { concordances, onIndexChange, index, onBackPressed } = props
10

    
11
    if (concordances && concordances.length > 0) {
12
        return (
13
            <VStack>
14
                <HStack h="16" >
15
                    <HStack width="50%">
16
                        <Button variant="ghost" size="lg" marginLeft={0}
17
                            onPress={onBackPressed}
18
                            leftIcon={<ChevronLeftIcon size="lg" />}>
19
                            Back
20
                        </Button>
21
                    </HStack>
22
                    <HStack width="50%">
23
                        <HStack width="50%">
24

    
25
                        </HStack>
26
                        <HStack marginRight={0}>
27
                            <Button variant="ghost" size="lg"
28
                                onPress={() => onIndexChange(index - 1)}
29
                                leftIcon={<ChevronLeftIcon size="lg" />}>
30
                            </Button>
31
                            <Button variant="ghost" size="lg"
32
                                onPress={() => onIndexChange(index + 1)}
33
                                leftIcon={<ChevronRightIcon size="lg" />}>
34
                            </Button>
35
                        </HStack>
36
                    </HStack>
37
                </HStack>
38
                <View h="8">
39
                    <ScrollView contentContainerStyle={{ flexGrow: 1 }} flex="1" horizontal={true}>
40
                        {props.navigationState.routes.length > 1 ? (
41
                            <HStack borderBottomWidth={1} flex="1" borderColor="light.400">
42
                                {props.navigationState.routes.map((route, i) => {
43
                                    return (
44
                                        <Pressable key={i} onPress={() => { onIndexChange(i) }}>
45
                                            <HStack alignItems={"center"} width="32" borderColor="light.400" height="100%" borderBottomWidth={i == index ? 2 : 0}>
46
                                                <CircleIcon
47
                                                    marginLeft="20%"
48
                                                    size="2"
49
                                                    color={CertaintyWithColors[concordances[i].cert].color}
50
                                                />
51
                                                <Text marginLeft="5%">
52
                                                    {i == index ? <Text bold>{concordances[i].id}</Text> : concordances[i].id}
53

    
54
                                                </Text>
55
                                            </HStack>
56
                                        </Pressable>
57
                                    );
58
                                })}
59
                            </HStack>
60
                        ) : (
61
                            // One item only
62
                            <Pressable onPress={() => { onIndexChange(0) }} width="100%">
63
                                            <HStack alignItems={"center"} width="100%" borderColor="light.400" height="100%" borderBottomWidth={2}>
64
                                                <CircleIcon
65
                                                    marginLeft="42%"
66
                                                    size="2"
67
                                                    color={CertaintyWithColors[concordances[0].cert].color}
68
                                                />
69
                                                <Text marginLeft="2%">
70
                                                    <Text bold>{concordances[0].id}</Text>
71
                                                </Text>
72
                                            </HStack>
73
                                        </Pressable>
74
                        )}
75
                    </ScrollView>
76
                </View>
77
            </VStack>
78

    
79
        );
80
    }
81
    else {
82
        return <LoadingBox text={`Loading concordances...`}></LoadingBox>
83
    }
84
};
85

    
86
export default ItemTabBar
(1-1/2)