Advertisement
zidniryi

maintab.js

Sep 8th, 2020
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.56 KB | None | 0 0
  1. import React from 'react'
  2. import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'
  3. import Ionicons from 'react-native-vector-icons/Ionicons'
  4. import {responsiveFontSize} from 'react-native-responsive-dimensions'
  5.  
  6. import HomeScreen from '../homeScreen/homeScreen'
  7. import colorThemes from '../../__global__/styles/themes/colorThemes'
  8. import AccountScreen from '../homeScreen/accountScreen'
  9. import {StyleSheet, View, Image} from 'react-native'
  10. import TabNavigator from '../../__global__/libs/react-native-tab-navigator'
  11.  
  12. export default function MainTab() {
  13. const [selectedTab, setselectedTab] = React.useState('home')
  14.  
  15. return (
  16. <TabNavigator style={styles.container}>
  17. <TabNavigator.Item
  18. selected={selectedTab === 'home'}
  19. title="Home"
  20. selectedTitleStyle={{color: '#FF7158'}}
  21. tabStyle={{
  22. borderTopWidth: selectedTab === 'home' ? 3 : 0,
  23. borderTopColor: '#FF7158',
  24. backgroundColor: selectedTab === 'home' ? '#fff8f6' : '#FFFFFF',
  25. }}
  26. renderIcon={() => (
  27. <Image
  28. source={require('images/mainTab/ic_beranda.png')}
  29. style={{width: 18, height: 18}}
  30. />
  31. )}
  32. renderSelectedIcon={() => (
  33. <Image
  34. source={require('images/mainTab/ic_beranda-actives.png')}
  35. style={{width: 18, height: 18}}
  36. />
  37. )}
  38. onPress={() => setselectedTab('home')}>
  39. <HomeScreen />
  40. </TabNavigator.Item>
  41. <TabNavigator.Item
  42. selected={selectedTab === 'profile'}
  43. title="Pemesanan"
  44. selectedTitleStyle={{color: '#FF7158'}}
  45. tabStyle={{
  46. borderTopWidth: selectedTab === 'profile' ? 3 : 0,
  47. borderTopColor: '#FF7158',
  48. backgroundColor: selectedTab === 'profile' ? '#fff8f6' : '#FFFFFF',
  49. }}
  50. renderIcon={() => (
  51. <Image
  52. source={require('images/mainTab/ic_pemesanan-inactive.png')}
  53. resizeMode="stretch"
  54. style={{width: 18, height: 18}}
  55. />
  56. )}
  57. renderSelectedIcon={() => (
  58. <Image
  59. source={require('images/mainTab/ic_pemesanan-active.png')}
  60. resizeMode="stretch"
  61. style={{width: 18, height: 18}}
  62. />
  63. )}
  64. onPress={() => setselectedTab('profile')}>
  65. <AccountScreen selected={() => setselectedTab('home')} />
  66. </TabNavigator.Item>
  67. <TabNavigator.Item
  68. selected={selectedTab === 'riwayat'}
  69. accessibilityLabel={'menuAkun'}
  70. title="Akun"
  71. selectedTitleStyle={{color: '#FF7158'}}
  72. tabStyle={{
  73. borderTopWidth: selectedTab === 'riwayat' ? 3 : 0,
  74. borderTopColor: '#FF7158',
  75. backgroundColor: selectedTab === 'riwayat' ? '#fff8f6' : '#FFFFFF',
  76. }}
  77. renderIcon={() => (
  78. <Image
  79. source={require('images/mainTab/ic_akun-inactive.png')}
  80. resizeMode="stretch"
  81. style={{width: 18, height: 18}}
  82. />
  83. )}
  84. renderSelectedIcon={() => (
  85. <Image
  86. source={require('images/mainTab/ic_akun-active.png')}
  87. resizeMode="stretch"
  88. style={{width: 18, height: 18}}
  89. />
  90. )}
  91. renderBadge={() => (
  92. <View
  93. style={{
  94. width: 10,
  95. height: 10,
  96. backgroundColor: '#FF7158',
  97. borderRadius: 50,
  98. }}></View>
  99. )}
  100. onPress={() => setselectedTab('riwayat')}>
  101. <AccountScreen />
  102. </TabNavigator.Item>
  103.  
  104. <TabNavigator.Item
  105. selected={selectedTab === 'user'}
  106. accessibilityLabel={'menuAkun'}
  107. title="Akun"
  108. selectedTitleStyle={{color: '#FF7158'}}
  109. tabStyle={{
  110. borderTopWidth: selectedTab === 'user' ? 3 : 0,
  111. borderTopColor: '#FF7158',
  112. backgroundColor: selectedTab === 'user' ? '#fff8f6' : '#FFFFFF',
  113. }}
  114. renderIcon={() => (
  115. <Image
  116. source={require('images/mainTab/ic_akun-inactive.png')}
  117. resizeMode="stretch"
  118. style={{width: 18, height: 18}}
  119. />
  120. )}
  121. renderSelectedIcon={() => (
  122. <Image
  123. source={require('images/mainTab/ic_akun-active.png')}
  124. resizeMode="stretch"
  125. style={{width: 18, height: 18}}
  126. />
  127. )}
  128. renderBadge={() => (
  129. <View
  130. style={{
  131. width: 10,
  132. height: 10,
  133. backgroundColor: '#FF7158',
  134. borderRadius: 50,
  135. }}></View>
  136. )}
  137. onPress={() => setselectedTab('user')}>
  138. <AccountScreen />
  139. </TabNavigator.Item>
  140. </TabNavigator>
  141. )
  142. }
  143.  
  144. const styles = StyleSheet.create({
  145. container: {
  146. flex: 1,
  147. justifyContent: 'center',
  148. alignItems: 'center',
  149. backgroundColor: '#FFFFFF',
  150. },
  151. welcome: {
  152. fontSize: 20,
  153. textAlign: 'center',
  154. margin: 10,
  155. },
  156. instructions: {
  157. textAlign: 'center',
  158. color: '#333333',
  159. marginBottom: 5,
  160. },
  161. })
  162.  
  163. // const Tab = createBottomTabNavigator()
  164. // function MainTab() {
  165. // return (
  166. // <Tab.Navigator
  167. // screenOptions={({route}) => ({
  168. // tabBarIcon: ({focused, color, size}) => {
  169. // let iconName
  170.  
  171. // if (route.name === 'Beranda') {
  172. // iconName = focused ? 'ios-home' : 'ios-home'
  173. // } else if (route.name === 'Dompet') {
  174. // iconName = focused ? 'ios-wallet' : 'ios-wallet'
  175. // } else if (route.name === 'Order') {
  176. // iconName = focused ? 'ios-document' : 'ios-document'
  177. // } else if (route.name === 'Akun') {
  178. // iconName = focused ? 'ios-contact' : 'ios-contact'
  179. // }
  180.  
  181. // // You can return any component that you like here!
  182. // return (
  183. // <Ionicons
  184. // name={iconName}
  185. // size={responsiveFontSize(2.8)}
  186. // color={color}
  187. // />
  188. // )
  189. // },
  190. // })}
  191. // tabBarOptions={{
  192. // activeTintColor: colorThemes.blue0,
  193. // inactiveTintColor: 'grey',
  194. // activeBackgroundColor: '#ddeeff',
  195. // }}>
  196. // <Tab.Screen name="Beranda" component={HomeScreen} />
  197. // <Tab.Screen name="Dompet" component={HomeScreen} />
  198. // <Tab.Screen name="Order" component={HomeScreen} />
  199. // <Tab.Screen name="Akun" component={AccountScreen} />
  200. // </Tab.Navigator>
  201. // )
  202. // }
  203. // export default MainTab
  204.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement