Skip to content

Instantly share code, notes, and snippets.

@dstaley
Created January 11, 2016 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstaley/1a2f925c7bc3b7f81011 to your computer and use it in GitHub Desktop.
Save dstaley/1a2f925c7bc3b7f81011 to your computer and use it in GitHub Desktop.
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