Newer
Older
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { useTranslation } from 'react-i18next';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { ColorPallet, TextTheme } from 'src/theme/theme';
import {
Screens,
TabStackParams,
TabStacks,
import ContactStack from './ContactStack';
import SealStack from './SealStack';
import CredentialStack from './CredentialStack';
import CredentialSvg from 'src/assets/svg/credential.svg';
import ConnectionsSvg from 'src/assets/svg/connections.svg';
import SealHistorySvg from 'src/assets/svg/seal_history.svg';
import EmailSvg from 'src/assets/svg/e-mail-black.svg';
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
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.ConnectionStack}
component={ContactStack}
options={{
tabBarIcon: ({ focused }) => (
<TabBarIcon focused={focused} Svg={ConnectionsSvg} />
),
tabBarLabel: () => (
<TabBarLabel label={t<string>('TabStack.Contacts')} />
),
unmountOnBlur: true,
}}
/>
name={TabStacks.SealStack}
component={SealStack}
<TabBarIcon focused={focused} Svg={SealHistorySvg} />
<TabBarLabel label={t<string>('TabStack.SealHistory')} />
),
unmountOnBlur: true,
}}
listeners={({ navigation }) => ({
tabPress: e => {
e.preventDefault();
navigation.navigate(TabStacks.SealStack, {
screen: Screens.SealScannedQrCodeList,
name={TabStacks.EmailStack}
component={EmailStack}
options={{
tabBarIcon: ({ focused }) => (
<TabBarIcon focused={focused} Svg={EmailSvg} />
<TabBarLabel label={t<string>('TabStack.Emails')} />
),
unmountOnBlur: true,
}}
listeners={({ navigation }) => ({
tabPress: e => {
e.preventDefault();
navigation.navigate(TabStacks.EmailStack, {
screen: Screens.ReceivedEmails,
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
174
175
176
177
});
},
})}
/>
</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,
},
});