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

76 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
* Basic [Android] Example for react-native-blur
* https://github.com/react-native-community/react-native-blur
*/
'use strict';
import React, {Component} from 'react';
import {
AppRegistry,
2016-04-11 04:13:01 +00:00
Image,
findNodeHandle,
StyleSheet,
Text,
View
} from 'react-native';
import {BlurView} from 'react-native-blur';
2016-04-11 04:13:01 +00:00
class Basic extends Component {
2016-04-11 04:13:01 +00:00
constructor() {
super()
this.state = {
viewRef: 0,
}
2016-04-11 04:13:01 +00:00
}
imageLoaded() {
this.setState({viewRef: findNodeHandle(this.refs.backgroundImage)})
}
render() {
return (
<Image
source={require('./bgimage.jpeg')}
2016-04-11 04:13:01 +00:00
style={styles.container}
ref={'backgroundImage'}
onLoadEnd={this.imageLoaded.bind(this)}>
2016-04-11 04:13:01 +00:00
<BlurView
blurRadius={15}
2016-04-11 04:13:01 +00:00
downsampleFactor={5}
overlayColor={'rgba(255, 255, 255, .25)'}
2016-04-11 04:13:01 +00:00
style={styles.blurView}
viewRef={this.state.viewRef}/>
<Text style={styles.welcome}>{`Blur component`}</Text>
2016-04-11 04:13:01 +00:00
</Image>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: 'transparent',
resizeMode: 'cover',
width: null,
height: null,
},
welcome: {
fontSize: 22,
fontWeight: 'bold',
textAlign: 'center',
margin: 10,
color: '#FFFFFF',
},
blurView: {
position: "absolute",
left: 0,
top: 0,
bottom: 0,
right: 0
},
});
AppRegistry.registerComponent('Basic', () => Basic);