Skip to content

Commit 2572943

Browse files
fix: button width change
1 parent e3e7efb commit 2572943

File tree

1 file changed

+214
-31
lines changed

1 file changed

+214
-31
lines changed

components/SpinnerButton.js

Lines changed: 214 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import React from 'react';
2-
import PropTypes from 'prop-types';
3-
import ChildrenView from './ChildrenView';
4-
import styles from './styles/SpinnerButtonStyle';
5-
import AnimatedView from './AnimatedView';
6-
import AnimatableView from './AnimatableView';
7-
import { useAnimatedValues, getSpinnerStyle } from './utils'
8-
import { Animated, View, TouchableOpacity } from 'react-native';
1+
import PropTypes from "prop-types";
2+
import React from "react";
3+
import { Animated, TouchableOpacity, View } from "react-native";
4+
import AnimatableView from "./AnimatableView";
5+
import AnimatedView from "./AnimatedView";
6+
import ChildrenView from "./ChildrenView";
7+
import styles from "./styles/SpinnerButtonStyle";
8+
import { getSpinnerStyle, useAnimatedValues } from "./utils";
99

10-
const AnimatedTouchablesOpacity = Animated.createAnimatedComponent(
11-
TouchableOpacity,
12-
);
10+
const AnimatedTouchablesOpacity =
11+
Animated.createAnimatedComponent(TouchableOpacity);
1312

1413
const SpinnerButton = ({
1514
animationType,
@@ -43,30 +42,45 @@ const SpinnerButton = ({
4342
isConnected = true,
4443
disabled = false,
4544
disableStyle,
46-
disableGradientColors
45+
disableGradientColors,
4746
}) => {
4847
const isDisable = disabled || !isConnected;
4948
const isAnimationType = animationType !== null && animationType !== undefined;
50-
const gradientColor = isDisable ? (disableGradientColors || gradientColors) : gradientColors;
51-
const style = [styles.defaultButton, styles.centerAlign, buttonStyle, borderStyle, isDisable && disableStyle];
49+
const gradientColor = isDisable
50+
? disableGradientColors || gradientColors
51+
: gradientColors;
52+
const style = [
53+
styles.defaultButton,
54+
styles.centerAlign,
55+
buttonStyle,
56+
borderStyle,
57+
isDisable && disableStyle,
58+
];
5259
const { height } = getSpinnerStyle(style, styles.defaultButton);
53-
const { handleLayout, animatedStyles, animatedChildHideStyle, animatedChildShowStyle } = useAnimatedValues({
54-
isLoading,
55-
style,
56-
animatedDuration,
60+
const {
61+
handleLayout,
62+
animatedStyles,
63+
animatedChildHideStyle,
64+
animatedChildShowStyle,
65+
} = useAnimatedValues({
66+
isLoading,
67+
style,
68+
animatedDuration,
5769
animateWidth,
5870
animateHeight,
59-
animateRadius
71+
animateRadius,
6072
});
61-
73+
6274
return (
63-
<View style={[styles.buttonContainer, styles.centerAlign, buttonContainer]}>
75+
<View
76+
style={[styles.buttonContainer, styles.centerAlign, buttonContainer]}
77+
onLayout={handleLayout}
78+
>
6479
<AnimatedTouchablesOpacity
6580
activeOpacity={1}
6681
style={[style, animatedStyles]}
6782
onPress={onPress}
6883
disabled={isDisable || isLoading}
69-
onLayout={handleLayout}
7084
>
7185
<ChildrenView
7286
animatedStyles={animatedStyles}
@@ -83,7 +97,7 @@ const SpinnerButton = ({
8397
gradientName={gradientName}
8498
children={
8599
<>
86-
{isAnimationType &&
100+
{isAnimationType && (
87101
<AnimatableView
88102
animationType={animationType}
89103
children={children}
@@ -97,8 +111,8 @@ const SpinnerButton = ({
97111
indicatorCount={indicatorCount}
98112
spinnerOptions={spinnerOptions}
99113
/>
100-
}
101-
{!isAnimationType &&
114+
)}
115+
{!isAnimationType && (
102116
<AnimatedView
103117
animatedChildHideStyle={animatedChildHideStyle}
104118
animatedChildShowStyle={animatedChildShowStyle}
@@ -111,9 +125,9 @@ const SpinnerButton = ({
111125
indicatorCount={indicatorCount}
112126
spinnerOptions={spinnerOptions}
113127
/>
114-
}
128+
)}
115129
</>
116-
}
130+
}
117131
/>
118132
</AnimatedTouchablesOpacity>
119133
</View>
@@ -133,7 +147,7 @@ SpinnerButton.propTypes = {
133147
size: PropTypes.number,
134148
spinnerOptions: PropTypes.shape({
135149
waveFactor: PropTypes.number,
136-
waveMode: PropTypes.string
150+
waveMode: PropTypes.string,
137151
}),
138152
gradientType: PropTypes.string,
139153
gradientColors: PropTypes.array,
@@ -155,7 +169,176 @@ SpinnerButton.propTypes = {
155169
isConnected: PropTypes.bool,
156170
disableStyle: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
157171
disableGradientColors: PropTypes.array,
158-
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"])
159-
}
172+
gradientName: PropTypes.oneOf([
173+
"Warm Flame",
174+
"Night Fade",
175+
"Spring Warmth",
176+
"Juicy Peach",
177+
"Young Passion",
178+
"Lady Lips",
179+
"Sunny Morning",
180+
"Rainy Ashville",
181+
"Frozen Dreams",
182+
"Winter Neva",
183+
"Dusty Grass",
184+
"Tempting Azure",
185+
"Heavy Rain",
186+
"Amy Crisp",
187+
"Mean Fruit",
188+
"Deep Blue",
189+
"Ripe Malinka",
190+
"Cloudy Knoxville",
191+
"Malibu Beach",
192+
"New Life",
193+
"True Sunset",
194+
"Morpheus Den",
195+
"Rare Wind",
196+
"Near Moon",
197+
"Wild Apple",
198+
"Saint Petersburg",
199+
"Plum Plate",
200+
"Everlasting Sky",
201+
"Happy Fisher",
202+
"Blessing",
203+
"Sharpeye Eagle",
204+
"Ladoga Bottom",
205+
"Lemon Gate",
206+
"Itmeo Branding",
207+
"Zeus Miracle",
208+
"Old Hat",
209+
"Star Wine",
210+
"Happy Acid",
211+
"Awesome Pine",
212+
"New York",
213+
"Shy Rainbow",
214+
"Mixed Hopes",
215+
"Fly High",
216+
"Strong Bliss",
217+
"Fresh Milk",
218+
"Snow Again",
219+
"February Ink",
220+
"Kind Steel",
221+
"Soft Grass",
222+
"Grown Early",
223+
"Sharp Blues",
224+
"Shady Water",
225+
"Dirty Beauty",
226+
"Great Whale",
227+
"Teen Notebook",
228+
"Polite Rumors",
229+
"Sweet Period",
230+
"Wide Matrix",
231+
"Soft Cherish",
232+
"Red Salvation",
233+
"Burning Spring",
234+
"Night Party",
235+
"Sky Glider",
236+
"Heaven Peach",
237+
"Purple Division",
238+
"Aqua Splash",
239+
"Spiky Naga",
240+
"Love Kiss",
241+
"Clean Mirror",
242+
"Premium Dark",
243+
"Cold Evening",
244+
"Cochiti Lake",
245+
"Summer Games",
246+
"Passionate Bed",
247+
"Mountain Rock",
248+
"Desert Hump",
249+
"Jungle Day",
250+
"Phoenix Start",
251+
"October Silence",
252+
"Faraway River",
253+
"Alchemist Lab",
254+
"Over Sun",
255+
"Premium White",
256+
"Mars Party",
257+
"Eternal Constance",
258+
"Japan Blush",
259+
"Smiling Rain",
260+
"Cloudy Apple",
261+
"Big Mango",
262+
"Healthy Water",
263+
"Amour Amour",
264+
"Risky Concrete",
265+
"Strong Stick",
266+
"Vicious Stance",
267+
"Palo Alto",
268+
"Happy Memories",
269+
"Midnight Bloom",
270+
"Crystalline",
271+
"Party Bliss",
272+
"Confident Cloud",
273+
"Le Cocktail",
274+
"River City",
275+
"Frozen Berry",
276+
"Child Care",
277+
"Flying Lemon",
278+
"New Retrowave",
279+
"Hidden Jaguar",
280+
"Above The Sky",
281+
"Nega",
282+
"Dense Water",
283+
"Seashore",
284+
"Marble Wall",
285+
"Cheerful Caramel",
286+
"Night Sky",
287+
"Magic Lake",
288+
"Young Grass",
289+
"Colorful Peach",
290+
"Gentle Care",
291+
"Plum Bath",
292+
"Happy Unicorn",
293+
"African Field",
294+
"Solid Stone",
295+
"Orange Juice",
296+
"Glass Water",
297+
"North Miracle",
298+
"Fruit Blend",
299+
"Millennium Pine",
300+
"High Flight",
301+
"Mole Hall",
302+
"Space Shift",
303+
"Forest Inei",
304+
"Royal Garden",
305+
"Rich Metal",
306+
"Juicy Cake",
307+
"Smart Indigo",
308+
"Sand Strike",
309+
"Norse Beauty",
310+
"Aqua Guidance",
311+
"Sun Veggie",
312+
"Sea Lord",
313+
"Black Sea",
314+
"Grass Shampoo",
315+
"Landing Aircraft",
316+
"Witch Dance",
317+
"Sleepless Night",
318+
"Angel Care",
319+
"Crystal River",
320+
"Soft Lipstick",
321+
"Salt Mountain",
322+
"Perfect White",
323+
"Fresh Oasis",
324+
"Strict November",
325+
"Morning Salad",
326+
"Deep Relief",
327+
"Sea Strike",
328+
"Night Call",
329+
"Supreme Sky",
330+
"Light Blue",
331+
"Mind Crawl",
332+
"Lily Meadow",
333+
"Sugar Lollipop",
334+
"Sweet Dessert",
335+
"Magic Ray",
336+
"Teen Party",
337+
"Frozen Heat",
338+
"Gagarin View",
339+
"Fabled Sunset",
340+
"Perfect Blue",
341+
]),
342+
};
160343

161-
export default SpinnerButton;
344+
export default SpinnerButton;

0 commit comments

Comments
 (0)