@@ -25,13 +25,12 @@ class Router extends React.Component{
2525 this . emitter = new EventEmitter ( ) ;
2626 }
2727
28- /*
29- * This changes the title in the navigation bar
30- * It should preferrably be called for "onWillFocus" instad >
31- * > but a recent update to React Native seems to break the animation
32- */
33- onDidFocus ( route ) {
28+ onWillFocus ( route ) {
3429 this . setState ( { route : route } ) ;
30+ this . emitter . emit ( 'willFocus' , route . name ) ;
31+ }
32+
33+ onDidFocus ( route ) {
3534 this . emitter . emit ( 'didFocus' , route . name ) ;
3635 }
3736
@@ -54,10 +53,18 @@ class Router extends React.Component{
5453 this . setState ( { leftProps : props } ) ;
5554 }
5655
56+ setTitleProps ( props ) {
57+ this . setState ( { titleProps : props } ) ;
58+ }
59+
5760 customAction ( opts ) {
5861 this . props . customAction ( opts ) ;
5962 }
6063
64+ configureScene ( route ) {
65+ return route . sceneConfig || Navigator . SceneConfigs . FloatFromRight ;
66+ }
67+
6168 renderScene ( route , navigator ) {
6269
6370 var goForward = function ( route ) {
@@ -91,6 +98,10 @@ class Router extends React.Component{
9198 this . setState ( { leftProps : props } ) ;
9299 } . bind ( this ) ;
93100
101+ var setTitleProps = function ( props ) {
102+ this . setState ( { titleProps : props } ) ;
103+ } . bind ( this ) ;
104+
94105 var customAction = function ( opts ) {
95106 this . customAction ( opts ) ;
96107 } . bind ( this ) ;
@@ -127,6 +138,7 @@ class Router extends React.Component{
127138 reset = { goToFirstRoute }
128139 setRightProps = { setRightProps }
129140 setLeftProps = { setLeftProps }
141+ setTitleProps = { setTitleProps }
130142 customAction = { customAction }
131143 { ...route . passProps }
132144 />
@@ -139,7 +151,7 @@ class Router extends React.Component{
139151 var navigationBar ;
140152 // Status bar color
141153 if ( Platform . OS === 'ios' ) {
142- if ( this . props . statusBarColor === " black" ) {
154+ if ( this . props . statusBarColor === ' black' ) {
143155 StatusBarIOS . setStyle ( 0 ) ;
144156 } else {
145157 StatusBarIOS . setStyle ( 1 ) ;
@@ -163,16 +175,20 @@ class Router extends React.Component{
163175 toBack = { this . onBack . bind ( this ) }
164176 leftProps = { this . state . leftProps }
165177 rightProps = { this . state . rightProps }
178+ titleProps = { this . state . titleProps }
166179 customAction = { this . customAction . bind ( this ) }
167180 />
168181 }
169182
170183 return (
171184 < Navigator
185+ ref = 'navigator'
172186 initialRoute = { this . props . firstRoute }
173187 navigationBar = { navigationBar }
174188 renderScene = { this . renderScene . bind ( this ) }
175189 onDidFocus = { this . onDidFocus . bind ( this ) }
190+ onWillFocus = { this . onWillFocus . bind ( this ) }
191+ configureScene = { this . configureScene }
176192 />
177193 ) ;
178194 }
0 commit comments