React-native-router-flux: How to have a transparent background?

Created on 18 Mar 2016  路  12Comments  路  Source: aksonov/react-native-router-flux

On the v2, I was able to have a transparent background on my scene, but now with the v3 I'm not able to do this anymore.
How can I set my Router/Scene to have a transparent background?
Thanks

Most helpful comment

this works but the previous scene is visible underneath. Should be an easy fix to animate it further off screen. Is there an api for that?

All 12 comments

The problem in NavigationCard of React Native package:

      <Animated.View
        {...panHandlers}
        style={[styles.main, animatedStyle]}>
        {this.props.renderScene(sceneProps)}
      </Animated.View>

So the component can't pass own style to NavigationCard and it is weird. Please create issue there if you want it to be fixed:
https://github.com/ericvicenti/navigation-rfc

The NavigationCard in the last React Native 0.22rc-4 has the following:

     <Animated.View
        {...panHandlers}
        style={[styles.main, style]}>
        {this.props.renderScene(sceneProps)}
      </Animated.View>

style is a prop that I should be able to modify with whatever I need, but I'm not sure how to access it via Scene/Router @aksonov ?

Looks like rc4 doesn't have this change, but master does. Anyway i've added this feature to the component (once NavigationCard will have style support, it should work), release 3.0.14

Check code above:

             style={[styles.animatedView, navigationState.style]}
``

@aksonov saw that, but where and how should I pass the style? in the Router? In each Scene? What if I want to set it globally? could you give me an example?

Thanks

For each scene. If you want to set globally you can wrap View around Router, but current Navigation API doesn't support it, you have to wait until current master will be published as i said above.

ok, which parameter should I use for each scene?

If I use the latest version 0.22.0-rc4 can I do:

<View style={{backgroundColor:'red'}}>
  <Router scenes={scenes} />
</View>

@aksonov just tried and it doesn't work :disappointed:

Read my answer again. i said 'master', not rc-4...

@zelphir You may use new feature #356 with 3.1.0 - you can pass some property to all scenes from Router. So you could pass sceneStyle, for example, and then use props.sceneStyle within your Scene...

@aksonov thanks!

this works but the previous scene is visible underneath. Should be an easy fix to animate it further off screen. Is there an api for that?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

basdvries picture basdvries  路  3Comments

xnog picture xnog  路  3Comments

fgrs picture fgrs  路  3Comments

YouYII picture YouYII  路  3Comments

sreejithr picture sreejithr  路  3Comments