1 |
faf84222
|
Fantič
|
import { HStack, CircleIcon, View, ScrollView, Button, Center, Heading, Pressable, Text, Box } 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 |
a7a9a204
|
Fantič
|
const ItemTabBar = (props: { navigationState: { routes: any[] }, concordances: Concordance[], index: number, onIndexChange: any }) => {
|
8 |
d281786c
|
Fantič
|
|
9 |
a7a9a204
|
Fantič
|
const { concordances, onIndexChange, index } = props
|
10 |
d281786c
|
Fantič
|
|
11 |
faf84222
|
Fantič
|
if (concordances && concordances.length > 0) {
|
12 |
a7a9a204
|
Fantič
|
return (
|
13 |
|
|
<View h="16">
|
14 |
faf84222
|
Fantič
|
<ScrollView width="100%" horizontal={true}>
|
15 |
|
|
{props.navigationState.routes.length > 100 ? (
|
16 |
|
|
<HStack>
|
17 |
|
|
{props.navigationState.routes.map((route, i) => {
|
18 |
|
|
return (
|
19 |
|
|
<Button
|
20 |
|
|
size="lg"
|
21 |
|
|
key={i}
|
22 |
|
|
variant={index == i ? "subtle" : "outline"}
|
23 |
|
|
rightIcon={
|
24 |
|
|
<CircleIcon
|
25 |
|
|
size="2"
|
26 |
|
|
color={CertaintyWithColors[concordances[i].cert].color}
|
27 |
|
|
/>
|
28 |
|
|
}
|
29 |
|
|
onPress={() => onIndexChange(i)}
|
30 |
|
|
>
|
31 |
|
|
{concordances[i].id}
|
32 |
|
|
</Button>
|
33 |
|
|
);
|
34 |
|
|
})}
|
35 |
|
|
</HStack>
|
36 |
|
|
) : (
|
37 |
|
|
// One item only
|
38 |
|
|
<Pressable size="96" variant="outline"
|
39 |
|
|
onPress={() => onIndexChange(0)}
|
40 |
|
|
>
|
41 |
|
|
<Box width="100%" background="red.100">
|
42 |
|
|
<Text>{concordances[0].id}</Text>
|
43 |
|
|
<CircleIcon
|
44 |
|
|
size="2"
|
45 |
|
|
color={CertaintyWithColors[concordances[0].cert].color}
|
46 |
|
|
/>
|
47 |
|
|
</Box >
|
48 |
|
|
</Pressable>
|
49 |
|
|
)}
|
50 |
a7a9a204
|
Fantič
|
</ScrollView>
|
51 |
|
|
</View>
|
52 |
faf84222
|
Fantič
|
);
|
53 |
|
|
}
|
54 |
d281786c
|
Fantič
|
else {
|
55 |
a7a9a204
|
Fantič
|
return <LoadingBox text={`Loading concordances...`}></LoadingBox>
|
56 |
d281786c
|
Fantič
|
}
|
57 |
a7a9a204
|
Fantič
|
};
|
58 |
d281786c
|
Fantič
|
|
59 |
a7a9a204
|
Fantič
|
export default ItemTabBar
|