-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export enum ACCOUNT_NAVIGATOR_ROUTES { | ||
LOGIN = 'LOGIN', | ||
Check failure Code scanning / ESLint disallow unused variables Error
'LOGIN' is defined but never used.
|
||
REGISTER = 'REGISTER', | ||
Check failure Code scanning / ESLint disallow unused variables Error
'REGISTER' is defined but never used.
|
||
PROFILE = 'PROFILE', | ||
Check failure Code scanning / ESLint disallow unused variables Error
'PROFILE' is defined but never used.
|
||
} | ||
|
||
export type AccountNavigatorParamList = { | ||
[ACCOUNT_NAVIGATOR_ROUTES.LOGIN]: undefined; | ||
[ACCOUNT_NAVIGATOR_ROUTES.REGISTER]: undefined; | ||
[ACCOUNT_NAVIGATOR_ROUTES.PROFILE]: undefined; | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export enum TAB_BAR_NAVIGATOR_ROUTES { | ||
ACCOUNT = 'ACCOUNT', | ||
Check failure Code scanning / ESLint disallow unused variables Error
'ACCOUNT' is defined but never used.
|
||
CARROT = 'CARROT', | ||
Check failure Code scanning / ESLint disallow unused variables Error
'CARROT' is defined but never used.
|
||
SEARCH = 'SEARCH', | ||
Check failure Code scanning / ESLint disallow unused variables Error
'SEARCH' is defined but never used.
|
||
QRSCAN = 'QRSCAN', | ||
Check failure Code scanning / ESLint disallow unused variables Error
'QRSCAN' is defined but never used.
|
||
PLATE = 'PLATE', | ||
Check failure Code scanning / ESLint disallow unused variables Error
'PLATE' is defined but never used.
|
||
} | ||
|
||
export type TabBarNavigatorParamList = { | ||
[TAB_BAR_NAVIGATOR_ROUTES.ACCOUNT]: undefined; | ||
[TAB_BAR_NAVIGATOR_ROUTES.CARROT]: undefined; | ||
[TAB_BAR_NAVIGATOR_ROUTES.SEARCH]: undefined; | ||
[TAB_BAR_NAVIGATOR_ROUTES.QRSCAN]: undefined; | ||
[TAB_BAR_NAVIGATOR_ROUTES.PLATE]: undefined; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,15 @@ import {useNavigation} from '@react-navigation/native'; | |
|
||
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'; | ||
import AccountNavigator from '../AccountNavigator'; | ||
import {ACCOUNT_NAVIGATOR_ROUTES} from '../AccountNavigator/account-navigator.interfaces.ts'; | ||
import {ACCOUNT_NAVIGATOR_ROUTES} from '../AccountNavigator/AccountNavigator.interfaces.ts'; | ||
import CarrotScreen from '../../../screens/carrot/CarrotScreen'; | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
import { | ||
TAB_BAR_NAVIGATOR_ROUTES, | ||
TabBarNavigatorParamList, | ||
} from './TabNavigator.interfaces.ts'; | ||
|
||
const Tab = createBottomTabNavigator(); | ||
const Tab = createBottomTabNavigator<TabBarNavigatorParamList>(); | ||
|
||
const PlateScreen = () => null; | ||
const QRScanScreen = () => null; | ||
|
@@ -26,7 +30,7 @@ const TabNavigator = () => { | |
} else { | ||
console.log('user token not found'); | ||
// @ts-ignore | ||
navigate('Account'); | ||
navigate(TAB_BAR_NAVIGATOR_ROUTES.LOGIN); | ||
} | ||
}); | ||
}, [navigate]); | ||
|
@@ -37,42 +41,52 @@ const TabNavigator = () => { | |
({color, size}: {color: ColorValue; size: number}) => | ||
<Icon name={name} color={color} size={size} />; | ||
Check warning Code scanning / ESLint Disallow creating unstable components inside components Warning
Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “TabNavigator” and pass data as props.
|
||
return ( | ||
<Tab.Navigator initialRouteName="Carrot"> | ||
<Tab.Navigator | ||
initialRouteName={TAB_BAR_NAVIGATOR_ROUTES.ACCOUNT} | ||
screenOptions={{ | ||
headerShown: false, | ||
}}> | ||
<Tab.Screen | ||
name="Carrot" | ||
name={TAB_BAR_NAVIGATOR_ROUTES.CARROT} | ||
component={CarrotScreen} | ||
options={{ | ||
tabBarIcon: renderIcon('carrot'), | ||
}} | ||
/> | ||
<Tab.Screen | ||
name="Plate" | ||
name={TAB_BAR_NAVIGATOR_ROUTES.PLATE} | ||
component={PlateScreen} | ||
options={{ | ||
tabBarIcon: renderIcon('food'), | ||
}} | ||
/> | ||
<Tab.Screen | ||
name="QRScan" | ||
name={TAB_BAR_NAVIGATOR_ROUTES.QRSCAN} | ||
component={QRScanScreen} | ||
options={{ | ||
tabBarIcon: renderIcon('qrcode-scan'), | ||
}} | ||
/> | ||
<Tab.Screen | ||
name="Search" | ||
name={TAB_BAR_NAVIGATOR_ROUTES.SEARCH} | ||
component={SearchScreen} | ||
options={{ | ||
tabBarIcon: renderIcon('magnify'), | ||
}} | ||
/> | ||
<Tab.Screen | ||
name="Account" | ||
name={TAB_BAR_NAVIGATOR_ROUTES.ACCOUNT} | ||
component={AccountNavigator} | ||
options={({route}) => { | ||
const routeName = getFocusedRouteNameFromRoute(route) ?? ''; | ||
if (routeName === ACCOUNT_NAVIGATOR_ROUTES.LOGIN) { | ||
console.log('routeName', routeName); | ||
console.log(routeName); | ||
|
||
if (routeName === ACCOUNT_NAVIGATOR_ROUTES.PROFILE) { | ||
return { | ||
tabBarIcon: renderIcon('account'), | ||
}; | ||
} | ||
if (routeName === ACCOUNT_NAVIGATOR_ROUTES.LOGIN || routeName === ACCOUNT_NAVIGATOR_ROUTES.REGISTER) { | ||
Check failure Code scanning / ESLint Replace routeName·===·ACCOUNT_NAVIGATOR_ROUTES.LOGIN·||·routeName·===·ACCOUNT_NAVIGATOR_ROUTES.REGISTER with ⏎············routeName·===·ACCOUNT_NAVIGATOR_ROUTES.LOGIN·||⏎············routeName·===·ACCOUNT_NAVIGATOR_ROUTES.REGISTER⏎·········· Error
Replace routeName·===·ACCOUNT\_NAVIGATOR\_ROUTES.LOGIN·||·routeName·===·ACCOUNT\_NAVIGATOR\_ROUTES.REGISTER with ⏎············routeName·===·ACCOUNT\_NAVIGATOR\_ROUTES.LOGIN·||⏎············routeName·===·ACCOUNT\_NAVIGATOR\_ROUTES.REGISTER⏎··········
|
||
return { | ||
tabBarStyle: { | ||
display: 'none', | ||
|