Code Monkey home page Code Monkey logo

react-native-blur's Introduction

@react-native-community/blur

npm version

A component for UIVisualEffectView's blur and vibrancy effect on iOS, and BlurView on Android.

Current Maintainers:

Content

Installation

yarn add @react-native-community/blur

Install native dependencies (iOS only):

cd ios && pod install

Usage

BlurView

Property Possible Values Default Platform
blurType See blurType below - All
blurAmount 0 - 100 (The maximum blurAmount on Android is 32, so higher values will be clamped to 32) 10 All
reducedTransparencyFallbackColor Any color - iOS only
blurRadius 0 - 25 Matches iOS blurAmount Android only
downsampleFactor 0 - 25 Matches iOS blurAmount Android only
overlayColor Any color Default color based on iOS blurType Android only

blurType

Name Description
xlight extra light blur type
light light blur type
dark dark blur type
extraDark extra dark blur type (tvOS only)
regular regular blur type (iOS 10+ and tvOS only)
prominent prominent blur type (iOS 10+ and tvOS only)

blurType (iOS 13 only)

Name Description
chromeMaterial An adaptable blur effect that creates the appearance of the system chrome.
material An adaptable blur effect that creates the appearance of a material with normal thickness.
thickMaterial An adaptable blur effect that creates the appearance of a material that is thicker than normal.
chromeMaterial An adaptable blur effect that creates the appearance of the system chrome.
thinMaterial An adaptable blur effect that creates the appearance of an ultra-thin material.
ultraThinMaterial An adaptable blur effect that creates the appearance of an ultra-thin material.
chromeMaterialDark A blur effect that creates the appearance of an ultra-thin material and is always dark.
materialDark A blur effect that creates the appearance of a thin material and is always dark.
thickMaterialDark A blur effect that creates the appearance of a material with normal thickness and is always dark.
thinMaterialDark A blur effect that creates the appearance of a material that is thicker than normal and is always dark.
ultraThinMaterialDark A blur effect that creates the appearance of the system chrome and is always dark.
chromeMaterialLight An adaptable blur effect that creates the appearance of the system chrome.
materialLight An adaptable blur effect that creates the appearance of a material with normal thickness.
thickMaterialLight An adaptable blur effect that creates the appearance of a material that is thicker than normal.
thinMaterialLight An adaptable blur effect that creates the appearance of a thin material.
ultraThinMaterialLight An adaptable blur effect that creates the appearance of an ultra-thin material.

Complete usage example that works on iOS and Android:

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

export default function Menu() {
  return (
    <View style={styles.container}>
      <Image
        key={'blurryImage'}
        source={{ uri }}
        style={styles.absolute}
      />
      <Text style={styles.absolute}>Hi, I am some blurred text</Text>
      {/* in terms of positioning and zIndex-ing everything before the BlurView will be blurred */}
      <BlurView
        style={styles.absolute}
        blurType="light"
        blurAmount={10}
        reducedTransparencyFallbackColor="white"
      />
      <Text>I'm the non blurred text because I got rendered on top of the BlurView</Text>
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    justifyContent: "center",
    alignItems: "center"
  },
  absolute: {
    position: "absolute",
    top: 0,
    left: 0,
    bottom: 0,
    right: 0
  }
});

In this example, the Image component will be blurred, because the BlurView in positioned on top. But the Text will stay unblurred.

If the accessibility setting Reduce Transparency is enabled the BlurView will use reducedTransparencyFallbackColor as it's background color rather than blurring. If no reducedTransparencyFallbackColor is provided, theBlurViewwill use the default fallback color (white, black, or grey depending on blurType)

VibrancyView

Uses the same properties as BlurView (blurType, blurAmount, and reducedTransparencyFallbackColor).

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

VibrancyView is only supported on iOS. Also note that the VibrancyView must contain nested views

import { VibrancyView } from "@react-native-community/blur";

export default function Menu() {
  return (
    <Image source={{ uri }} style={styles.absolute}>
      <VibrancyView blurType="light" style={styles.flex}>
      <Text>Hi, I am some vibrant text.</Text>
      </VibrancyView>
    </Image>
  )
}

Example React Native App

This project includes an example React Native app, which was used to make the GIF in this README. You can run the apps by following these steps:

Clone the repository

git clone https://github.com/react-native-community/react-native-blur.git

Install dependencies

yarn

Run the app

yarn example android/ios

Questions?

Feel free to create an issue

react-native-blur's People

Contributors

adkenyon avatar aforty avatar ahanriat avatar arthur31416 avatar baransu avatar bilby91 avatar breadadams avatar charpeni avatar cmcewen avatar dependabot[bot] avatar eliperkins avatar evanbacon avatar gitim avatar jakehasler avatar jgkim avatar julienkode avatar kelset avatar kesha-antonov avatar kureev avatar levibuzolic avatar manasjayanth avatar msand avatar ndbroadbent avatar npomfret avatar sebqq avatar seidtgeist avatar sonicdoe avatar titozzz avatar viix avatar vonovak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-blur's Issues

Does not work

Just show red borders around the view and no blur at all =((

Please provide xcodeproj file in NPM module

Looking forward to using this though this is the first native module I've come across recently which didn't have a xcodeproj file checked in - which is what most people expect right now. It would be nice to have the installation consistency of other modules in this one as well.

For example please see react-native-video. Thanks!

Blur effect greys out the image completely

Hello, I'm trying to add a blur effect but it seems off. Here's the image with and without this library. I tried both BlurView and VibrantView:

screen shot 2015-12-15 at 3 52 29 pm

screen shot 2015-12-15 at 3 53 03 pm

Here's the code. Any ideas?

<View style={styles.contentContainer}>
  <Image
    style={styles.image}
    source={this.getImage()}>
    <BlurView blurType='light' style={styles.image}/>
  </Image>
</View>

red outline

blur view is positioned right and sized properly but all that shows up is a red outline of the view. I also attempted to use it as the child of a standard Image tag and it didnt work..

Blur without Image?

Is it possible to blur based on the content of existing view and not an image?

blur not working on iPad Retina/iPad2

blur effect doesn't appear to be working on some iPad devices in simulation

NOT working

  • iPad Retina
  • iPad 2

working on

  • iPad pro
  • iPad Air

this was the image i used as a full screen bg, incase image size has anything to do with it.
http://img00.deviantart.net/8910/i/2011/225/a/7/night_city_lights_by_ati711-d46fp5i.jpg

i thought it might be this size so i tried it with a larger
http://www.fyqyfz.com/data/uploads/15/334042-citylights-blur.jpg

still getting it specific devices.

Doesn't work with React Native 0.5

I'm trying to make react-native-blur working with react-native 0.5 but the only thing I get is a red border around the text:

        <View style={styles.container}>
          <Image source={require("image!background")}>
            <BlurView blurType="light">
              <Text>Hi, I am a tiny menu item</Text>
            </BlurView>
          </Image>
      </View>

To try it, i changed package.json in my fork specifying "react-native": "^0.5.x" as peer dependency. Any idea?

Support a configurable "blur radius"

It would be nice if we could configure a relative "amount" to blur something. This component is great, but I'm finding myself wanting the backgrounds to be blurred much less than this does by default.

Thanks!

Performance of BlurView during scroll

I'm using multiple BlurView items in one view and I'm hitting performance problems.

I have a list where each item contains: a scaled-down <Image>, a <Blur View> and icons.
When I scroll my view the perceived framerate drops significantly. Occasionally I see slight flickers in the <BlurView> items, as if they were being updated during scroll.

The FPS drops start being visible even in small lists (e.g. 6 elements). They occur both in the simulator and on the device. The issue happens when using <ScrollView> and with a <ListView> as well. I've experimented with the shouldRasterizeIOS View property, but couldn't get it to improve the situation.

Absolute positioning on BlurView child doesn't receive touches

The following will "Not Work" on iOS:

<BlurView style={{position: 'absolute', float-on-top-of-the-page}}>
  <ListView style={{position: 'absolute', left: 0, top: 20}}
    dataSource={this.state.dataSource}
    renderRow={(row) => <Text>{row}</Text>}
  />
</BlurView>

(The more real-world example is that I have a BlurView header containing an Autocomplete widget that pops open an absolutely-positioned ListView with autocomplete suggestions.)

Unfortunately, the elements in the ListView are unclickable (when those elements fall outside of the bounds of the BlurView). And any clicks/drags/interactions are sent to the elements physically underneath the ListView (ie, the elements outside of the BlurView hierarchy).

Basic example didn't work: "Could not find dependencies"

I went into examples/Basic and ran npm install. I get the following error when I try to run the packager. The error is the same whether I run npm start or react-native start. Thanks.

$ npm start

> [email protected] start /Users/foo/react-native-blur/examples/Basic
> node_modules/react-native/packager/packager.sh


Could not find dependencies.
Ensure dependencies are installed - run 'npm install' from project root.

$ npm -v
3.3.6
$ node -v
v5.0.0
$ react-native -v
react-native-cli: 0.1.10
react-native: 0.11.4

Change DEPLOYMENT_TARGET back to iOS=8.0

This identifies the earliest OS version on which your software can run.

I am targeting 8.0 and getting warnings:

Object file (/Users/grabbou/Library/Developer/Xcode/DerivedData/este-fmrlxbyzjguqiohdnboycovvmxjd/Build/Products/Debug-iphonesimulator/libRNBlur.a(BlurViewManager.o)) was built for newer iOS version (9.0) than being linked (8.0)

Was there any specific decision behind that?

Gamma differences between simulator and iphone?

When using react-native-blur, the effects rendered in the iOS simulator appear correct, but when built on the iphone itself, are a degree of magnitude darker as if the gamma were cranked down. Is this a known issue, or am I missing something?

Android Build: Dependency Issue - Could not find com.fivehundredpx:blurringview:1.0.0

Here's my error after:

npm install [email protected] --save
rnpm link

And a:

react-native run-android
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find com.fivehundredpx:blurringview:1.0.0.
     Searched in the following locations:
         file:/Users/kqn032/dev/Magneto/node_modules/react-native/android/com/fivehundredpx/blurringview/1.0.0/blurringview-1.0.0.pom
         file:/Users/kqn032/dev/Magneto/node_modules/react-native/android/com/fivehundredpx/blurringview/1.0.0/blurringview-1.0.0.jar
         file:/usr/local/opt/android-sdk/extras/android/m2repository/com/fivehundredpx/blurringview/1.0.0/blurringview-1.0.0.pom
         file:/usr/local/opt/android-sdk/extras/android/m2repository/com/fivehundredpx/blurringview/1.0.0/blurringview-1.0.0.jar

I assume I'm missing something that may not be in your npm package?

Creates too many subviews

bug

This seems to be because we add the effect in layoutSubviews and don't clean up after any previously created ones - I think we should use setBlurType to create it instead, and make sure to remove the previously created subview when we change it.

If I add this before creating the visual effect view:

  [visualEffectView removeFromSuperView];

It cleans up properly and we get the right number of layers, but we are still creating a bunch and deleting them, and thrashing leads to performance problems.

is it support scrollView?

i hava a image view wrapping the blur view, on the top of my component.the blur effect is ok, but when i scroll the view, the blur view will twinkle.

rnpm doesn't install ios dependencies

I ran:

$ npm install react-native-blur
[email protected] /Users/foo/FooProject
└── [email protected]  extraneous
$ rnpm -V
1.4.1
$ rnpm link
rnpm info Linking react-native-image-picker android dependency
rnpm info Android module react-native-image-picker is already linked

in my project folder. It didn't install any iOS dependencies. Had to do this the old fashioned way. Am I doing something wrong?

Thanks

Blur underlaying MapView

I'm trying to use this module to add a button on top of my mapview

      <View style={styles.container}>
        <MapView
            style={styles.map}
          />
          <VibrancyView
            style={styles.button}
            blurType="light">
              <Text style={styles.buttonText}>Test!</Text>
          </VibrancyView>
      </View>

Styles:

var styles = StyleSheet.create({
  button: {
    height: 50,
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 20,
    position: "absolute",
    bottom: 100,
    width: windowSize.width
  },
  buttonText: {
    color: '#007aff',
    fontFamily: '.HelveticaNeueInterface-MediumP4',
    fontSize: 17,
    fontWeight: 'bold',
    textAlign: 'center',
  },,
  map: {
    flex: 1
  }
});

Here's what I get:

http://i.imgur.com/X7m58ud.png

Any hints what I could be doing wrong?

Update for React Native 0.26

Hello can you please update the file BlurView and VibranceView, with following imports?

import React from 'react';
import {Component} from 'react';
import {requireNativeComponent} from 'react-native';

Thanks

Fading in?

Hey,

Awesome work on this.

Tried using Animated with the BlurView but it returns Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

Wrapping in view that animates opacity doesn't work either.

Any suggestions?

Blur child

Hi @Kureev,

Would it be possible to blur the childs of the BlurView ?
I'm asking you that question because of react-native-video, the Video component doesn't support subviews so no way to apply a blur filter currently...
Any idea ?

Thanks

Roadmap

  • Working prototype
  • More examples (your ideas are very welcome)
  • Support different types of blur: light, extra light and dark

React Native 0.8.0

Hello and thanks!

Is there a React Native 0.8.0 compatible version out there?
Impossible to make it work for me. Do I miss something?

Thanks a lot.

Fatal exception in 0.7.7

I'm getting this error after installing 0.7.7. Works just fine in 0.7.6.

Unhandled JS Exception: In this environment the target of assign MUST be an object.This error is a performance optimization and not spec compliant.

I'm guessing it's because of 3c0fd0d

Does it blur everything?

Forgive my ignorance, but should these effects blur everything underneath them? Or does it only blur images?

For example, if I have a page of text, and then put this element on top of it, should I expect a blur?

publish to npm?

I see react native 0.25 compatibility warning fix is merged, any plan on updating npm package?

Couldn't blur, gives backgroundColor

I've used the BlurView in my previous project, It was working as expected but I couldn't make it work for my current project.

I've tried like in the example. Tried BlurView on both for parent and child component, it's the same.
The gray area in the screenshot should be blurred.

ekran resmi 2015-11-29 00 29 20

Broken in RN 0.23

I don't see any error in build but BlurView no longer work in app.

RN 0.23 also added new blurRadius prop to Image. Which I don't think is relevant but fyi

Build fails

The latest version of react-native-blur breaks the build with the following reason:
#import "RCTComponent.h" file not found

Is it possible to add transition animation when turning blur effect off?

My use case is that I'm blurring the whole background view while a panel expands and transits to a new scene;
And when user goes back from the new scene, I want same thing happens - the panel shrinks and the blur goes away.

If I apply LayoutAnimation while expanding the panel and adding the blur view, the blur effect does has a transition animation, but I don't how to apply the same effect while removing the blur view.
Is there currently a possible way to do a nice blur -> plain view transition effect?

Can't compile under a Release scheme

I added RNBlur to my project correctly and everything, builds fine and is working correctly in my React Native app...with a Debug build that is.

If I try to do a Release build in Xcode, I get this error:

clang: error: no such file or directory: '/Users/marcshilling/Library/Developer/Xcode/DerivedData/Wego-fkagpfjtiozdwmhallyibbxulerw/Build/Products/Release-iphonesimulator/libRNBlur.a'

I've tried some obvious debugging...cleaning the project, comparing the xcodeproj file to other React Native libraries I'm using...what am I missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.