Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sceneStyle work without having to apply styles manually #470

Merged
merged 3 commits into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ const reducerCreate = params=>{

export default class Example extends React.Component {
render() {
return <Router createReducer={reducerCreate} sceneStyle={{backgroundColor:'#F7F7F7'}}>
return <Router createReducer={reducerCreate}>
<Scene key="modal" component={Modal} >
<Scene key="root" hideNavBar={true}>
<Scene key="echo" clone component={EchoView} />
<Scene key="register" component={Register} title="Register"/>
<Scene key="register2" component={Register} title="Register2" duration={1}/>
<Scene key="home" component={Home} title="Replace" type="replace"/>
<Scene key="launch" component={Launch} title="Launch" initial={true} style={{flex:1, backgroundColor:"transparent"}}/>
<Scene key="launch" component={Launch} title="Launch" initial={true} />
<Scene key="login" direction="vertical" >
<Scene key="loginModal" component={Login} title="Login"/>
<Scene key="loginModal2" hideNavBar={true} component={Login2} title="Login2" panHandlers={null} duration={1}/>
Expand Down
2 changes: 1 addition & 1 deletion Example/components/Launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const styles = StyleSheet.create({
class Launch extends React.Component {
render(){
return (
<View {...this.props} style={[styles.container, this.props.sceneStyle]}>
<View {...this.props} style={styles.container}>
<Text>Launch page</Text>
<Button onPress={()=>Actions.login({data:"Custom data", title:"Custom title" })}>Go to Login page</Button>
<Button onPress={Actions.register}>Go to Register page</Button>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class App extends React.Component {
| rightButtonTextStyle | Text style | | optional style override for the right title element |
| clone | bool | | Scenes marked with `clone` will be treated as templates and cloned into the current scene's parent when pushed. See example. |
| tabBarStyle | View style | | optional style override for the Tabs component |
| sceneStyle | View style | { flex: 1 } | optional style override for the Scene's component |
| other props | | | all properties that will be passed to your component instance |

## Example
Expand Down
8 changes: 6 additions & 2 deletions src/DefaultRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*
*/
import React, {Component, Animated, StyleSheet, ScrollView, Text, NavigationExperimental} from "react-native";
import React, {Component, Animated, StyleSheet, ScrollView, View, Text, NavigationExperimental} from "react-native";
const {
AnimatedView: NavigationAnimatedView,
Card: NavigationCard,
Expand Down Expand Up @@ -37,7 +37,11 @@ export default class DefaultRenderer extends Component {
Component = TabBar;
}
if (Component) {
return <Component style={navigationState.sceneStyle} {...navigationState} navigationState={navigationState} />
return (
<View style={[{flex: 1}, navigationState.sceneStyle]}>
<Component {...navigationState} navigationState={navigationState} />
</View>
)
}

const selected = navigationState.children[navigationState.index];
Expand Down