|
@@ -1,11 +1,100 @@
|
1
|
1
|
# Third Party Libraries Support
|
2
|
2
|
|
3
|
3
|
## Redux
|
4
|
|
-!> This is deprecated in favor of [Registering screens with wrapping provider component](https://wix.github.io/react-native-navigation/#/docs/top-level-api-migration?id=registering-screens-with-wrapping-provider-component)
|
5
|
|
-### registerComponentWithRedux(screenID, generator, Provider, store)
|
6
|
|
-Utility helper function like registerComponent,
|
7
|
|
-wraps the provided component with a react-redux Provider with the passed redux store
|
8
|
4
|
|
|
5
|
+Create a HOC which provides the redux store.
|
9
|
6
|
```js
|
10
|
|
-Navigation.registerComponentWithRedux('navigation.playground.WelcomeScreen', () => WelcomeScreen, Provider, store);
|
|
7
|
+import { Provider } from 'react-redux';
|
|
8
|
+
|
|
9
|
+let store;
|
|
10
|
+function ReduxProvider(Component) {
|
|
11
|
+ store = store || createStore({});
|
|
12
|
+
|
|
13
|
+ return (props) => (
|
|
14
|
+ <Provider store={store}>
|
|
15
|
+ <Component {...props} />
|
|
16
|
+ </Provider>
|
|
17
|
+ );
|
|
18
|
+}
|
|
19
|
+```
|
|
20
|
+Wrap all Screens, which need the redux store, with the HOC.
|
|
21
|
+```js
|
|
22
|
+import { Navigation } from 'react-native-navigation';
|
|
23
|
+
|
|
24
|
+export default () => {
|
|
25
|
+ Navigation.registerComponent('TestScreen', () => ReduxProvider(TestScreen), () => TestScreen);
|
|
26
|
+}
|
|
27
|
+```
|
|
28
|
+
|
|
29
|
+For more information about how to set up redux read the [react-redux docs](https://react-redux.js.org/)
|
|
30
|
+
|
|
31
|
+## react-native-vector-icons
|
|
32
|
+This liabry can be used to set icons as the following example does.
|
|
33
|
+For available icons read the [react-native-vector-icons docs](https://github.com/oblador/react-native-vector-icons).
|
|
34
|
+
|
|
35
|
+```js
|
|
36
|
+import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
37
|
+import { Navigation } from 'react-native-navigation';
|
|
38
|
+
|
|
39
|
+export default function startApp() {
|
|
40
|
+ Promise.all([
|
|
41
|
+ MaterialIcons.getImageSource('home', 25),
|
|
42
|
+ MaterialIcons.getImageSource('menu', 25),
|
|
43
|
+ MaterialIcons.getImageSource('search', 25),
|
|
44
|
+ MaterialIcons.getImageSource('add', 25),
|
|
45
|
+ ]).then(([homeIcon, menuIcon, searchIcon, addIcon]) => {
|
|
46
|
+ Navigation.setRoot({
|
|
47
|
+ root: {
|
|
48
|
+ sideMenu: {
|
|
49
|
+ id: 'main',
|
|
50
|
+ left: {
|
|
51
|
+ component: {
|
|
52
|
+ name: 'App.FirstBottomTab.HomeScreen',
|
|
53
|
+ },
|
|
54
|
+ },
|
|
55
|
+ center: {
|
|
56
|
+ bottomTabs: {
|
|
57
|
+ id: 'BottomTabs',
|
|
58
|
+ children: [{
|
|
59
|
+ stack: {
|
|
60
|
+ id: 'FirstBottomTab',
|
|
61
|
+ children: [{
|
|
62
|
+ component: {
|
|
63
|
+ name: 'App.FirstBottomTab.HomeScreen',
|
|
64
|
+ },
|
|
65
|
+ }],
|
|
66
|
+ options: {
|
|
67
|
+ topBar: {
|
|
68
|
+ title: {
|
|
69
|
+ text: 'Home',
|
|
70
|
+ },
|
|
71
|
+ leftButtons: [{
|
|
72
|
+ id: 'sideMenu',
|
|
73
|
+ icon: menuIcon,
|
|
74
|
+ }],
|
|
75
|
+ rightButtons: [{
|
|
76
|
+ id: 'search',
|
|
77
|
+ icon: searchIcon,
|
|
78
|
+ }],
|
|
79
|
+ },
|
|
80
|
+ bottomTab: {
|
|
81
|
+ text: 'FirstBottomTab',
|
|
82
|
+ icon: homeIcon,
|
|
83
|
+ },
|
|
84
|
+ fab: {
|
|
85
|
+ id: 'addRecipe',
|
|
86
|
+ icon: addIcon,
|
|
87
|
+ },
|
|
88
|
+ },
|
|
89
|
+ },
|
|
90
|
+ }],
|
|
91
|
+ },
|
|
92
|
+ },
|
|
93
|
+ },
|
|
94
|
+ },
|
|
95
|
+ });
|
|
96
|
+ });
|
|
97
|
+}
|
11
|
98
|
```
|
|
99
|
+
|
|
100
|
+Its also possible to to define custom icons without react-native-vector-icons within the iOS and Android project as described [here](https://wix.github.io/react-native-navigation/#/docs/styling?id=custom-tab-icons).
|