React Native Blur component
Go to file
Michael Hancock 47dfe40b6a Updated example to use ES6 features
Used imports instead of require.
Simplified imports and removed unused component View.
Background is now a const instead of var. <- ES6 prefers this
Removed dangling comma after background ```source={{uri: background, }}```

Generally example is more succinct and easier to understand for users only exposed to the new tools of ES6.
2016-07-01 09:12:28 +01:00
android Add android support for BlurView 2016-06-13 15:55:46 -04:00
examples/Basic Updated example to use ES6 features 2016-07-01 09:12:28 +01:00
ios set build active architecture to no for release builds 2015-10-22 10:14:22 -04:00
src RN upgrade changes to .android files 2016-06-13 16:57:58 -04:00
.eslintrc Rebuild react-native-blur for RN-0.11.4 2015-10-05 22:42:23 +02:00
.flowconfig Rebuild react-native-blur for RN-0.11.4 2015-10-05 22:42:23 +02:00
.gitignore Rebuild react-native-blur for RN-0.11.4 2015-10-05 22:42:23 +02:00
.npmignore Rebuild react-native-blur for RN-0.11.4 2015-10-05 22:42:23 +02:00
.watchmanconfig Rebuild react-native-blur for RN-0.11.4 2015-10-05 22:42:23 +02:00
README.md Add android info in the README 2016-06-13 16:48:20 -04:00
index.js Rebuild react-native-blur for RN-0.11.4 2015-10-05 22:42:23 +02:00
package.json Release v1.0.0. 2016-06-13 23:26:18 +02:00
react-native-blur.podspec Update react-native-blur.podspec 2016-05-23 11:43:04 -04:00

README.md

React Native Blur

Component implementation for UIVisualEffectView's blur and vibrancy effect.
Check the roadmap here

Content

Installation

  1. Install package via npm:
npm install react-native-blur
  1. Link your library by one of those ways: either by using rnpm link (see more about rnpm here) or like it's described here.
  2. Inside your code include JS part by adding
const { BlurView, VibrancyView } = require('react-native-blur');
  1. Compile and have fun!

Usage example

You can run built-in example via few simple steps:

  1. Clone repository
  2. Go to examples/Basic
  3. Run npm install && open Basic.xcodeproj
  4. Hit "Run"(cmd+R) button on XCode panel

Blur View

To use blur view, you need to require BlurView to your module and insert <BlurView> tag inside render function as it's done below:

const { BlurView } = require('react-native-blur');

const Menu = React.createClass({
  render() {
    return (
      <Image source={{uri}} style={styles.menu}>
        <BlurView blurType="light" style={styles.blur}>
          <Text>Hi, I am a tiny menu item</Text>
        </BlurView>
      </Image>
    );
  }
});

In this example, Image component will be blurred, a BlurView content will stay untouched.

Vibrancy View

The vibrancy effect lets the content underneath a blurred view show through more vibrantly

const { VibrancyView } = require('react-native-blur');

const Menu = React.createClass({
  render() {
    return (
      <Image source={{uri}} style={styles.menu}>
        <VibrancyView blurType="light" style={styles.blur}>
          <Text>Hi, I am a tiny menu item</Text>
        </VibrancyView>
      </Image>
    );
  }
});

Component properties

  • blurType (String) - blur type effect
    • xlight - extra light blur type
    • light - light blur type
    • dark - dark blur type

Android

Android support uses an external library which has slightly different properties and setup requirements. You must add the following to the android/app/build.gradle file:

android {
  ...
  defaultConfig {
    ...
    renderscriptTargetApi 20
    renderscriptSupportModeEnabled true
  }
}

repositories {
    maven { url 'https://github.com/500px/500px-android-blur/raw/master/releases/' }
}

dependencies {
  ...
  compile project(':react-native-blur')
}

buildscript {
    repositories {
        maven { url 'https://github.com/500px/500px-android-blur/raw/master/releases/' }
    }
    dependencies {
        classpath 'com.fivehundredpx:blurringview:1.0.0'
    }
}

The android BlurView works by blurring an existing referenced view, so you must wait till the view you want to blur is rendered and then provide the reference to the BlurView as the viewRef prop. Take a look at the example to see how it works.

It has the following props:

  • viewRef (Number) - a reference to the existing view you want to blur
  • blurRadius (Number)
  • downsampleFactor (Number)
  • overlayColor (Color)

Questions?

Feel free to contact me in twitter or create an issue