Skip to content

Commit 4a6545c

Browse files
authored
Merge pull request #6 from noddy1996/ios
Tab navigation is configured
2 parents a0d521c + 5339def commit 4a6545c

8 files changed

+101
-24
lines changed

App.js

+18-15
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,33 @@
88

99
import React from 'react';
1010
import MainStack from './app/routing/MainStack';
11-
import { Provider } from "react-redux"
12-
import { StatusBar } from 'react-native'
11+
import {Provider} from 'react-redux';
12+
import {StatusBar} from 'react-native';
1313
import storePre from './app/redux/store';
1414
import DropdownAlert from 'react-native-dropdownalert';
15-
import { AlertHelper } from './app/utils/AlertHelper';
16-
import { PersistGate } from 'redux-persist/integration/react'
17-
15+
import {AlertHelper} from './app/utils/AlertHelper';
16+
import {PersistGate} from 'redux-persist/integration/react';
17+
import TabNavigationStack from './app/routing/TabNavigationStack';
18+
import {navigationTypeTabs} from './app.json';
1819
const App: () => React$Node = () => {
19-
const { persistor, store } = storePre;
20+
const {persistor, store} = storePre;
2021

2122
return (
2223
<Provider store={store}>
23-
<PersistGate loading={null} persistor={persistor}>
24-
<MainStack/>
25-
<DropdownAlert
26-
defaultContainer={{ padding: 8, paddingTop: StatusBar.currentHeight, flexDirection: 'row' }}
27-
ref={ref => AlertHelper.setDropDown(ref)}
24+
<PersistGate loading={null} persistor={persistor}>
25+
{navigationTypeTabs ? <TabNavigationStack /> : <MainStack />}
26+
<DropdownAlert
27+
defaultContainer={{
28+
padding: 8,
29+
paddingTop: StatusBar.currentHeight,
30+
flexDirection: 'row',
31+
}}
32+
ref={(ref) => AlertHelper.setDropDown(ref)}
2833
onClose={() => AlertHelper.invokeOnClose()}
2934
/>
30-
</PersistGate>
35+
</PersistGate>
3136
</Provider>
32-
)
33-
37+
);
3438
};
3539

36-
3740
export default App;

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ See [Getting Started](https://facebook.github.io/react-native/docs/getting-start
1717
- [Redux-persist](https://github.com/rt2zz/redux-persist) `6.0.0` Persist and rehydrate a redux store. Javascript apps
1818
- [Alert](https://github.com/testshallpass/react-native-dropdownalert) `4.3.0` An alert to notify users
1919
- [Babel](http://babeljs.io/) `7.2.3` for ES6+ support
20+
- [Bottom-Tabs](https://github.com/react-navigation/react-navigation) `5.11.11` for Bottom Navigations
2021
- [Navigation for React Native](https://reactnavigation.org/) a router based on new React Native Navigation API
2122

2223
## Libraries
2324
- [@react-native-community/masked-view](https://github.com/react-native-community/react-native-masked-view) `0.1.10`
2425
- [@react-navigation/native](https://github.com/react-navigation/react-navigation) `5.7.3`
2526
- [@react-navigation/stack](https://github.com/react-navigation/react-navigation) `5.9.0`
27+
- [Bottom-Tabs](https://github.com/react-navigation/react-navigation) `5.11.11`
2628
- [react-native-gesture-handler](https://github.com/software-mansion/react-native-gesture-handler) `1.7.0`
2729
- [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated) `1.13.0`
2830
- [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) `3.1.7`
@@ -77,7 +79,10 @@ $ react-native run-ios
7779
```sh
7880
$ react-native run-android
7981
```
82+
#### 4. How to Decide the Navigation
8083

84+
* Navigation is decided By **navigationTypeTabs** Key definend in [app.json](./app.json).
85+
* **navigationTypeTabs** : true, will give you the bottom Tabs and vice versa.
8186
## Debugger
8287
- [React Native Debugger](https://github.com/jhen0409/react-native-debugger) : The standalone app based on official debugger of React Native, and includes React Inspector / Redux DevTools
8388
- [redux-devtools-extension](https://github.com/zalmoxisus/redux-devtools-extension) `2.13.5`

app.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"name": "react_native_redux_starter",
3-
"displayName": "react_native_redux_starter"
3+
"displayName": "react_native_redux_starter",
4+
"navigationTypeTabs": true
45
}

app/routing/MainStack.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
import React from 'react'
2-
import { createStackNavigator } from '@react-navigation/stack';
3-
import { NavigationContainer } from '@react-navigation/native';
1+
import React from 'react';
2+
import {createStackNavigator} from '@react-navigation/stack';
3+
import {NavigationContainer} from '@react-navigation/native';
44
import Home from '../screens/Home';
5+
import {RoutesList} from './routes';
56

67
const Stack = createStackNavigator();
78

89
export default function MainStack() {
910
return (
10-
<NavigationContainer>
11-
<Stack.Navigator screenOptions={{headerShown:false}}>
12-
<Stack.Screen name="Home" component={Home} />
13-
</Stack.Navigator>
11+
<NavigationContainer>
12+
<Stack.Navigator screenOptions={{headerShown: false}}>
13+
{RoutesList?.map((route, key) => {
14+
const {name, component} = route;
15+
return <Stack.Screen key={key} name={name} component={component} />;
16+
})}
17+
</Stack.Navigator>
1418
</NavigationContainer>
1519
);
16-
}
20+
}

app/routing/TabNavigationStack.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @author Amusoftech <er.amudeep@gmail.com>
3+
* @description Minimal example of Tab Navigations
4+
*/
5+
import * as React from 'react';
6+
import {Text, View} from 'react-native';
7+
import {NavigationContainer} from '@react-navigation/native';
8+
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
9+
import {RoutesList} from './routes';
10+
import {appColors} from '../utils/appColors';
11+
12+
const Tab = createBottomTabNavigator();
13+
14+
export default function TabNavigationStack() {
15+
return (
16+
<NavigationContainer>
17+
<Tab.Navigator
18+
tabBarOptions={{
19+
activeTintColor: appColors.primary,
20+
inactiveTintColor: appColors.secondary,
21+
}}>
22+
{RoutesList?.map((route, key) => {
23+
const {name, component, options} = route;
24+
return (
25+
<Tab.Screen
26+
key={key}
27+
name={name}
28+
component={component}
29+
options={options}
30+
/>
31+
);
32+
})}
33+
</Tab.Navigator>
34+
</NavigationContainer>
35+
);
36+
}

app/routing/routes.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @author Amusoftech <er.amudeep@gmail.com>
3+
* @description List of routes for Tabs Navigator and Stack navigator, Along addational Option for Tabs
4+
*/
5+
import Home from '../screens/Home';
6+
import {appColors} from '../utils/appColors';
7+
8+
export const RoutesList = [
9+
{
10+
name: 'Home',
11+
component: Home,
12+
options: {
13+
tabBarBadge: 3,
14+
tabBarLabel: 'Home',
15+
//.... rest are the params for Tab.Screen See : https://reactnavigation.org/docs/bottom-tab-navigator/#options
16+
},
17+
},
18+
];

package-lock.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"@react-native-community/async-storage": "^1.12.1",
1414
"@react-native-community/masked-view": "^0.1.10",
15+
"@react-navigation/bottom-tabs": "^5.11.11",
1516
"@react-navigation/native": "^5.8.10",
1617
"@react-navigation/stack": "^5.12.8",
1718
"react": "^17.0.1",

0 commit comments

Comments
 (0)