Skip to content

Commit 24e21cf

Browse files
Feat: Support height and width dynamic.
1 parent 4032595 commit 24e21cf

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

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.5",
22+
"react-native-spinner-button": "^1.0.7",
2323
"react-native-svg": "^12.1.0"
2424
},
2525
"devDependencies": {

components/SpinnerButton.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const AnimatedTouchablesOpacity = Animated.createAnimatedComponent(
1313

1414
const SpinnerButton = ({
1515
animationType,
16+
buttonContainer,
1617
buttonStyle,
1718
borderStyle,
1819
spinnerColor,
@@ -57,7 +58,7 @@ const SpinnerButton = ({
5758
});
5859

5960
return (
60-
<View style={[styles.buttonContainer, styles.centerAlign]}>
61+
<View style={[styles.buttonContainer, styles.centerAlign, buttonContainer]}>
6162
<AnimatedTouchablesOpacity
6263
activeOpacity={1}
6364
style={[style, animatedStyles]}
@@ -119,6 +120,7 @@ const SpinnerButton = ({
119120

120121
SpinnerButton.propTypes = {
121122
animationType: PropTypes.string,
123+
buttonContainer: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
122124
buttonStyle: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
123125
borderStyle: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
124126
spinnerColor: PropTypes.string,

components/utils/useAnimatedValues.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const useAnimatedValues = ({
1313
const [size, setSize] = useState(null);
1414
const defaultStyle = StyleSheet.flatten(style);
1515
const margin = defaultStyle.margin || defaultStyle.marginLeft || defaultStyle.marginRight || defaultStyle.marginHorizontal || 0;
16-
const defaultWidth = (size?.width || defaulButtonWidth) - (margin * 2);
16+
const defaultWidth = (defaultStyle.width || size?.width || defaulButtonWidth) - (margin * 2);
1717
const defaultRadius = defaultStyle.borderRadius || 0;
18-
const defaultHeight = size?.height || defaulButtonHeight;
18+
const defaultHeight = defaultStyle.height || size?.height || defaulButtonHeight;
1919
const animatedHeight = animateHeight || Math.min(defaultWidth, defaultHeight);
2020
const animatedWidth = animateWidth || Math.min(defaultWidth, defaultHeight);
2121
const animatedRadius = animateRadius || (Math.min(defaultWidth, defaultHeight)/2);

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.5",
3+
"version": "1.0.7",
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)