2016-11-09 00:12:53 +00:00
|
|
|
/**
|
|
|
|
* Basic [iOS] Example for react-native-blur
|
|
|
|
* https://github.com/react-native-community/react-native-blur
|
|
|
|
*/
|
|
|
|
import React, {Component} from 'react'
|
2016-07-01 08:12:28 +00:00
|
|
|
import {
|
2015-10-05 20:41:32 +00:00
|
|
|
AppRegistry,
|
|
|
|
StyleSheet,
|
|
|
|
Text,
|
|
|
|
Image,
|
2016-11-09 00:12:53 +00:00
|
|
|
View,
|
|
|
|
SegmentedControlIOS,
|
|
|
|
Switch
|
|
|
|
} from 'react-native'
|
|
|
|
|
|
|
|
import {BlurView, VibrancyView} from 'react-native-blur'
|
|
|
|
|
|
|
|
class Basic extends Component {
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super()
|
|
|
|
this.state = {
|
2016-11-09 00:19:32 +00:00
|
|
|
showBlurs: true,
|
2016-11-09 00:12:53 +00:00
|
|
|
blurBlurType: 'light',
|
|
|
|
blurActiveSegment: 1,
|
|
|
|
vibrancyBlurType: 'dark',
|
|
|
|
vibrancyActiveSegment: 2,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_onBlurChange(event) {
|
|
|
|
this.setState({blurActiveSegment: event.nativeEvent.selectedSegmentIndex})
|
|
|
|
}
|
|
|
|
|
|
|
|
_onBlurValueChange(value) {
|
|
|
|
this.setState({blurBlurType: value})
|
|
|
|
}
|
|
|
|
|
|
|
|
_onVibrancyChange(event) {
|
|
|
|
this.setState({vibrancyActiveSegment: event.nativeEvent.selectedSegmentIndex})
|
|
|
|
}
|
|
|
|
|
|
|
|
_onVibrancyValueChange(value) {
|
|
|
|
this.setState({vibrancyBlurType: value})
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<View
|
|
|
|
style={styles.container}>
|
|
|
|
|
|
|
|
<Image
|
|
|
|
source={require('./bgimage.jpeg')}
|
|
|
|
resizeMode='cover'
|
|
|
|
style={styles.img}/>
|
|
|
|
|
2016-11-09 00:19:32 +00:00
|
|
|
{(this.state.showBlurs
|
2016-11-09 00:12:53 +00:00
|
|
|
|
2016-11-09 00:19:32 +00:00
|
|
|
? <View style={styles.container}>
|
2016-11-09 00:12:53 +00:00
|
|
|
|
|
|
|
<BlurView
|
|
|
|
blurType={this.state.blurBlurType}
|
|
|
|
blurAmount={10}
|
|
|
|
style={[styles.container, styles.blurContainer]}>
|
|
|
|
<Text style={styles.welcome}>{`Blur component`}</Text>
|
|
|
|
<SegmentedControlIOS
|
|
|
|
values={['xlight', 'light', 'dark']}
|
|
|
|
selectedIndex={this.state.blurActiveSegment}
|
|
|
|
onChange={(event) => {this._onBlurChange(event)}}
|
|
|
|
onValueChange={(value) => {this._onBlurValueChange(value)}}
|
|
|
|
tintColor={this.state.blurBlurType == 'xlight' ? 'black' : 'white'}/>
|
|
|
|
</BlurView>
|
|
|
|
|
|
|
|
<VibrancyView
|
|
|
|
blurType={this.state.vibrancyBlurType}
|
|
|
|
blurAmount={1}
|
|
|
|
style={[styles.container, styles.blurContainer]}>
|
|
|
|
<Text style={styles.welcome}>{`Vibrancy component`}</Text>
|
|
|
|
<SegmentedControlIOS
|
|
|
|
values={['xlight', 'light', 'dark']}
|
|
|
|
selectedIndex={this.state.vibrancyActiveSegment}
|
|
|
|
onChange={(event) => {this._onVibrancyChange(event)}}
|
|
|
|
onValueChange={(value) => {this._onVibrancyValueChange(value)}}
|
|
|
|
tintColor={this.state.vibrancyBlurType == 'xlight' ? 'black' : 'white'}/>
|
|
|
|
</VibrancyView>
|
|
|
|
|
|
|
|
</View>
|
2016-11-09 00:19:32 +00:00
|
|
|
|
|
|
|
: null
|
2016-11-09 00:12:53 +00:00
|
|
|
)}
|
|
|
|
|
|
|
|
<View
|
|
|
|
style={styles.blurToggle}>
|
|
|
|
<Switch
|
2016-11-09 00:19:32 +00:00
|
|
|
onValueChange={(value) => this.setState({showBlurs: value})}
|
|
|
|
value={this.state.showBlurs} />
|
2016-11-09 00:12:53 +00:00
|
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2015-10-05 20:41:32 +00:00
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
justifyContent: 'center',
|
2016-11-09 00:12:53 +00:00
|
|
|
alignItems: 'stretch',
|
2015-10-05 20:41:32 +00:00
|
|
|
backgroundColor: 'transparent',
|
|
|
|
},
|
2016-11-09 00:12:53 +00:00
|
|
|
blurContainer: {
|
|
|
|
paddingHorizontal: 20,
|
|
|
|
},
|
|
|
|
img: {
|
|
|
|
position: 'absolute',
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
top: 0,
|
|
|
|
bottom: 0,
|
|
|
|
height: null,
|
|
|
|
width: null,
|
|
|
|
},
|
2015-10-05 20:41:32 +00:00
|
|
|
welcome: {
|
|
|
|
fontSize: 20,
|
2016-11-09 00:12:53 +00:00
|
|
|
fontWeight: 'bold',
|
2015-10-05 20:41:32 +00:00
|
|
|
textAlign: 'center',
|
|
|
|
margin: 10,
|
2016-11-09 00:12:53 +00:00
|
|
|
color: 'white',
|
2015-10-05 20:41:32 +00:00
|
|
|
},
|
2016-11-09 00:12:53 +00:00
|
|
|
blurToggle: {
|
|
|
|
position: 'absolute',
|
|
|
|
top: 30,
|
|
|
|
right: 10,
|
|
|
|
alignItems: 'flex-end',
|
2015-10-05 20:41:32 +00:00
|
|
|
}
|
2016-11-09 00:12:53 +00:00
|
|
|
});
|
2015-10-05 20:41:32 +00:00
|
|
|
|
2016-11-09 00:12:53 +00:00
|
|
|
AppRegistry.registerComponent('Basic', () => Basic);
|