1- 'use strict ';
1+ import React from 'react-native ';
22
3- var React = require ( 'react-native' ) ;
3+ import NavBarContent from './NavBarContent' ;
44
5- var NavBarContent = require ( './NavBarContent' ) ;
6-
7- var {
5+ const {
86 StyleSheet,
9- View
7+ View,
8+ Component,
109} = React ;
1110
12- var NavBarContainer = React . createClass ( {
11+ class NavBarContainer extends Component {
12+ constructor ( props ) {
13+ super ( props ) ;
14+
15+ this . goBack = this . goBack . bind ( this ) ;
16+ this . goForward = this . goForward . bind ( this ) ;
17+ this . customAction = this . customAction . bind ( this ) ;
1318
14- getInitialState : function ( ) {
15- return {
19+ this . state = {
1620 backButtonOpacity : 0 ,
17- previousRoute : { } // Keep previousRoute for smooth transitions
21+ previousRoute : { } , // Keep previousRoute for smooth transitions
1822 } ;
19- } ,
23+ }
2024
21- componentWillReceiveProps : function ( newProps ) {
25+ componentWillReceiveProps ( newProps ) {
2226 if ( this . props && this . props . currentRoute . index !== newProps . currentRoute . index ) {
2327 this . setState ( {
24- previousRoute : this . props . currentRoute
28+ previousRoute : this . props . currentRoute ,
2529 } ) ;
2630 }
27- } ,
31+ }
2832
29- goBack : function ( ) {
33+ goBack ( ) {
3034 this . props . toBack ( this . props . navigator ) ;
31- } ,
35+ }
3236
33- goForward : function ( route ) {
37+ goForward ( route ) {
3438 this . props . toRoute ( route , this . props . navigator ) ;
35- } ,
39+ }
3640
37- customAction : function ( opts ) {
41+ customAction ( opts ) {
3842 this . props . customAction ( opts ) ;
39- } ,
43+ }
4044
4145 // We render both the current and the previous navbar (for animation)
42- render : function ( ) {
43- var trans ,
44- navbarStyle ,
45- navbarContent ;
46+ render ( ) {
47+ let trans ;
48+ let navbarStyle ;
49+ let navbarContent ;
4650
4751 if ( this . props . currentRoute . trans ) {
48- trans = { backgroundColor : 'transparent' } ;
52+ trans = { backgroundColor : 'transparent' } ;
4953 } else {
5054 trans = { } ;
5155 }
@@ -56,14 +60,15 @@ var NavBarContainer = React.createClass({
5660 navbarStyle = styles . navbarContainer ;
5761 }
5862
59- if ( this . props . currentRoute . trans ) {
63+ if ( this . props . currentRoute . trans ) {
6064 navbarContent = (
6165 < NavBarContent
62- route = { this . state . previousRoute }
63- backButtonComponent = { this . props . backButtonComponent }
64- rightCorner = { this . props . rightCorner }
65- titleStyle = { this . props . titleStyle }
66- willDisappear = "true" > </ NavBarContent >
66+ route = { this . state . previousRoute }
67+ backButtonComponent = { this . props . backButtonComponent }
68+ rightCorner = { this . props . rightCorner }
69+ titleStyle = { this . props . titleStyle }
70+ willDisappear = "true"
71+ />
6772 ) ;
6873 } else if ( this . props . currentRoute . hideNavigationBar ) {
6974 navbarContent = (
@@ -79,8 +84,8 @@ var NavBarContainer = React.createClass({
7984 leftProps = { this . props . leftProps }
8085 rightProps = { this . props . rightProps }
8186 titleProps = { this . props . titleProps }
82- customAction = { this . customAction } >
83- </ NavBarContent >
87+ customAction = { this . customAction }
88+ / >
8489 ) ;
8590 } else {
8691 navbarContent = (
@@ -96,8 +101,8 @@ var NavBarContainer = React.createClass({
96101 leftProps = { this . props . leftProps }
97102 rightProps = { this . props . rightProps }
98103 titleProps = { this . props . titleProps }
99- customAction = { this . customAction } >
100- </ NavBarContent >
104+ customAction = { this . customAction }
105+ / >
101106 ) ;
102107 }
103108
@@ -107,23 +112,23 @@ var NavBarContainer = React.createClass({
107112 </ View >
108113 ) ;
109114 }
110- } ) ;
115+ }
111116
112- var styles = StyleSheet . create ( {
117+ const styles = StyleSheet . create ( {
113118 navbarContainer : {
114119 position : 'absolute' ,
115120 top : 0 ,
116121 left : 0 ,
117122 right : 0 ,
118- height : 64
123+ height : 64 ,
119124 } ,
120125 navbarContainerHidden : {
121126 position : 'absolute' ,
122127 top : - 64 ,
123128 left : 0 ,
124129 right : 0 ,
125- height : 64
126- }
130+ height : 64 ,
131+ } ,
127132} ) ;
128133
129- module . exports = NavBarContainer ;
134+ export default NavBarContainer ;
0 commit comments