Skip to content

Commit 359b8dc

Browse files
committed
Merge pull request #9 from APSL/v0.2.0
v0.2.0
2 parents 2dc5329 + 4fa231b commit 359b8dc

12 files changed

Lines changed: 258 additions & 94 deletions

.eslintrc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,9 @@
157157
"no-lonely-if": 0,
158158
"no-new-object": 1,
159159
"no-spaced-func": 1,
160-
"semi-spacing": 1,
161160
"no-ternary": 0,
162161
"no-trailing-spaces": 1,
163162
"no-underscore-dangle": 0,
164-
"no-extra-parens": 0,
165163
"no-mixed-spaces-and-tabs": 1,
166164
"quotes": [1, "single", "avoid-escape"],
167165
"quote-props": 0,

.flowconfig

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*.web.js
5+
.*/*.android.js
6+
7+
# Some modules have their own node_modules with overlap
8+
.*/node_modules/node-haste/.*
9+
10+
# Ugh
11+
.*/node_modules/babel.*
12+
.*/node_modules/babylon.*
13+
.*/node_modules/invariant.*
14+
15+
# Ignore react and fbjs where there are overlaps, but don't ignore
16+
# anything that react-native relies on
17+
.*/node_modules/fbjs/lib/Map.js
18+
.*/node_modules/fbjs/lib/fetch.js
19+
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
20+
.*/node_modules/fbjs/lib/ErrorUtils.js
21+
22+
# Flow has a built-in definition for the 'react' module which we prefer to use
23+
# over the currently-untyped source
24+
.*/node_modules/react/react.js
25+
.*/node_modules/react/lib/React.js
26+
.*/node_modules/react/lib/ReactDOM.js
27+
28+
.*/__mocks__/.*
29+
.*/__tests__/.*
30+
31+
.*/commoner/test/source/widget/share.js
32+
33+
# Ignore commoner tests
34+
.*/node_modules/commoner/test/.*
35+
36+
# See https://github.com/facebook/flow/issues/442
37+
.*/react-tools/node_modules/commoner/lib/reader.js
38+
39+
# Ignore jest
40+
.*/node_modules/jest-cli/.*
41+
42+
# Ignore Website
43+
.*/website/.*
44+
45+
# Ignore generators
46+
.*/local-cli/generator.*
47+
48+
# Ignore BUCK generated folders
49+
.*\.buckd/
50+
51+
.*/node_modules/is-my-json-valid/test/.*\.json
52+
.*/node_modules/iconv-lite/encodings/tables/.*\.json
53+
.*/node_modules/y18n/test/.*\.json
54+
.*/node_modules/spdx-license-ids/spdx-license-ids.json
55+
.*/node_modules/spdx-exceptions/index.json
56+
.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
57+
.*/node_modules/resolve/lib/core.json
58+
.*/node_modules/jsonparse/samplejson/.*\.json
59+
.*/node_modules/json5/test/.*\.json
60+
.*/node_modules/ua-parser-js/test/.*\.json
61+
.*/node_modules/builtin-modules/builtin-modules.json
62+
.*/node_modules/binary-extensions/binary-extensions.json
63+
.*/node_modules/url-regex/tlds.json
64+
.*/node_modules/joi/.*\.json
65+
.*/node_modules/isemail/.*\.json
66+
.*/node_modules/tr46/.*\.json
67+
68+
69+
[include]
70+
71+
[libs]
72+
node_modules/react-native/Libraries/react-native/react-native-interface.js
73+
node_modules/react-native/flow
74+
flow/
75+
76+
[options]
77+
module.system=haste
78+
79+
esproposal.class_static_fields=enable
80+
esproposal.class_instance_fields=enable
81+
82+
munge_underscores=true
83+
84+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
85+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub'
86+
87+
suppress_type=$FlowIssue
88+
suppress_type=$FlowFixMe
89+
suppress_type=$FixMe
90+
91+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
92+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-3]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
93+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
94+
95+
[version]
96+
0.23.0

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,23 @@
22
A React Native Navigator component wrapper that implements nested navigators for
33
both push and modal transitions.
44

5+
<p align="center">
6+
<img src="https://raw.githubusercontent.com/wiki/APSL/react-native-navigator-wrapper/nav.gif" alt="Wrapper example" width="400">
7+
</p>
8+
9+
## Disclaimer
10+
This component uses the JS `Navigator` implementation of React Native. Future versions of the component will use the actual `NavigatorExperimental`.
11+
512
## Installation
613
You can install this component through ``npm``:
714

815
```shell
916
npm i react-native-navigator-wrapper --save
1017
```
1118

12-
You also need to install the awesome
19+
Configure the awesome
1320
[``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
21+
from Joel Oblador to display the back button icons. Remember to include the
1522
``Ionicons.ttf`` font in your project. All the components of the library are
1623
written in ES6/ES7 style.
1724

@@ -48,43 +55,37 @@ modal component.
4855
## Usage
4956
This library can be used in several ways. It's composed from a couple of different
5057
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.
58+
mimics the iOS and Android navigation bar and two navigation wrappers.
5359

5460
### Nested navigation with ``TopNavigatorWrapper``
5561
You can use ``TopNavigatorWrapper`` component to bring the nested navigator
5662
strategy just importing the component and wrapping whatever you want to render
5763
inside it:
5864

5965
```js
60-
import React from 'react-native'
66+
import React from 'react'
6167
import { TopNavigatorWrapper } from 'react-native-navigator-wrapper'
6268
import MyComponent from './MyComponent'
6369

6470
class MyApp extends React.Component {
6571
render () {
6672
return (
67-
<TopNavigatorWrapper
68-
initialRoute={{
69-
component: MyComponent,
70-
title='Title'
71-
}}
72-
/>
73+
<TopNavigatorWrapper modalStyle={{backgroundColor: '#090909'}}>
74+
<MyComponent />
75+
</TopNavigatorWrapper>
7376
)
7477
}
7578
}
7679
```
7780

78-
You component ``MyComponent`` will have two props, **navigator** and
79-
**topNavigator**. They will let you to push new components from right using
80-
the first one or open a modal pushing from the second one.
81+
You component ``MyComponent`` will have a **topNavigator** prop. It will let you to push new components in a modal-style, opening from bottom to top.
8182

8283
### Navigation with ``NavigatorWrapper``
8384
If you just want to use the navigation bar inside a navigator, use the
8485
``NavigatorWrapper`` component:
8586

8687
```js
87-
import React from 'react-native'
88+
import React from 'react'
8889
import { NavigatorWrapper } from 'react-native-navigator-wrapper'
8990

9091
class MyComponent extends React.Component {
@@ -109,12 +110,15 @@ that will let you to keep pushing components in the stack.
109110
The React Native ``Navigator.NavigatorBar`` component has an object called
110111
``routeMapper`` that configures the three components that can be displayed
111112
inside the navigation bar: ``LeftButton``, ``RightButton`` and ``Title``.
112-
This library auto-generates a default route mapper object that displays an iOS
113-
style back button, a title and accepts a right element to render.
113+
This library auto-generates a default route mapper object that displays an iOS & Android style back button, a title and accepts a right element to render.
114114

115115
It also provides functions to generate each of the route mapper components so
116116
you can build a completely custom navigation bar for each ``NavigatorWrapper``.
117117
See the source code for more information.
118118

119+
## 🚧 Roadmap
120+
121+
- [ ] Handle several hardware back button actions with multiple navigators (Android).
122+
119123
## License
120124
MIT.

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* @flow */
2+
13
import NavBarBackButton from './lib/NavBarBackButton'
24
import NavBar from './lib/NavBar'
35
import NavigatorWrapper from './lib/NavigatorWrapper'

lib/NavBar.android.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
import React, {
1+
/* @flow */
2+
3+
import React from 'react'
4+
import {
25
Navigator,
36
StyleSheet,
47
} from 'react-native'
58

69
const stylesAndroid = StyleSheet.create({
710
navBar: {
8-
backgroundColor: 'white',
11+
backgroundColor: '#f5f5f5',
12+
flexDirection: 'row',
13+
alignItems: 'center',
14+
justifyContent: 'center',
915
}
1016
})
1117

lib/NavBar.ios.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import React, { Navigator, StyleSheet, PixelRatio } from 'react-native'
1+
/* @flow */
2+
3+
import React from 'react'
4+
import { Navigator, StyleSheet, PixelRatio } from 'react-native'
25

36
class NavBar extends React.Component {
47
updateProgress (progress, fromIndex, toIndex) {

lib/NavBarBackButton.android.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React, { TouchableOpacity, Text, PropTypes, StyleSheet } from 'react-native'
2-
import StyleSheetPropType from 'react-native/Libraries/StyleSheet/StyleSheetPropType'
3-
import TextStylePropTypes from 'react-native/Libraries/Text/TextStylePropTypes'
1+
/* @flow */
2+
3+
import React, { PropTypes } from 'react'
4+
import { TouchableOpacity, Text, StyleSheet } from 'react-native'
45
import Ionicon from 'react-native-vector-icons/Ionicons'
56

67
class NavBarBackButton extends React.Component {
@@ -32,7 +33,7 @@ class NavBarBackButton extends React.Component {
3233
<TouchableOpacity
3334
{...touchableProps}
3435
style={styles.container}>
35-
<Ionicon name='android-arrow-back' size={24} style={styles.icon}
36+
<Ionicon name='md-arrow-back' size={24} style={styles.icon}
3637
color={this.state.tintColor} />
3738
{this._renderBackTitle.bind(this)}
3839
</TouchableOpacity>
@@ -44,7 +45,7 @@ NavBarBackButton.propTypes = {
4445
...TouchableOpacity.propTypes,
4546
tintColor: PropTypes.string,
4647
children: PropTypes.string.isRequired,
47-
style: StyleSheetPropType(TextStylePropTypes),
48+
style: Text.propTypes.style,
4849
showBackTitle: PropTypes.bool,
4950
}
5051

lib/NavBarBackButton.ios.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import React, { TouchableOpacity, Text, PropTypes, StyleSheet } from 'react-native'
2-
import StyleSheetPropType from 'react-native/Libraries/StyleSheet/StyleSheetPropType'
3-
import TextStylePropTypes from 'react-native/Libraries/Text/TextStylePropTypes'
1+
/* @flow */
2+
3+
import React, { PropTypes } from 'react'
4+
import { TouchableOpacity, Text, StyleSheet } from 'react-native'
45
import Ionicon from 'react-native-vector-icons/Ionicons'
56

67
class NavBarBackButton extends React.Component {
7-
constructor (props) {
8+
state: Object;
9+
10+
constructor (props: Object) {
811
super(props)
912
this.state = {
1013
tintColor: props.tintColor || 'black'
@@ -34,7 +37,7 @@ class NavBarBackButton extends React.Component {
3437
style={styles.container}>
3538
<Ionicon name='ios-arrow-back' size={32} style={styles.icon}
3639
color={this.state.tintColor} />
37-
{this._renderBackTitle.bind(this)}
40+
{this._renderBackTitle()}
3841
</TouchableOpacity>
3942
)
4043
}
@@ -44,7 +47,7 @@ NavBarBackButton.propTypes = {
4447
...TouchableOpacity.propTypes,
4548
tintColor: PropTypes.string,
4649
children: PropTypes.string.isRequired,
47-
style: StyleSheetPropType(TextStylePropTypes),
50+
style: Text.propTypes.style,
4851
showBackTitle: PropTypes.bool,
4952
}
5053

0 commit comments

Comments
 (0)