Skip to content

Commit 02e09c9

Browse files
Merge pull request #22 from SimformSolutionsPvtLtd/feature/disable_color
feat: add gradient disable color.
2 parents 67f739f + 1b63f7a commit 02e09c9

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Don't forget to set the state variable you have given to _isLoading_ prop false
152152
* The flag to identify network connection and based on flag set user iteration. _false_ will render button with disable mode and _true_ will render button with normal mode.
153153
* Default type: boolean
154154
* Default value: _true_
155-
27. **isDisable**
155+
27. **disabled**
156156
* The flag to identify button enable/disable. _true_ will render button with disable mode and _false_ will render button with normal mode.
157157
* Default type: boolean
158158
* Default value: _false_
@@ -166,6 +166,10 @@ Don't forget to set the state variable you have given to _isLoading_ prop false
166166
* Its default value is null | undefined.
167167
* This properties used whenever you want to need gradient but not pass __gradientColors__, __gradientColoroffset__ and __gradientColorAngle__ properties.
168168
* if you want to see color combination of [Sample gradient](https://fx-gradient-previewer.netlify.app/)
169+
30. **disableGradientColors**
170+
* This is how we pass the colors we want to be displayed when button disable, colors can be passed in a different format, name, rgba, hex etc.
171+
* The colors should be ordered the way we want them to be displayed.
172+
* Eg. colors={[ “purple”, “white” ]} the gradient will move from purple to white.
169173
170174
## Example
171175
A full working example project is here [Example](https://github.com/simformsolutions/react-native-spinner-button/tree/master/Example)

components/SpinnerButton.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ const SpinnerButton = ({
4242
isLoading,
4343
isConnected = true,
4444
disabled = false,
45-
disableStyle
45+
disableStyle,
46+
disableGradientColors
4647
}) => {
4748
const isDisable = disabled || !isConnected;
4849
const isAnimationType = animationType !== null && animationType !== undefined;
50+
const gradientColor = isDisable ? (disableGradientColors || gradientColors) : gradientColors;
4951
const style = [styles.defaultButton, styles.centerAlign, buttonStyle, borderStyle, isDisable && disableStyle];
5052
const { height } = getSpinnerStyle(style, styles.defaultButton);
5153
const { handleLayout, animatedStyles, animatedChildHideStyle, animatedChildShowStyle } = useAnimatedValues({
@@ -69,7 +71,7 @@ const SpinnerButton = ({
6971
<ChildrenView
7072
animatedStyles={animatedStyles}
7173
gradientType={gradientType}
72-
gradientColors={gradientColors}
74+
gradientColors={gradientColor}
7375
gradientColoroffset={gradientColoroffset}
7476
gradientColorAngle={gradientColorAngle}
7577
gradientRadialRadius={gradientRadialRadius}
@@ -152,6 +154,7 @@ SpinnerButton.propTypes = {
152154
isLoading: PropTypes.bool,
153155
isConnected: PropTypes.bool,
154156
disableStyle: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
157+
disableGradientColors: PropTypes.array,
155158
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"])
156159
}
157160

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-spinner-button",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "This is a react-native button component with a spinner. You can load a spinner or a button from the same component depending on a flag. for eg, you have a button. And on press of that button you are doing something and wants the user to show a spinner, all you have to do is use this component. You can pass along a boolean flag. The component will render a spinner if the flag is true and button if the flag is false.",
55
"author": "Rupal Patel <[email protected]>",
66
"main": "index.js",

0 commit comments

Comments
 (0)