Skip to content

Commit 181f531

Browse files
committed
ref(routes): routes optimization
1 parent 521d6aa commit 181f531

File tree

8 files changed

+534
-490
lines changed

8 files changed

+534
-490
lines changed

App.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Platform, StatusBar} from 'react-native';
33
import {NavigationContainer} from '@react-navigation/native';
44
// eslint-disable-next-line no-unused-vars
55
import AppsStateService from './src/services/appStates';
6-
import {NavigationScreens} from './src/routes';
6+
import {NavigationScreens} from './src/router/router';
77
import {SafeAreaProvider} from 'react-native-safe-area-context';
88
import {LoadingSheet} from './src/components/loadingSheet';
99
import FlashMessage from 'react-native-flash-message';
@@ -15,6 +15,7 @@ function App() {
1515
StatusBar.setBackgroundColor('black');
1616
}
1717
} catch (e) {}
18+
1819
const CoingrigTheme = {
1920
colors: {
2021
background: Colors.background,

src/i18n/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import i18n from 'i18next';
22
import {initReactI18next} from 'react-i18next';
3-
var numeral = require('numeral');
3+
const numeral = require('numeral');
44
import english from './languages/en.json';
55
import french from './languages/fr.json';
66
// import romanian from './languages/ro.json';

src/router/router.tsx

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* eslint-disable react-native/no-inline-styles */
2+
import React from 'react';
3+
import 'react-native-gesture-handler';
4+
import {createStackNavigator} from '@react-navigation/stack';
5+
import {screens} from './utils/screens';
6+
7+
const Stack = createStackNavigator();
8+
9+
// const BT = React.memo(BottomTabs);
10+
// export const NavigationScreens = React.memo(NS);
11+
12+
export const NavigationScreens = () => {
13+
return (
14+
<Stack.Navigator>
15+
{screens?.map(({name, component, options}) => (
16+
<Stack.Screen
17+
key={name}
18+
name={name}
19+
component={component}
20+
options={options}
21+
/>
22+
))}
23+
</Stack.Navigator>
24+
);
25+
};

src/router/utils/components/Icon.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
import Ionicons from 'react-native-vector-icons/Ionicons';
3+
import {Colors} from 'utils/colors';
4+
5+
const Icon = () => (
6+
<Ionicons
7+
name="close"
8+
size={30}
9+
color={Colors.foreground}
10+
style={{padding: 10}}
11+
/>
12+
);
13+
14+
export default Icon;

src/router/utils/index.tsx

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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

Comments
 (0)