javascriptandroidiosreact-nativeblur

Can we create custom blur in react native?


Can we create a custom Blur in React Native like the @react-native-community/blur packages provide? That package works for iOS, but it creates many issues on Android. It requires a complete screen size, and the component does not follow constraints. I want an exact component like the first header, in which the producer is mentioned.

Blur Image


Solution

  • I Just figured it we can resolve that issue in android by using inner and outer wrapper with blurview. preview

    that is a sample code working for me

    Platform.OS == 'ios' ?
            (
                <TouchableOpacity>
                    <BlurView
                        style={styles.box_Wrappeer}
                        blurType="light"
                        blurAmount={10}
                    >
                        <View style={styles.row_1}>
                            <View style={styles.row_1.first_part}>
                                <Image style={styles.row_1.image} source={icon} ></Image>
                                <Text style={styles.row_1.text}>{title}</Text>
                            </View>
                            <TouchableOpacity style={styles.row_1.second_part}>
                                <Image style={styles.row_1.image2} source={require('../../assets/cross_icon.png')}></Image>
                            </TouchableOpacity>
                        </View>
                        <View style={styles.row_2}>
                            <Text style={styles.row_2.text}>
                                {user}
                            </Text>
                        </View>
                    </BlurView>
                </TouchableOpacity>
            ) :
            (
                <TouchableOpacity style={styles.box_wrapper_android}>
                    <BlurView
                        style={styles.box_inner_wrapper_android}
                        blurType="light"
                        blurAmount={10}
                    >
                        <View style={styles.box_Wrappeer}>
                            <View style={styles.row_1}>
                                <View style={styles.row_1.first_part}>
                                    <Image style={styles.row_1.image} source={icon} ></Image>
                                    <Text style={styles.row_1.text}>{title}</Text>
                                </View>
                                <TouchableOpacity style={styles.row_1.second_part}>
                                    <Image style={styles.row_1.image2} source={require('../../assets/cross_icon.png')}></Image>
                                </TouchableOpacity>
                            </View>
                            <View style={styles.row_2}>
                                <Text style={styles.row_2.text}>
                                    {user}
                                </Text>
                            </View>
                        </View>
                    </BlurView>
                </TouchableOpacity>
            )