react-native-blur icon indicating copy to clipboard operation
react-native-blur copied to clipboard

1,How to use it in List 2, how to use on < View/> <Text /> components

Open z3season opened this issue 5 years ago • 8 comments

Question

1,How to use it in FlatList item? 2, how to use on < View/> <Text /> components ?

z3season avatar Feb 14 '20 15:02 z3season

The main example on the ReadMe should be removed altogether and changed to a View. I'm gonna take a guess and say that 90% of people coming to the readme for solutions need to blur a View and not an image. Actually anything but an image in the example would have sufficed. They picked the worst example to display IMO.

Juan-Castelli avatar Feb 18 '20 19:02 Juan-Castelli

@Juan-Castelli i am not 100% but i think till 3.4.1 it was just not possible to blur the whole view on iOS and Android so this is the example which worked on both.

But sind 3.4.1/3.5.0 you can just add a BlurView and everything behind it will be blurred. I've created a Custom Modal with a BlurView Background behind it which works fine on 3.5.0 and looks pretty cool.

Psiiirus avatar Mar 20 '20 13:03 Psiiirus

@seasonZzl

The current README demo is wrong it should show something like this

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

export default class Menu extends Component {

  render() {
    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}
          viewRef={this.state.viewRef}
          blurType="light"
          blurAmount={10}
        />
        <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
  }
});

Psiiirus avatar Mar 20 '20 13:03 Psiiirus

@Psiiirus Thank you for pointing this out. Why is the documentation wrong?

jan-happy avatar Apr 01 '20 11:04 jan-happy

@jan-happy well i think because no one did a PR so far...me either xD

Psiiirus avatar Apr 01 '20 11:04 Psiiirus

It would be great if the changes in the documentation would be made by the same contributors that made the changes to the code. Because I guess they know best what has changed ;)

jan-happy avatar Apr 01 '20 11:04 jan-happy

I general u r totally right :) but anyways I did a PR with my example code...lets see if it gets excepted.

@seasonZzl can this ticket be closed?

Psiiirus avatar Apr 01 '20 11:04 Psiiirus

It is not addressed on how it's used in a flatlist. @Psiiirus
You might say it is because the same way can be applied to a flatlist. but nah.

The problem with flatlist is when you place the blur inside, yes, it does blur the first item, but until you scroll up the other visible items have pure white /black background.

How does one solve this issue?

C-odes avatar Mar 17 '21 11:03 C-odes