Skip to content

Commit 6a9e330

Browse files
author
alvaromb
committed
Improved README
1 parent e568d3f commit 6a9e330

1 file changed

Lines changed: 105 additions & 1 deletion

File tree

README.md

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,106 @@
11
# react-native-navigator-wrapper
2-
A React Native Navigator component wrapper that implements nested navigators for both push and modal transitions.
2+
A React Native Navigator component wrapper that implements nested navigators for
3+
both push and modal transitions.
4+
5+
## Installation
6+
You can install this component through ``npm``:
7+
8+
```shell
9+
npm i react-native-navigator-wrapper --save
10+
```
11+
12+
You also need to install the awesome
13+
[``react-native-vector-icons``](https://github.com/oblador/react-native-vector-icons#installation)
14+
from Joel Oblador (in order to use the back button arrow icon) and include the
15+
``Ionicons.ttf`` font in your project. All the components of the library are
16+
written in ES6/ES7 style.
17+
18+
## Motivation
19+
This library implements the nested ``Navigator`` strategy to let the developer
20+
to use both push-like transitions and modal transitions that can also handle
21+
push navigation inside them. Think about a login/signup process. You can let the
22+
user to browse your app and then present a modal when they want to register.
23+
Once the modal is open, you can provide push navigation between signup or register
24+
screens. This is what tries to solve this component.
25+
26+
Take this pseudo-jsx code as an example:
27+
28+
```js
29+
<Navigator
30+
renderScene={(route, navigator) => {
31+
if (route.id === 'innerNavigator') {
32+
// This navigator uses push-like transitions
33+
return <Navigator />
34+
}
35+
// This navigator also uses push-like transitions, but it is opened using
36+
// FloatFromBottom scene config
37+
return <Navigator />
38+
}}
39+
/>
40+
```
41+
42+
The parent navigator will push new components using ``FloatFromBottom``. Both
43+
inner navigators will use ``FloatFromRight``, but the inner navigator will keep
44+
the default navigation history and the other navigator is going to be used when
45+
presenting a modal component. With this you can have push navigation inside a
46+
modal component.
47+
48+
## Usage
49+
This library can be used in several ways. It's composed from a couple of different
50+
components that interact with each other. In short, it has a navigation bar that
51+
mimics the iOS navigation bar and two navigation wrappers. Expect an Android
52+
style navigation bar soon.
53+
54+
### Nested navigation with ``TopNavigatorWrapper``
55+
You can use ``TopNavigatorWrapper`` component to bring the nested navigator
56+
strategy just importing the component and wrapping whatever you want to render
57+
inside it:
58+
59+
```js
60+
import React from 'react-native'
61+
import TopNavigatorWrapper from 'react-native-navigator-wrapper'
62+
import MyComponent from './MyComponent'
63+
64+
class MyApp extends React.Component {
65+
render () {
66+
return (
67+
<TopNavigatorWrapper
68+
initialComponent={MyComponent}
69+
title='My App'
70+
/>
71+
)
72+
}
73+
}
74+
```
75+
76+
You component ``MyComponent`` will have two props, **navigator** and
77+
**topNavigator**. They will let you to push new components from right using
78+
the first one or open a modal pushing from the second one.
79+
80+
### Navigation with ``NavigationWrapper``
81+
If you just want to use the navigation bar inside a navigator, use the
82+
``NavigationWrapper`` component:
83+
84+
```js
85+
import React from 'react-native'
86+
import NavigationWrapper from 'react-native-navigator-wrapper'
87+
88+
class MyComponent extends React.Component {
89+
render () {
90+
return (
91+
<NavigationWrapper
92+
initialComponent={Component}
93+
title='Title'
94+
passProps={}
95+
/>
96+
)
97+
}
98+
}
99+
```
100+
101+
Every time you push a component that's inside the ``NavigationWrapper`` component
102+
you will have a **navigator** prop, just like the top navigation option before,
103+
that will let you to keep pushing components in the stack.
104+
105+
## License
106+
MIT.

0 commit comments

Comments
 (0)