1 |
1054fe09
|
Fantič
|
import { HStack, CircleIcon, View, ScrollView, Button, Center, Heading, Pressable, Text, Box, Container, VStack, Icon, ArrowBackIcon, ChevronLeftIcon, ChevronRightIcon } from "native-base";
|
2 |
d281786c
|
Fantič
|
import { CertaintyWithColors } from "../../stores/reducers/itemSlice";
|
3 |
|
|
import { Concordance } from "../../types/item";
|
4 |
a7a9a204
|
Fantič
|
import LoadingBox from "../loading/LoadingBox";
|
5 |
d281786c
|
Fantič
|
|
6 |
|
|
// custom render Tab
|
7 |
1054fe09
|
Fantič
|
const ItemTabBar = (props: { navigationState: { routes: any[] }, concordances: Concordance[], index: number, onIndexChange: any, onBackPressed: any }) => {
|
8 |
d281786c
|
Fantič
|
|
9 |
1054fe09
|
Fantič
|
const { concordances, onIndexChange, index, onBackPressed } = props
|
10 |
d281786c
|
Fantič
|
|
11 |
faf84222
|
Fantič
|
if (concordances && concordances.length > 0) {
|
12 |
a7a9a204
|
Fantič
|
return (
|
13 |
1054fe09
|
Fantič
|
<VStack>
|
14 |
|
|
<HStack h="16" >
|
15 |
|
|
<HStack width="50%">
|
16 |
091dec61
|
Fantič
|
<Button variant="ghost" size="lg" marginLeft={0}
|
17 |
1054fe09
|
Fantič
|
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 |
091dec61
|
Fantič
|
<Button variant="ghost" size="lg"
|
28 |
191f2cc7
|
Fantič
|
onPress={() => onIndexChange(index - 1)}
|
29 |
1054fe09
|
Fantič
|
leftIcon={<ChevronLeftIcon size="lg" />}>
|
30 |
|
|
</Button>
|
31 |
091dec61
|
Fantič
|
<Button variant="ghost" size="lg"
|
32 |
191f2cc7
|
Fantič
|
onPress={() => onIndexChange(index + 1)}
|
33 |
1054fe09
|
Fantič
|
leftIcon={<ChevronRightIcon size="lg" />}>
|
34 |
|
|
</Button>
|
35 |
faf84222
|
Fantič
|
</HStack>
|
36 |
1054fe09
|
Fantič
|
</HStack>
|
37 |
|
|
</HStack>
|
38 |
191f2cc7
|
Fantič
|
<View h="8">
|
39 |
1054fe09
|
Fantič
|
<ScrollView contentContainerStyle={{ flexGrow: 1 }} flex="1" horizontal={true}>
|
40 |
|
|
{props.navigationState.routes.length > 1 ? (
|
41 |
191f2cc7
|
Fantič
|
<HStack borderBottomWidth={1} flex="1" borderColor="light.400">
|
42 |
1054fe09
|
Fantič
|
{props.navigationState.routes.map((route, i) => {
|
43 |
|
|
return (
|
44 |
191f2cc7
|
Fantič
|
<Pressable key={i} onPress={() => { onIndexChange(i) }}>
|
45 |
|
|
<HStack alignItems={"center"} width="32" borderColor="light.400" height="100%" borderBottomWidth={i == index ? 2 : 0}>
|
46 |
1054fe09
|
Fantič
|
<CircleIcon
|
47 |
191f2cc7
|
Fantič
|
marginLeft="20%"
|
48 |
1054fe09
|
Fantič
|
size="2"
|
49 |
|
|
color={CertaintyWithColors[concordances[i].cert].color}
|
50 |
|
|
/>
|
51 |
191f2cc7
|
Fantič
|
<Text marginLeft="5%">
|
52 |
|
|
{i == index ? <Text bold>{concordances[i].id}</Text> : concordances[i].id}
|
53 |
|
|
|
54 |
|
|
</Text>
|
55 |
|
|
</HStack>
|
56 |
|
|
</Pressable>
|
57 |
1054fe09
|
Fantič
|
);
|
58 |
|
|
})}
|
59 |
|
|
</HStack>
|
60 |
|
|
) : (
|
61 |
|
|
// One item only
|
62 |
191f2cc7
|
Fantič
|
<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 |
1054fe09
|
Fantič
|
)}
|
75 |
|
|
</ScrollView>
|
76 |
|
|
</View>
|
77 |
|
|
</VStack>
|
78 |
|
|
|
79 |
faf84222
|
Fantič
|
);
|
80 |
|
|
}
|
81 |
d281786c
|
Fantič
|
else {
|
82 |
a7a9a204
|
Fantič
|
return <LoadingBox text={`Loading concordances...`}></LoadingBox>
|
83 |
d281786c
|
Fantič
|
}
|
84 |
a7a9a204
|
Fantič
|
};
|
85 |
d281786c
|
Fantič
|
|
86 |
a7a9a204
|
Fantič
|
export default ItemTabBar
|