1
1
/**
2
- * Sample React Native App
3
- * https://github.com/facebook /react-native
2
+ * Basic [Android] Example for react-native-blur
3
+ * https://github.com/react-native-community /react-native-blur
4
4
*/
5
5
'use strict' ;
6
-
7
- var ReactNative = require ( 'react-native' ) ;
8
- var React = require ( 'react' ) ;
9
- var {
6
+ import React , { Component } from 'react' ;
7
+ import {
10
8
AppRegistry ,
11
9
Image ,
12
10
findNodeHandle ,
13
11
StyleSheet ,
14
12
Text ,
15
- View,
16
- } = ReactNative ;
17
-
18
- const styles = StyleSheet . create ( {
19
- container : {
20
- flex : 1 ,
21
- justifyContent : 'center' ,
22
- backgroundColor : 'transparent' ,
23
- } ,
24
- welcome : {
25
- fontSize : 20 ,
26
- textAlign : 'center' ,
27
- margin : 10 ,
28
- color : '#FFFFFF' ,
29
- } ,
30
- blurView : {
31
- position : "absolute" ,
32
- left : 0 ,
33
- top : 0 ,
34
- bottom : 0 ,
35
- right : 0
36
- } ,
37
- } ) ;
13
+ View
14
+ } from 'react-native' ;
38
15
39
- var BlurView = require ( 'react-native-blur' ) . BlurView ;
16
+ import { BlurView } from 'react-native-blur' ;
40
17
41
- var background = 'http://iphonewallpapers-hd.com/thumbs/firework_iphone_wallpaper_5-t2.jpg' ;
18
+ class Basic extends Component {
42
19
43
- class Basic extends React . Component {
44
- state = {
45
- viewRef : 0
20
+ constructor ( ) {
21
+ super ( )
22
+ this . state = {
23
+ viewRef : 0 ,
24
+ }
46
25
}
47
26
48
27
imageLoaded ( ) {
@@ -52,22 +31,45 @@ class Basic extends React.Component {
52
31
render ( ) {
53
32
return (
54
33
< Image
55
- source = { { uri : background } }
34
+ source = { require ( './bgimage.jpeg' ) }
56
35
style = { styles . container }
57
36
ref = { 'backgroundImage' }
58
- onLoadEnd = { this . imageLoaded . bind ( this ) }
59
- >
37
+ onLoadEnd = { this . imageLoaded . bind ( this ) } >
60
38
< BlurView
61
39
blurRadius = { 10 }
62
40
downsampleFactor = { 5 }
63
- overlayColor = { 'rgba(255, 255, 255, 0.1 )' }
41
+ overlayColor = { 'rgba(255, 255, 255, .25 )' }
64
42
style = { styles . blurView }
65
- viewRef = { this . state . viewRef }
66
- />
67
- < Text style = { styles . welcome } > Blur component</ Text >
43
+ viewRef = { this . state . viewRef } />
44
+ < Text style = { styles . welcome } > { `Blur component` } </ Text >
68
45
</ Image >
69
46
) ;
70
47
}
71
48
}
72
49
50
+ const styles = StyleSheet . create ( {
51
+ container : {
52
+ flex : 1 ,
53
+ justifyContent : 'center' ,
54
+ backgroundColor : 'transparent' ,
55
+ resizeMode : 'cover' ,
56
+ width : null ,
57
+ height : null ,
58
+ } ,
59
+ welcome : {
60
+ fontSize : 22 ,
61
+ fontWeight : 'bold' ,
62
+ textAlign : 'center' ,
63
+ margin : 10 ,
64
+ color : '#FFFFFF' ,
65
+ } ,
66
+ blurView : {
67
+ position : "absolute" ,
68
+ left : 0 ,
69
+ top : 0 ,
70
+ bottom : 0 ,
71
+ right : 0
72
+ } ,
73
+ } ) ;
74
+
73
75
AppRegistry . registerComponent ( 'Basic' , ( ) => Basic ) ;
0 commit comments