1
|
import { HStack, CircleIcon, View, ScrollView, Button, Center, Heading, Pressable, Text, Box } 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 }) => {
|
8
|
|
9
|
const { concordances, onIndexChange, index } = props
|
10
|
|
11
|
if (concordances && concordances.length > 0) {
|
12
|
return (
|
13
|
<View h="16">
|
14
|
<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
|
</ScrollView>
|
51
|
</View>
|
52
|
);
|
53
|
}
|
54
|
else {
|
55
|
return <LoadingBox text={`Loading concordances...`}></LoadingBox>
|
56
|
}
|
57
|
};
|
58
|
|
59
|
export default ItemTabBar
|