Skip to content

Commit 5a1d8d3

Browse files
Feat: Added default gradient(168 count) and it's like as https://fx-gradient-previewer.netlify.app/
1 parent fd8f43f commit 5a1d8d3

File tree

11 files changed

+223
-23
lines changed

11 files changed

+223
-23
lines changed

Example/App/DotSpinnerButton.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ const DotSpinnerButton = () => {
2626
onPress={handleButtonPress}
2727
animationType={'bounceIn'}
2828
gradientType={'Radial'}
29-
gradientColors={['#231557', '#44107A', '#FF1361', '#FFF800']}
30-
gradientColoroffset={['0%', '29%', '67%', '100%']}
31-
gradientColorAngle={90}
29+
gradientName={'Night Fade'}
3230
gradientRadialRadius={10}
3331
gradientButtonHeight={50}
3432
radialRadiusx={"50%"}

Example/App/SkypeSpinnerButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const SkypeSpinnerButton = () => {
2626
}}
2727
onPress={handleButtonPress}
2828
gradientType={'Radial'}
29-
gradientColors={['#231557', '#44107A', '#FF1361', '#FFF800']}
29+
gradientColors={['#44107A', '#FF1361', '#dead00', '#231557']}
3030
gradientColoroffset={['0%', '29%', '67%', '100%']}
3131
gradientColorAngle={90}
3232
gradientRadialRadius={10}

Example/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"react-native-animatable": "^1.3.3",
2020
"react-native-gradients": "^1.1.1",
2121
"react-native-indicators": "^0.17.0",
22-
"react-native-spinner-button": "^1.0.4",
22+
"react-native-spinner-button": "^1.0.5",
2323
"react-native-svg": "^12.1.0"
2424
},
2525
"devDependencies": {

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ Don't forget to set the state variable you have given to _isLoading_ prop false
160160
* Its a stylesheet object.
161161
* This style apply when identify button disable or if network connect not available.
162162
* Default value: null | undefined
163+
29. **gradientName**
164+
* Its a sample gradient name.
165+
* Default type: string
166+
* Its default value is null | undefined.
167+
* This properties used whenever you want to need gradient but not pass __gradientColors__, __gradientColoroffset__ and __gradientColorAngle__ properties.
168+
* if you want to see color combination of [Sample gradient](https://fx-gradient-previewer.netlify.app/)
163169
164170
## Example
165171
A full working example project is here [Example](https://github.com/simformsolutions/react-native-spinner-button/tree/master/Example)

components/ChildrenView.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const ChildrenView = ({
1515
radialRadiusy,
1616
radialRadiusRX,
1717
radialRadiusRY,
18-
children
18+
children,
19+
gradientName
1920
}) => {
2021
const isLinearGradient = gradientType?.trim()?.toLowerCase() === 'linear';
2122
const isRadialGradient = gradientType?.trim()?.toLowerCase() === 'radial';
@@ -28,6 +29,7 @@ const ChildrenView = ({
2829
animatedStyles={animatedStyles}
2930
gradientColoroffset={gradientColoroffset}
3031
gradientColors={gradientColors}
32+
gradientName={gradientName}
3133
gradientRadialRadius={gradientRadialRadius}
3234
gradientButtonHeight={gradientButtonHeight}
3335
/>
@@ -40,6 +42,7 @@ const ChildrenView = ({
4042
radialRadiusRX={radialRadiusRX}
4143
radialRadiusRY={radialRadiusRY}
4244
children={children}
45+
gradientName={gradientName}
4346
animatedStyles={animatedStyles}
4447
gradientColoroffset={gradientColoroffset}
4548
gradientColors={gradientColors}
@@ -63,7 +66,8 @@ ChildrenView.propTypes = {
6366
radialRadiusy: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
6467
radialRadiusRX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
6568
radialRadiusRY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
66-
children: PropTypes.any.isRequired
69+
children: PropTypes.any.isRequired,
70+
gradientName: PropTypes.string
6771
}
6872

6973
export default ChildrenView;

components/LinearGradient.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Animated, View } from 'react-native';
44
import styles from './styles/SpinnerButtonStyle';
55
import { getColorList, getAnglePercentageObject } from './utils'
66
import Svg, { Defs, LinearGradient as SVGLinearGradient, Rect, Stop } from 'react-native-svg'
7+
import { getGradientFromName } from './utils/getAnglePercentageObject';
78

89
const AnimatedRect = Animated.createAnimatedComponent(Rect);
910

@@ -14,11 +15,13 @@ const LinearGradient = ({
1415
gradientRadialRadius,
1516
gradientColoroffset = [],
1617
gradientColors = [],
17-
gradientButtonHeight
18+
gradientButtonHeight,
19+
gradientName
1820
}) => {
1921
const rectWidth = animatedStyles.width;
20-
const angleObj = getAnglePercentageObject(angle)
21-
const colorList = getColorList(gradientColoroffset, gradientColors);
22+
const gradientData = getGradientFromName(gradientName);
23+
const angleObj = getAnglePercentageObject(gradientData?.angle || angle)
24+
const colorList = getColorList(gradientData?.offset || gradientColoroffset, gradientData?.colors || gradientColors);
2225
return (
2326
<View style={[styles.defaultGradientContainerStyle, styles.centerAlign, { height: gradientButtonHeight }]}>
2427
<View style={styles.absoluteView}>
@@ -61,7 +64,8 @@ LinearGradient.propTypes = {
6164
gradientRadialRadius: PropTypes.number,
6265
gradientColoroffset: PropTypes.array,
6366
gradientColors: PropTypes.array,
64-
gradientButtonHeight: PropTypes.number
67+
gradientButtonHeight: PropTypes.number,
68+
gradientName: PropTypes.string
6569
}
6670

6771
export default LinearGradient

components/RadialGradient.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getColorList } from './utils';
44
import { Animated, View } from 'react-native';
55
import styles from './styles/SpinnerButtonStyle';
66
import Svg, { Defs, RadialGradient as SVGRadialGradient, Rect, Stop } from 'react-native-svg'
7+
import { getGradientFromName } from './utils/getAnglePercentageObject';
78

89
const AnimatedRect = Animated.createAnimatedComponent(Rect);
910

@@ -17,10 +18,12 @@ const RadialGradient = ({
1718
radialRadiusx,
1819
radialRadiusy,
1920
radialRadiusRX,
20-
radialRadiusRY
21+
radialRadiusRY,
22+
gradientName
2123
}) => {
2224
const rectWidth = animatedStyles.width;
23-
const colorList = getColorList(gradientColoroffset, gradientColors);
25+
const gradientData = getGradientFromName(gradientName);
26+
const colorList = getColorList(gradientData?.offset || gradientColoroffset, gradientData?.colors || gradientColors);
2427
return (
2528
<View style={[styles.defaultGradientContainerStyle, styles.centerAlign, { height: gradientButtonHeight }]}>
2629
<View style={styles.absoluteView}>
@@ -63,6 +66,7 @@ RadialGradient.propTypes = {
6366
gradientColoroffset: PropTypes.array,
6467
gradientColors: PropTypes.array,
6568
gradientButtonHeight: PropTypes.number,
69+
gradientName: PropTypes.string,
6670
radialRadiusRX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
6771
radialRadiusRY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
6872
radialRadiusx: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,

components/SpinnerButton.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const SpinnerButton = ({
2222
indicatorCount,
2323
size,
2424
spinnerOptions,
25+
gradientName,
2526
gradientType,
2627
gradientColors,
2728
gradientColoroffset,
@@ -76,6 +77,7 @@ const SpinnerButton = ({
7677
radialRadiusy={radialRadiusy}
7778
radialRadiusRX={radialRadiusRX}
7879
radialRadiusRY={radialRadiusRY}
80+
gradientName={gradientName}
7981
children={
8082
<>
8183
{isAnimationType &&
@@ -147,7 +149,8 @@ SpinnerButton.propTypes = {
147149
disabled: PropTypes.bool,
148150
isLoading: PropTypes.bool,
149151
isConnected: PropTypes.bool,
150-
disableStyle: PropTypes.oneOfType([PropTypes.array, PropTypes.object])
152+
disableStyle: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
153+
gradientName: PropTypes.oneOf(["Warm Flame", "Night Fade", "Spring Warmth", "Juicy Peach", "Young Passion", "Lady Lips", "Sunny Morning", "Rainy Ashville", "Frozen Dreams", "Winter Neva", "Dusty Grass", "Tempting Azure", "Heavy Rain", "Amy Crisp", "Mean Fruit", "Deep Blue", "Ripe Malinka", "Cloudy Knoxville", "Malibu Beach", "New Life", "True Sunset", "Morpheus Den", "Rare Wind", "Near Moon", "Wild Apple", "Saint Petersburg", "Plum Plate", "Everlasting Sky", "Happy Fisher", "Blessing", "Sharpeye Eagle", "Ladoga Bottom", "Lemon Gate", "Itmeo Branding", "Zeus Miracle", "Old Hat", "Star Wine", "Happy Acid", "Awesome Pine", "New York", "Shy Rainbow", "Mixed Hopes", "Fly High", "Strong Bliss", "Fresh Milk", "Snow Again", "February Ink", "Kind Steel", "Soft Grass", "Grown Early", "Sharp Blues", "Shady Water", "Dirty Beauty", "Great Whale", "Teen Notebook", "Polite Rumors", "Sweet Period", "Wide Matrix", "Soft Cherish", "Red Salvation", "Burning Spring", "Night Party", "Sky Glider", "Heaven Peach", "Purple Division", "Aqua Splash", "Spiky Naga", "Love Kiss", "Clean Mirror", "Premium Dark", "Cold Evening", "Cochiti Lake", "Summer Games", "Passionate Bed", "Mountain Rock", "Desert Hump", "Jungle Day", "Phoenix Start", "October Silence", "Faraway River", "Alchemist Lab", "Over Sun", "Premium White", "Mars Party", "Eternal Constance", "Japan Blush", "Smiling Rain", "Cloudy Apple", "Big Mango", "Healthy Water", "Amour Amour", "Risky Concrete", "Strong Stick", "Vicious Stance", "Palo Alto", "Happy Memories", "Midnight Bloom", "Crystalline", "Party Bliss", "Confident Cloud", "Le Cocktail", "River City", "Frozen Berry", "Child Care", "Flying Lemon", "New Retrowave", "Hidden Jaguar", "Above The Sky", "Nega", "Dense Water", "Seashore", "Marble Wall", "Cheerful Caramel", "Night Sky", "Magic Lake", "Young Grass", "Colorful Peach", "Gentle Care", "Plum Bath", "Happy Unicorn", "African Field", "Solid Stone", "Orange Juice", "Glass Water", "North Miracle", "Fruit Blend", "Millennium Pine", "High Flight", "Mole Hall", "Space Shift", "Forest Inei", "Royal Garden", "Rich Metal", "Juicy Cake", "Smart Indigo", "Sand Strike", "Norse Beauty", "Aqua Guidance", "Sun Veggie", "Sea Lord", "Black Sea", "Grass Shampoo", "Landing Aircraft", "Witch Dance", "Sleepless Night", "Angel Care", "Crystal River", "Soft Lipstick", "Salt Mountain", "Perfect White", "Fresh Oasis", "Strict November", "Morning Salad", "Deep Relief", "Sea Strike", "Night Call", "Supreme Sky", "Light Blue", "Mind Crawl", "Lily Meadow", "Sugar Lollipop", "Sweet Dessert", "Magic Ray", "Teen Party", "Frozen Heat", "Gagarin View", "Fabled Sunset", "Perfect Blue"])
151154
}
152155

153156
export default SpinnerButton;

0 commit comments

Comments
 (0)