react-native-blur/examples/Basic/index.android.js

74 lines
1.4 KiB
JavaScript
Raw Normal View History

/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
2016-05-06 09:35:18 +00:00
var ReactNative = require('react-native');
var React = require('react');
var {
AppRegistry,
2016-04-11 04:13:01 +00:00
Image,
findNodeHandle,
StyleSheet,
Text,
View,
2016-05-06 09:35:18 +00:00
} = ReactNative;
2016-04-11 04:13:01 +00:00
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
2016-04-11 04:13:01 +00:00
backgroundColor: 'transparent',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
2016-04-11 04:13:01 +00:00
color: '#FFFFFF',
},
2016-04-11 04:13:01 +00:00
blurView: {
position: "absolute",
left: 0,
top: 0,
bottom: 0,
right: 0
},
});
2016-04-11 04:13:01 +00:00
var BlurView = require('react-native-blur').BlurView;
var background = 'http://iphonewallpapers-hd.com/thumbs/firework_iphone_wallpaper_5-t2.jpg';
class Basic extends React.Component {
state = {
viewRef: 0
}
imageLoaded() {
this.setState({viewRef: findNodeHandle(this.refs.backgroundImage)})
}
render() {
return (
<Image
2016-06-13 20:40:35 +00:00
source={{uri: background}}
2016-04-11 04:13:01 +00:00
style={styles.container}
ref={'backgroundImage'}
2016-06-13 20:40:35 +00:00
onLoadEnd={this.imageLoaded.bind(this)}
2016-04-11 04:13:01 +00:00
>
<BlurView
blurRadius={10}
downsampleFactor={5}
overlayColor={'rgba(255, 255, 255, 0.1)'}
style={styles.blurView}
viewRef={this.state.viewRef}
/>
<Text style={styles.welcome}>Blur component</Text>
</Image>
);
}
}
AppRegistry.registerComponent('Basic', () => Basic);