|
| 1 | +import React from 'react'; |
| 2 | +import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; |
| 3 | +import CONFIG from 'config'; |
| 4 | +import Icon from 'react-native-vector-icons/Ionicons'; |
| 5 | +import {Image, Platform, View, Text} from 'react-native'; |
| 6 | +import {Colors} from 'utils/colors'; |
| 7 | +import {tabs} from './tabs'; |
| 8 | + |
| 9 | +export const isTestnet = () => { |
| 10 | + if (!CONFIG.TESTNET) { |
| 11 | + return; |
| 12 | + } |
| 13 | + return ( |
| 14 | + <View |
| 15 | + style={{ |
| 16 | + backgroundColor: '#d9534f', |
| 17 | + padding: 5, |
| 18 | + borderRadius: 5, |
| 19 | + marginLeft: 15, |
| 20 | + }}> |
| 21 | + <Text |
| 22 | + style={{ |
| 23 | + color: 'white', |
| 24 | + fontSize: 10, |
| 25 | + }}> |
| 26 | + TESTNET |
| 27 | + </Text> |
| 28 | + </View> |
| 29 | + ); |
| 30 | +}; |
| 31 | + |
| 32 | +export const TabLogo = (inverse = false) => { |
| 33 | + return ( |
| 34 | + <View |
| 35 | + style={{ |
| 36 | + flexDirection: 'row', |
| 37 | + justifyContent: 'center', |
| 38 | + alignItems: 'center', |
| 39 | + }}> |
| 40 | + <Image |
| 41 | + source={require('../../assets/logo_small.png')} |
| 42 | + style={{ |
| 43 | + height: 280 / 13, |
| 44 | + width: 279 / 13, |
| 45 | + tintColor: inverse ? Colors.foreground : Colors.background, |
| 46 | + marginLeft: 3, |
| 47 | + }} |
| 48 | + /> |
| 49 | + </View> |
| 50 | + ); |
| 51 | +}; |
| 52 | + |
| 53 | +export const SmallLogo = () => { |
| 54 | + return ( |
| 55 | + <View |
| 56 | + style={{ |
| 57 | + flexDirection: 'row', |
| 58 | + justifyContent: 'center', |
| 59 | + alignItems: 'center', |
| 60 | + }}> |
| 61 | + <Image |
| 62 | + source={require('../../assets/logo_small.png')} |
| 63 | + style={{ |
| 64 | + height: 280 / 13, |
| 65 | + width: 279 / 13, |
| 66 | + tintColor: Colors.foreground, |
| 67 | + marginLeft: 3, |
| 68 | + }} |
| 69 | + /> |
| 70 | + {isTestnet()} |
| 71 | + </View> |
| 72 | + ); |
| 73 | +}; |
| 74 | + |
| 75 | +const Tab = createBottomTabNavigator(); |
| 76 | + |
| 77 | +export function BottomTabs() { |
| 78 | + return ( |
| 79 | + <Tab.Navigator |
| 80 | + initialRouteName="Dashboard" |
| 81 | + headerMode="screen" |
| 82 | + screenOptions={({route}) => ({ |
| 83 | + tabBarShowLabel: false, |
| 84 | + tabBarActiveTintColor: '#FFFFFF', |
| 85 | + tabBarActiveBackgroundColor: Colors.foreground, |
| 86 | + tabBarStyle: { |
| 87 | + borderTopWidth: 0, |
| 88 | + elevation: 0, |
| 89 | + height: Platform.OS === 'android' ? 60 : 75, |
| 90 | + marginTop: 3, |
| 91 | + }, |
| 92 | + tabBarItemStyle: { |
| 93 | + marginHorizontal: 20, |
| 94 | + borderRadius: 40, |
| 95 | + paddingVertical: 5, |
| 96 | + marginBottom: Platform.OS === 'android' && 10, |
| 97 | + }, |
| 98 | + tabBarIcon: ({focused}) => { |
| 99 | + if (route.name === 'Dashboard') { |
| 100 | + return focused ? TabLogo(false) : TabLogo(true); |
| 101 | + } else if (route.name === 'PortfolioScreen') { |
| 102 | + return ( |
| 103 | + <Icon |
| 104 | + name="wallet" |
| 105 | + size={24} |
| 106 | + color={focused ? Colors.inverse : Colors.foreground} |
| 107 | + /> |
| 108 | + ); |
| 109 | + } else if (route.name === 'MarketScreen') { |
| 110 | + return ( |
| 111 | + <Icon |
| 112 | + name="stats-chart" |
| 113 | + size={22} |
| 114 | + color={focused ? Colors.inverse : Colors.foreground} |
| 115 | + /> |
| 116 | + ); |
| 117 | + } |
| 118 | + return null; |
| 119 | + }, |
| 120 | + })}> |
| 121 | + {tabs?.map(({name, component, options}) => ( |
| 122 | + <Tab.Screen |
| 123 | + key={name} |
| 124 | + name={name} |
| 125 | + component={component} |
| 126 | + options={options} |
| 127 | + /> |
| 128 | + ))} |
| 129 | + </Tab.Navigator> |
| 130 | + ); |
| 131 | +} |
0 commit comments