diff --git a/.gitignore b/.gitignore index 60b82c7..13d2f90 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ node_modules # OSX .DS_Store + +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index bc06e87..4b36338 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ React Native Router =================== Awesome navigation for your React Native app. +** This is a React Native Router fix version. It can be used in Android project. ** + ![Twitter navigation](http://tristanedwards.me/u/react-native-router/native-router.gif) Install @@ -9,7 +11,7 @@ Install Make sure that you are in your React Native project directory and run: -```npm install react-native-router --save``` +```npm install react-native-router-fix --save``` Usage ----- diff --git a/components/NavBarContainer.js b/components/NavBarContainer.js index 7fda8ff..1aba559 100644 --- a/components/NavBarContainer.js +++ b/components/NavBarContainer.js @@ -42,16 +42,18 @@ var NavBarContainer = React.createClass({ // We render both the current and the previous navbar (for animation) render: function() { return ( - + + {leftCorner} {titleComponent} {rightCorner} @@ -137,17 +137,17 @@ var styles = StyleSheet.create({ top: 0, left: 0, right: 0, - height: 64, // Default iOS navbar height + height: React.Platform.OS == 'ios' ? 64 : 48, // Default iOS navbar height justifyContent: 'center', alignItems: 'center', flexDirection: 'row', - paddingTop: 13 + paddingTop: React.Platform.OS == 'ios' ? 13 : 0 }, navbarText: { color: 'white', fontSize: 17, margin: 10, - marginTop: 14, + marginTop: React.Platform.OS == 'ios' ? 14 : 10, fontWeight: '600', textAlign: 'center', alignItems: 'center', diff --git a/index.js b/index.js index e9e4350..573ac12 100644 --- a/index.js +++ b/index.js @@ -68,6 +68,10 @@ var Router = React.createClass({ this.customAction(opts); }.bind(this); + var isRootView = function() { + return this.state.route.index == 1; + }.bind(this); + var didStartDrag = function(evt) { var x = evt.nativeEvent.pageX; if (x < 28) { @@ -114,6 +118,7 @@ var Router = React.createClass({ toRoute={goForward} toBack={goBackwards} reset={goToFirstRoute} + isRootView={isRootView} customAction={customAction} /> @@ -123,11 +128,13 @@ var Router = React.createClass({ render: function() { - // Status bar color - if (this.props.statusBarColor === "black") { - StatusBarIOS.setStyle(0); - } else { - StatusBarIOS.setStyle(1); + // Status bar color, if on iOS + if (React.Platform.OS == 'ios') { + if (this.props.statusBarColor === "black") { + StatusBarIOS.setStyle(0); + } else { + StatusBarIOS.setStyle(1); + } } var navigationBar; @@ -147,14 +154,26 @@ var Router = React.createClass({ /> } - return ( - - ) + if (React.Platform.OS == 'ios') { + return ( + + ); + } else { + return ( + Navigator.SceneConfigs.FadeAndroid} + navigationBar={navigationBar} + renderScene={this.renderScene} + onDidFocus={this.onDidFocus} + /> + ); + } } }); @@ -163,7 +182,7 @@ var styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#F5FCFF', - marginTop: 64 + marginTop: React.Platform.OS == 'ios' ? 64 : 48 }, }); diff --git a/package.json b/package.json index 57c6ec7..052259f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "react-native-router", - "version": "0.2.1", + "name": "react-native-router-fix", + "version": "0.2.1-fix-10", "description": "Awesome navigation for your native app.", "main": "index.js", "scripts": { @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/t4t5/react-native-router.git" + "url": "https://github.com/starlight36/react-native-router.git" }, "keywords": [ "react",