Newer
Older
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { useTranslation } from 'react-i18next';
import { StyleSheet, Text, View } from 'react-native';
import { ColorPallet, TextTheme } from 'src/theme/theme';
import {
Screens,
Stacks,
TabStackParams,
TabStacks,
import ContactStack from './ContactStack';
import SealStack from './SealStack';
import CredentialStack from './CredentialStack';
import CredentialSvg from 'src/assets/svg/credential.svg';
import ScanSvg from 'src/assets/svg/scan.svg';
import ConnectionsSvg from 'src/assets/svg/connections.svg';
import SealHistorySvg from 'src/assets/svg/seal_history.svg';
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
const MainTabNavigator = createBottomTabNavigator<TabStackParams>();
type TabBarIconProps = {
focused: boolean;
Svg: React.FC<any>;
};
type TabBarLabelProps = {
label: string;
};
const TabBarIcon = ({ Svg, focused }: TabBarIconProps) => {
return (
<View style={styles.tabView}>
<Svg
style={[
styles.tabBarIcon,
focused ? styles.tabBarIconFocused : undefined,
]}
resizeMode="contain"
/>
</View>
);
};
const TabBarLabel = ({ label }: TabBarLabelProps) => {
return (
<Text style={styles.tabBarLabel} numberOfLines={1}>
{label}
</Text>
);
};
const TabStack: React.FC = () => {
const { t } = useTranslation();
return (
<MainTabNavigator.Navigator
screenOptions={{
tabBarStyle: styles.tabBarStyle,
tabBarActiveTintColor: ColorPallet.baseColors.white,
tabBarInactiveTintColor: ColorPallet.brand.primary,
headerShown: false,
tabBarHideOnKeyboard: true,
unmountOnBlur: true,
tabBarShowLabel: true,
tabBarLabelPosition: 'below-icon',
}}
>
<MainTabNavigator.Screen
name={TabStacks.CredentialStack}
component={CredentialStack}
options={{
tabBarIcon: ({ focused }) => (
<TabBarIcon focused={focused} Svg={CredentialSvg} />
),
tabBarLabel: () => (
<TabBarLabel label={t<string>('TabStack.Credentials')} />
),
unmountOnBlur: true,
}}
/>
<MainTabNavigator.Screen
name={TabStacks.ScanStack}
options={{
tabBarIcon: () => <TabBarIcon focused={false} Svg={ScanSvg} />,
tabBarLabel: () => (
<TabBarLabel label={t<string>('TabStack.Scan')} />
),
tabBarAccessibilityLabel: t<string>('TabStack.Scan'),
}}
listeners={({ navigation }) => ({
tabPress: e => {
e.preventDefault();
navigation.navigate(Screens.Scan);
},
})}
>
{/* Just a placeholder, the tab will navigate to a different stack */}
{() => <View />}
</MainTabNavigator.Screen>
<MainTabNavigator.Screen
name={TabStacks.ConnectionStack}
component={ContactStack}
options={{
tabBarIcon: ({ focused }) => (
<TabBarIcon focused={focused} Svg={ConnectionsSvg} />
),
tabBarLabel: () => (
<TabBarLabel label={t<string>('TabStack.Connections')} />
),
unmountOnBlur: true,
}}
/>
<MainTabNavigator.Screen
name={TabStacks.SealStack}
component={SealStack}
options={{
tabBarIcon: ({ focused }) => (
<TabBarIcon focused={focused} Svg={SealHistorySvg} />
),
tabBarLabel: () => (
<TabBarLabel label={t<string>('TabStack.SealHistory')} />
),
unmountOnBlur: true,
}}
listeners={({ navigation }) => ({
tabPress: e => {
e.preventDefault();
navigation.navigate(TabStacks.SealStack, {
screen: Screens.SealScannedQrCodeList,
});
},
})}
/>
</MainTabNavigator.Navigator>
);
};
export default TabStack;
const styles = StyleSheet.create({
tabBarStyle: {
height: 80,
backgroundColor: ColorPallet.grayscale.veryLightGrey,
borderTopWidth: 0,
paddingBottom: 0,
marginRight: 10,
marginLeft: 10,
marginBottom: 10,
borderRadius: 24,
},
tabView: {
height: 45,
width: 45,
alignItems: 'center',
justifyContent: 'center',
},
tabBarLabel: {
...TextTheme.label,
fontWeight: 'normal',
paddingBottom: 5,
color: ColorPallet.grayscale.black,
},
tabBarIcon: {
height: 40,
width: 40,
fill: ColorPallet.grayscale.black,
},
tabBarIconFocused: {
fill: ColorPallet.brand.primary,
},
});