Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

blur area behind an element in react native

import React, { Component } from 'react';
import { BlurView } from '@react-native-community/blur';
import {
  StyleSheet,
  Text,
  View,
  findNodeHandle,
  Platform,
  Image,
} from 'react-native';

const styles = StyleSheet.create({
  title: {
    color: 'black',
    fontSize: 15,
  },
  absolute: {
    position: 'absolute',
    top: 0,
    left: 0,
    bottom: 0,
    right: 0,
  },
  blurredView: {
    // For me android blur did not work until applying a background color:
    backgroundColor: 'white',
  },
});

export default class MyBlurredComponent extends Component {
  constructor(props) {
    super(props);
    this.state = { viewRef: null };
  }

  onTextViewLoaded() {
    this.setState({ viewRef: findNodeHandle(this.viewRef) });
  }

  render() {
    return (
      <View>
        <View
          style={[
            styles.blurredView,
          ]}
          ref={(viewRef) => { this.viewRef = viewRef; }}
          onLayout={() => { this.onTextViewLoaded(); }}
        >
          <Image
            style={{ width: 100, height: 100 }}
            source={{ uri: 'https://facebook.github.io/react-native/docs/assets/GettingStartedCongratulations.png' }}
          />
          <Text style={[styles.title]}>
            TEXT 2222 

            TEXT 3333
          </Text>
        </View>
        {
          (this.state.viewRef || Platform.OS === 'ios') && <BlurView
            style={styles.absolute}
            viewRef={this.state.viewRef}
            blurType="light"
            blurAmount={3}
            blurRadius={5}
          />
        }
      </View>
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: currying in javascript mdn 
Javascript :: hide modal event listener js 
Javascript :: js date add days daylight saving 
Javascript :: prevent the fire of parent event listener 
Javascript :: format file using jq input curl 
Javascript :: this ....object of. 
Javascript :: Node Red to their W1HQ station 
Javascript :: javascript python like for loop 
Javascript :: nestjs cors dotnot woriking 
Javascript :: react native red Triangle Left 
Javascript :: regex generator 
Javascript :: how to print huge numbers in a variable alert javascript 
Javascript :: btn click on click file javascript 
Javascript :: for (var i = 0; i < 3; i++) { setTimeout(function() { console.log(i); }, 1000 + i); } 
Javascript :: how to remove comma from toString function javascript 
Javascript :: express plus 
Javascript :: trigger keyup event jquery 
Javascript :: linked list distance between two nodes 
Javascript :: get call log in react native with filter android 
Javascript :: xmlhttprequest set route params 
Javascript :: ProgressBar from color to color 
Javascript :: summernote click event jquery 
Javascript :: likedislike 
Javascript :: how stop users from submitting empty input in todo list javascript 
Javascript :: loop through json object jquery 
Javascript :: freecodecamp Drop it 
Javascript :: how to only register one click on nested component and not parent component in react js 
Javascript :: types of directive in jsp 
Javascript :: does mysql accept json 
Javascript :: Uncaught TypeError: table.fnColReorder.transpose is not a function 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =