Coder Social home page Coder Social logo

react-native-radial-gradient's People

Contributors

alyalya avatar andreasboehm avatar antewall avatar carne8 avatar itsramiel avatar kodayashi avatar kryjex avatar mayurbaldha avatar priyankabitcanny avatar r3nya avatar robhogan avatar saeedzhiany avatar shkatulo avatar sreeni34 avatar surajit-bitcanny avatar surajitsarkar19 avatar yousefed 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

react-native-radial-gradient's Issues

iOS: libSRSRadialGradient.a no such file or directory

After a recent upgrade from RN0.64 to RN0.73

clang: error: no such file or directory: '/path-to-app/node_modules/react-native-radial-gradient/ios/build/Debug-iphoneos/libSRSRadialGradient.a'
Command Ld failed with a nonzero exit code

React Native: v0.73.2
xCode: 14.2

Tried these, with no success

  • changing path to /path-to-app/ios/build/Debug-iphoneos/SRSRadialGradient/libSRSRadialGradient.a (which exists during build)
  • Reinstalling the package
  • podfile contains pod 'SRSRadialGradient', :path => '../node_modules/react-native-radial-gradient/ios'
  • Added to build phases -> Link binary with libraries
image

Fix android build issue react-native 0.68

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-radial-gradient/android/build.gradle b/node_modules/react-native-radial-gradient/android/build.gradle
index 6a3fde8..81f6e66 100644
--- a/node_modules/react-native-radial-gradient/android/build.gradle
+++ b/node_modules/react-native-radial-gradient/android/build.gradle
@@ -9,7 +9,6 @@ buildscript {
     if (project == rootProject) {
         repositories {
             google()
-            jcenter()
             mavenCentral()
         }
 
@@ -40,10 +39,9 @@ allprojects {
     repositories {
         google()
         mavenCentral()
-        jcenter()
     }
 }
 
 dependencies {
-    compile 'com.facebook.react:react-native:+'
+    implementation 'com.facebook.react:react-native:+'
 }

This issue body was partially generated by patch-package.

Could not find method compile() error on Android

Encountered an error on latest RN version 0.68.1

A problem occurred evaluating project ':react-native-radial-gradient'.

Could not find method compile() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Screen Shot 2022-04-26 at 11 07 07 AM

Environment:

"react": "17.0.2",
"react-native": "0.68.1",
"Platform": "Android only"

[BUG]: Does not support transparent backgrounds.

I'm trying to interpolate between a regular color and a transparent one in order to have 2 radial gradients that interact with each other. Unfortunately it seems transparent gets ignored and interpreted as black. Transparent hex values also don't work.

      <RadialGradient
        style={{ width: 200, height: 200 }}
        colors={['#00ffff', 'transparent']}
        stops={[0.3]}
        center={[100, 100]}
        radius={200}
      />

results in
image

Whereas the black pixels should be transparent.

Invariant Violation: Native component for "SRSRadialGradient" does not exist

Hi! Thanks for this project!

I`m trying to get it set on a new React Native project on iOS, carefully going through your instructions.

But got this and have no idea how to fix it:
Invariant Violation: Native component for "SRSRadialGradient" does not exist

This error is located at:
in SRSRadialGradient (at index.js:28)
in RCTView (at View.js:71)
in View (at index.js:27)
in RadialGradient (at App.js:21)
in App (at renderApplication.js:35)
in RCTView (at View.js:71)
in View (at AppContainer.js:102)
in RCTView (at View.js:71)
in View (at AppContainer.js:122)
in AppContainer (at renderApplication.js:34)

getViewConfig
requireNativeComponent.js:112:6
get$1
ReactNativeRenderer-dev.js:11859:17
createInstance
ReactNativeRenderer-dev.js:12022:27
completeWork
ReactNativeRenderer-dev.js:8814:14
completeUnitOfWork
ReactNativeRenderer-dev.js:10418:8
performUnitOfWork
ReactNativeRenderer-dev.js:10523:32
workLoop
ReactNativeRenderer-dev.js:10584:43
_invokeGuardedCallback
ReactNativeRenderer-dev.js:134:15
invokeGuardedCallback
ReactNativeRenderer-dev.js:67:32
renderRoot
ReactNativeRenderer-dev.js:10677:30
performWorkOnRoot
ReactNativeRenderer-dev.js:11449:34
performWork
ReactNativeRenderer-dev.js:11364:8
requestWork
ReactNativeRenderer-dev.js:11258:18
scheduleWorkImpl
ReactNativeRenderer-dev.js:11099:22
scheduleRootUpdate
ReactNativeRenderer-dev.js:11690:17
render
ReactNativeRenderer-dev.js:12919:35
renderApplication
renderApplication.js:58:21
runApplication
AppRegistry.js:196:26
__callFunction
MessageQueue.js:353:47

MessageQueue.js:118:26
__guardSafe
MessageQueue.js:316:6
callFunctionReturnFlushedQueue
MessageQueue.js:117:17

I tried to fix this using https://stackoverflow.com/questions/47672941/invariant-violation-native-component-for-rnsvgsvgview-does-not-exist but this didn`t help.
Maybe you have some ideas?

Suggestion: Add relative centering and radius

It would be much more convenient if the center and radius props also accepted relative arguments such as percentage values contained in strings. As can be done with a component's width and height.

e.g.

<RadialGradient
          ...
          center={['25%', '50%']}
          radius={'10%'}>

Linking error

I've installed package using npm install react-native-radial-gradient --save and tried to linking with react-native link react-native-radial-gradient. Below I've mentioned the error.

rnpm-install ERR! Something went wrong while linking. Error: Expected "/* Begin ", "/*", """, "}", or [A-Za-z0-9_.] but "<" found.
Please file an issue here: https://github.com/facebook/react-native/issues

Expected "/* Begin ", "/*", """, "}", or [A-Za-z0-9_.] but "<" found.

SyntaxError: Expected "/* Begin ", "/*", """, "}", or [A-Za-z0-9_.] but "<" found.
at peg$buildStructuredError (<project_dir>\lms-mobile-app\node_modules\xcode\lib\parser\pbxproj.js:412:12)
at Object.peg$parse [as parse] (<project_dir>\lms-mobile-app\node_modules\xcode\lib\parser\pbxproj.js:1886:11)
at pbxProject.parseSync (<project_dir>\lms-mobile-app\node_modules\xcode\lib\pbxProject.js:46:24)
at isInstalled (<project_dir>\lms-mobile-app\node_modules\react-native\local-cli\link\ios\isInstalled.js:19:60)
at Object.isInstalled (<project_dir>\lms-mobile-app\node_modules\react-native\local-cli\link\ios\common\isInstalled.js:8:5)
at Object.keys.forEach.platform (<project_dir>\lms-mobile-app\node_modules\react-native\local-cli\link\link.js:57:36)
at Array.forEach ()
at linkDependency (<project_dir>\lms-mobile-app\node_modules\react-native\local-cli\link\link.js:44:32)

--
I'm using following versions
react-native-cli: 1.2.0
react-native: 0.57.1

Reanimated animation

I have tried to play with Reanimated 2, but unable to make it work.

The gradient and radius stay the same.

It works on React native SVG for the radius while updating it, but did get how to figure out how to draw a gradient.

Thx for your help.

Unable to link the package in react native 0.68.1 android

android/app/src/main/java/com/dating/MainApplication.java:33: error: cannot find symbol
packages.add(new RNRadialGradientPackage());
^
symbol: class RNRadialGradientPackage


android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:121: error: cannot find symbol
new RNRadialGradientPackage(),
^
symbol: class RNRadialGradientPackage
location: class PackageList


android/app/src/main/java/com/dating/MainApplication.java:16: error: package com.surajit.rnrg does not exist
import com.surajit.rnrg.RNRadialGradientPackage;


android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:47: error: package com.surajit.rnrg does not exist
import com.surajit.rnrg.RNRadialGradientPackage;

The package won't work even if linked manually

Failed to list versions for com.facebook.react:react-native

With jCenter being sunset and currently having issues, I currently can't build my application due to some references in the project's gradle config.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':ostrichapp_react-native-radial-gradient:compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':ostrichapp_react-native-radial-gradient:releaseCompileClasspath'.
   > Could not resolve com.facebook.react:react-native:+.
     Required by:
         project :ostrichapp_react-native-radial-gradient
      > Failed to list versions for com.facebook.react:react-native.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/com/facebook/react/react-native/maven-metadata.xml'.
               > Read timed out

Incident status: https://status.gradle.com/incidents/9740r6bzx438

From what I've read elsewhere this is fixable by updating the gradle config on your side, possibly even by bumping version with no real changes.

requireNativeComponent: "SRSRadialGradient" was not found in the UIManager.

Hi,

I am trying to install this package to my react native, but I am getting the following error:
requireNativeComponent: "SRSRadialGradient" was not found in the UIManager.

After installing in the library, I executed pod install int the ios directory but it did not add SRSRadialGradient as a dependency. I believe there is an issue with autolinking?

Here is an example repro. If you try to install and then run pod install you'll see that it doesnt add package to the podfile and you'll get the error specified above when trying to use the component

Unable to press child button when using 2 absolutely positioned RadialGradients

I have 2 RadialGradients (both absolutely positioned), with .absoluteFill set, so they both fill the entire screen and overlap one another. Each one has a child TouchableOpacity, but the problem is that only the second one is pressable. The first is obstructed by the 2nd, thereby preventing touches from registering. If I use Views instead of RadialGradients, I can pass the prop 'pointerEvents="box-none"', to indicate that the parent view should allow touches to pass through to any element under them. However, this does not work when using RadialGradient. Here's a simple example of the scenario.

export default class RadialGradientIssue extends React.Component {
    render() {
        return (
            <View style={{flex: 1}}>
                <RadialGradient
                    colors={['#FF000055', '#00000000']}
                    stops={[0, 1]}
                    center={[100, 100]}
                    radius={130}
                    style={StyleSheet.absoluteFill}
                    pointerEvents={'box-none'}>
                    <TouchableOpacity
                        style={{
                            width: 50,
                            height: 50,
                            marginTop: 40,
                            backgroundColor: 'blue',
                        }}
                        onPress={() => alert('Pressed blue!')}
                    />
                </RadialGradient>
                <RadialGradient
                    colors={['#00FF0055', '#00000000']}
                    stops={[0, 1]}
                    center={[300, 300]}
                    radius={180}
                    style={StyleSheet.absoluteFill}
                    pointerEvents={'box-none'}>
                    <TouchableOpacity
                        style={{
                            marginTop: 40,
                            width: 50,
                            height: 50,
                            backgroundColor: 'green',
                            alignSelf: 'flex-end',
                        }}
                        onPress={() => alert('Pressed green!')}
                    />
                </RadialGradient>
            </View>
        );
    }
}

Looking at the index.js source for RadialGradient, I found that the NativeRadialGradient element does not accept any props from the parent component. When I add 'pointerEvents="box-none"' directly to NativeRadialGradient (see below), everything works as expected.

<View ref={(component) => { this.gradientRef = component; }} {...otherProps} style={style}>
                <NativeRadialGradient
                    pointerEvents={"box-none"} // adding this line fixes the issue
                    style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}}
                    colors={(colors)?colors.map(processColor):null}
                    center={center}
                    radius={radius}
                    stops={stops}
                />
                { children }
</View>

Would it be possible to expose a 'nativeProps' prop to the application, so that we can handle scenarios like this? The library might look like this afterward.

<View ref={(component) => { this.gradientRef = component; }} {...otherProps} style={style}>
                <NativeRadialGradient
                    {...this.props.nativeProps} // a possible solution
                    style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}}
                    colors={(colors)?colors.map(processColor):null}
                    center={center}
                    radius={radius}
                    stops={stops}
                />
                { children }
</View>

Thank you!

Negative center coordinates are not working

When I set center to center={[viewWidth/2, -200]} radial gradient is drown in the middle of my view.

Removing checks from GradientView::populateDefaultCenterValue and GradientView::drawGradient methods fixed the problem.
I'm sure removing checks in iOS classes will work too.
Please fix

BorderRadius not working

Hello,
I really like the library but simply borderRadius prop not working :(
I've tried to fix it but could not find the solution. Can you please take a look at it?

Any way to cut a quarter of the circle?

I want a ๐Ÿ•.

Tried to wrap the <RadialGradient/> with a <View style={{height: radius/2, width/2}}/>, but the gradient will draw outside it anyway.

Is it possible?

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.