Created
January 11, 2016 01:49
-
-
Save dstaley/1a2f925c7bc3b7f81011 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ThemeComponent = React.createClass({ | |
getInitialState() { | |
return { | |
'theme': 'Day', | |
}; | |
}, | |
getStyle(element) { | |
return [baseStyles[element], themeStyles[this.state.theme][element]]; | |
}, | |
render() { | |
return ( | |
<View style={this.getStyle('container')}> | |
<Text>Hello!</Text> | |
</View> | |
); | |
} | |
}); | |
const baseStyles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
}, | |
}); | |
const themeStyles = { | |
'Day': StyleSheet.create({ | |
container: { | |
backgroundColor: '#FFFFFF', | |
}, | |
}), | |
'Sunset': StyleSheet.create({ | |
container: { | |
backgroundColor: '#EFEEE4', | |
}, | |
}), | |
'Night': StyleSheet.create({ | |
container: { | |
backgroundColor: '#353739', | |
}, | |
}), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment