react-native-circular-progress icon indicating copy to clipboard operation
react-native-circular-progress copied to clipboard

Conical gradient support

Open fdnhkj opened this issue 9 years ago • 30 comments

It would be nice to have support for conical gradient. Has anyone an idea on how to implement it ?

colorgradient

fdnhkj avatar Oct 18 '16 20:10 fdnhkj

Any luck on finding your conical gradient... I need that in a slider as well

GroupXTech avatar Oct 27 '16 16:10 GroupXTech

Yes I'm looking for something similar, I want to animate the colour of the fill.

I can get it to work by removing the validation of PropTypes.string but it is incredibly slow.

morelazers avatar Oct 28 '16 08:10 morelazers

@fdnhkj Cannonical gradients aren't supported in SVG. In my other component (https://github.com/bgryszko/react-native-circular-slider) I achieve exactly what you're looking for by splitting circle into segments and draw small linear gradients – in practice if gradient colors difference is subtle or there are enough "segments" it'll look as if it's cannonical gradient.

Link to specific code: https://github.com/bgryszko/react-native-circular-slider/blob/master/src/CircularSlider.js#L161-L168

bartgryszko avatar Jan 07 '17 09:01 bartgryszko

Indeed, I forgot to update this issue with my findings, I'll try to find back my repo & share it.

Basically I switched to react-native-svg and as you mentioned splited the circle in multiple segments with attached linear gradients (see http://jsfiddle.net/Cy7ec/3/).

The conical gradient was looking fine on both iOS & Android but I had quite some issues with the Android animations (lots of dropped fps).

It's maybe worth trying with the latest versions of react-native & react-native-svg. I will give you updates ASAP.

fdnhkj avatar Jan 07 '17 23:01 fdnhkj

That's great! In fact this library would need switch over to react-native-svg as well.

Bart

On 8 Jan 2017, at 12:47 AM, Fidan Hakaj [email protected] wrote:

Indeed, I forgot to update this issue with my findings, I'll try to find back my repo & share it.

Basically I switched to react-native-svg and as you mentioned splited the circle in multiple segments with attached linear gradients (see http://jsfiddle.net/Cy7ec/3/).

The conical gradient was looking fine on both iOS & Android but I had quite some issues with the Android animations (lots of dropped fps).

It's maybe worth trying with the latest versions of react-native & react-native-svg. I will give you updates ASAP.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

bartgryszko avatar Jan 08 '17 08:01 bartgryszko

Voilà, I published my findings after upgrading to latest react-native and react-native-svg in fdnhkj/react-native-conical-gradient.

It looks like there are some dropped fps. I don't really see how to improve it tho, suggestions are welcome 🙂

Fidan

fdnhkj avatar Jan 09 '17 22:01 fdnhkj

I'm happy to accept PR if anybody would be able to merge this into main lib.

bartgryszko avatar Mar 04 '17 10:03 bartgryszko

+1

zoharlevin avatar Mar 07 '17 10:03 zoharlevin

+1

t2krew avatar Mar 14 '17 09:03 t2krew

+1

rodrigooler avatar May 31 '17 03:05 rodrigooler

@fdnhkj How to make it spin in the opposite direction? (like in the first your post)

valerybodak avatar Jun 12 '17 14:06 valerybodak

@fdnhkj based on this research the only possible solution to improve FPS is using canvas instead of svg

NeXTs avatar Aug 30 '17 10:08 NeXTs

+1

robert-stevens avatar Feb 14 '18 08:02 robert-stevens

@bartgryszko I can try add this feature, into react-native-circular-progress. I updated @fdnhkj example with some changes and I have ideas how to increase perfomance with smooth gradient on the screen.

MikePodgorniy avatar Nov 30 '18 15:11 MikePodgorniy

@fdnhkj How to make it spin in the opposite direction? i.e clockwise instead of anticlockwise

hanishcodebrew avatar Dec 05 '18 07:12 hanishcodebrew

@hanishcodebrew you can wrap component into

<View style={ { transform: [ { scaleX: -1 }] } }>

or use similar code https://github.com/MikePodgorniy/react-native-conical-gradient-progress/blob/de35329780ed6431ff21710dc8a6c69b639263e8/CircularProgress.js#L175-L183

MikePodgorniy avatar Dec 05 '18 07:12 MikePodgorniy

Thanks @MikePodgorniy for the instant reply. It works. I am facing a issue in Android. screen shot 2018-12-05 at 1 14 52 pm

I have given 45 to fill but its showing complete circle. And also can we add image and text inside the circle ?

hanishcodebrew avatar Dec 05 '18 07:12 hanishcodebrew

@MikePodgorniy I'm not actively participating in developing this library as I'm not working on any RN project currently. That said, feel free to add PR, if not me, maybe @Jacse or @markusl would be able to review and merge it.

bartgryszko avatar Dec 05 '18 07:12 bartgryszko

@hanishcodebrew yes, you can 👍 use render callback to this. but you need to rescale your inner components again https://github.com/MikePodgorniy/react-native-conical-gradient-progress/blob/de35329780ed6431ff21710dc8a6c69b639263e8/example/App.js#L25-L32

MikePodgorniy avatar Dec 05 '18 07:12 MikePodgorniy

@fdnhkj,@GroupXTech,@morelazers,@bartgryszko,@fdnhkj,@NeXTs,@MikePodgorniy,@hanishcodebrew : I wanted to know how it ended, it also served me.

@fdnhkj: Your module react-native-conical-gradient, I do not find it on npm you can upload it, can you also put an example code?

@MikePodgorniy: Your module react-native-conical-gradient-progress, I do not find it on npm you can upload it, can you also put an example code?

For both: The sample code of the images of your modules would be a step forward.

An example that can also be tried on snack.expo.io, would be very ideal.

Angelk90 avatar Jan 18 '19 00:01 Angelk90

@Angelk90 Try now, it is available as an npm-package: https://www.npmjs.com/package/react-native-conical-gradient-progress.

You can find an example here – https://github.com/MikePodgorniy/react-native-conical-gradient-progress/tree/master/example

if you use clear react-native you should install react-native-svg.

MikePodgorniy avatar Jan 18 '19 08:01 MikePodgorniy

@MikePodgorniy : I do not understand why among the dependencies you did not put svg in the package.json?

Angelk90 avatar Jan 18 '19 10:01 Angelk90

@MikePodgorniy : I tried to convert your module to try it on https://snack.expo.io/ I am given the following error: TypeError: undefined is not an object (evaluating 'o.map') Line 27 of CircularProgress: Here is the link where you can try it: https://snack.expo.io/HkDheSJmE

Angelk90 avatar Jan 18 '19 12:01 Angelk90

@Angelk90
Thank you, I will check this issue later. I tested component with expo local. If you want we can continue discussing there https://github.com/MikePodgorniy/react-native-conical-gradient-progress

MikePodgorniy avatar Jan 18 '19 13:01 MikePodgorniy

@MikePodgorniy : Do not allow me to create issues in the indicated project. It's because your project is a fork.

Angelk90 avatar Jan 18 '19 14:01 Angelk90

@Angelk90 sorry, try again

MikePodgorniy avatar Jan 18 '19 14:01 MikePodgorniy

@MikePodgorniy : I answered you in your project, I look forward to your response.

Angelk90 avatar Jan 19 '19 17:01 Angelk90

Voilà, I published my findings after upgrading to latest react-native and react-native-svg in fdnhkj/react-native-conical-gradient.

It looks like there are some dropped fps. I don't really see how to improve it tho, suggestions are welcome 🙂

Fidan

I have the same problem as well, the UI's fps is dropped to 2x. Any ideas on how to improve it?

ngnclht1102 avatar Aug 23 '19 08:08 ngnclht1102

I have been doing something similar. My approach uses "LinearGradient" react-native-svg.

You can give it a try by:

npm install [email protected]

You will need to add tintColorSecondary prop to trigger the gradient mode.

thanakij avatar Nov 14 '20 07:11 thanakij

I have been doing something similar. My approach uses "LinearGradient" react-native-svg.

You can give it a try by:

npm install [email protected]

You will need to add tintColorSecondary prop to trigger the gradient mode.

GREAT, THANK YOU! 👍

minafa96 avatar May 21 '21 08:05 minafa96