Skip to content

Commit 730c695

Browse files
Merge pull request #54 from SimformSolutionsPvtLtd/feature/UNT-T23127_Ripple_With_Animated
feat: UNT-T23127: Ripple Button With Animated API
2 parents 4549bf5 + b5dd7ee commit 730c695

File tree

20 files changed

+329
-14
lines changed

20 files changed

+329
-14
lines changed

README.md

Lines changed: 69 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
# react-native-spinner-button [![npm version](https://badge.fury.io/js/react-native-spinner-button.svg)](https://badge.fury.io/js/react-native-spinner-button) [![Android](https://img.shields.io/badge/Platform-Android-green?logo=android)](https://www.android.com) [![iOS](https://img.shields.io/badge/Platform-iOS-green?logo=apple)](https://developer.apple.com/ios) [![MIT](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
2-
This is a pure javascript and react-native Button component with a Spinner embeded in it.
3-
In many of the react-native projects we have worked on required the button to be disabled when app is processing something on tap of that button, and a loading indicator on it or beside it, so the user can be made aware of app doing some processing.
4-
5-
From a developer perspective, it is very painful to manage two different components: a button and a spinner for lots of buttons! So when we came accross this beautiful component [SSspinnerButton](https://github.com/simformsolutions/SSSpinnerButton), we decided to do something like that in react-native.
1+
![Tree-Selection](./assets/react-native-spinner-button.png)
62

7-
By default it will render a Button and you have to pass a boolean _isLoading_ prop to it. When the _isLoading_ will be true, it will render a Spinner in place of the Button and once its false, the Button will be rendered back again.
3+
# react-native-spinner-button [![npm version](https://badge.fury.io/js/react-native-spinner-button.svg)](https://badge.fury.io/js/react-native-spinner-button) [![Android](https://img.shields.io/badge/Platform-Android-green?logo=android)](https://www.android.com) [![iOS](https://img.shields.io/badge/Platform-iOS-green?logo=apple)](https://developer.apple.com/ios) [![MIT](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT)
4+
React Native Spinner Button component library provides dynamic spinner buttons and ripple effects, enriching the user experience with smooth animations and intuitive feedback
5+
6+
Library is compatible with both Android and iOS platforms, offering a versatile solution to elevate your app's user interface with ease.
87

98
## 🎬 Preview
109

1110
![Example of react-native-spinner-button](./assets/example.gif)
1211

1312
## Quick Access
1413

15-
- [Installation](#installation) | [Usage and Examples](#usage) | [Properties](#properties) | [Example Code](#example) | [License](#license)
14+
[Installation](#installation) | [Usage and Examples](#usage) | [Properties](#properties) | [Example Code](#example) | [License](#license)
1615

1716
## Getting Started
1817

@@ -68,7 +67,8 @@ const App: React.FC = () => {
6867
onPress={() => {
6968
handleButtonPress();
7069
}}
71-
indicatorCount={10}>
70+
indicatorCount={10}
71+
>
7272
<Text style={styles.buttonText}>Default Or Ball SpinnerButton</Text>
7373
</SpinnerButton>
7474
</View>
@@ -96,13 +96,63 @@ const styles = StyleSheet.create({
9696
});
9797
```
9898

99+
100+
Example of Ripple Effect Button
101+
102+
```jsx
103+
import React from 'react';
104+
import {StyleSheet, Text, View} from 'react-native';
105+
import {Button} from 'react-native-spinner-button';
106+
107+
const App: React.FC = () => {
108+
const buttonPress: () => void = () => {
109+
console.log('Button Clicked');
110+
};
111+
112+
return (
113+
<View style={styles.screen}>
114+
<Button
115+
animationType="ripple-effect"
116+
onPress={buttonPress}
117+
style={styles.btnStyle}
118+
animatedDuration={400}>
119+
<Text style={styles.textStyle}>RippleButton</Text>
120+
</Button>
121+
</View>
122+
);
123+
};
124+
125+
const styles = StyleSheet.create({
126+
screen: {
127+
flex: 1,
128+
justifyContent: 'center',
129+
},
130+
btnStyle: {
131+
margin: 10,
132+
backgroundColor: '#893346',
133+
},
134+
textStyle: {
135+
fontSize: 20,
136+
textAlign: 'center',
137+
color: 'white',
138+
},
139+
});
140+
141+
export default App;
142+
```
143+
144+
99145
#### 🎬 Preview
100146

101-
## ![Default Modal](./assets/exampleDemo.gif)
147+
| Spinner Button | Ripple Button |
148+
| :-------: | :-----:|
149+
| ![alt Default](./assets/exampleDemo1.gif) | ![alt Modal](./assets/exampleDemo2.gif) |
102150

103151

104152
## Properties
105153

154+
Props for Spinner Button
155+
106156
| Props | Default | Type | Description |
107157
| :-------------------- | :-----: | :---------------------: | :--------------------------------------------------------------------------------------------------- |
108158
| **onPress** | - | function | The function to execute on tap of the button |
@@ -137,6 +187,16 @@ const styles = StyleSheet.create({
137187
| disableGradientColors | - | array | Colors can be passed in a different format name, rgba, hex etc. The colors should be ordered the way we want them to be displayed. Eg. colors={[ “purple”, “white” ]} the gradient will move from purple to white |
138188

139189

190+
Props for Button
191+
192+
| Props | Default | Type | Description |
193+
| :-------------------- | :-----: | :---------------------: | :--------------------------------------------------------------------------------------------------- |
194+
| **onPress** | - | function | The function to execute on tap of the button |
195+
| style | - | object | Styling for button container |
196+
| animatedDuration | 500 | number | Duration of ripple animation effect |
197+
| rippleColor | rgba(255, 255, 255, .25) | string | Color of ripple animation effect
198+
| animationType | ripple-effect | string | Type of the Animation (ripple-effect)
199+
140200
## Example
141201
A full working example project is here [Example](./Example/App/App.tsx)
142202

assets/example.gif

-747 KB
Loading

assets/exampleDemo.gif

-60.7 KB
Binary file not shown.

assets/exampleDemo1.gif

84.5 KB
Loading

assets/exampleDemo2.gif

25.3 KB
Loading
1.78 MB
Loading

example/App/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import PulseSpinnerButton from './PulseSpinnerButton';
1010
import SkypeSpinnerButton from './SkypeSpinnerButton';
1111
import UIActivitySpinnerButton from './UIActivitySpinnerButton';
1212
import WaveSpinnerButton from './WaveSpinnerButton';
13+
import CustomButton from './CustomButton';
1314

1415
const App: React.FC = () => {
1516
return (
@@ -23,6 +24,7 @@ const App: React.FC = () => {
2324
<SkypeSpinnerButton />
2425
<UIActivitySpinnerButton />
2526
<WaveSpinnerButton />
27+
<CustomButton />
2628
</ScrollView>
2729
);
2830
};

example/App/CustomButton.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import {StyleSheet, Text} from 'react-native';
3+
import {Button} from 'react-native-spinner-button';
4+
5+
const CustomButton: React.FC = () => {
6+
const buttonPress: () => void = () => {
7+
console.log('Button Clicked');
8+
};
9+
10+
return (
11+
<Button
12+
animationType="ripple-effect"
13+
onPress={buttonPress}
14+
style={style.btnStyle}>
15+
<Text style={style.textStyle}>RippleButton</Text>
16+
</Button>
17+
);
18+
};
19+
20+
const style = StyleSheet.create({
21+
btnStyle: {
22+
margin: 5,
23+
},
24+
textStyle: {
25+
fontSize: 20,
26+
textAlign: 'center',
27+
color: 'white',
28+
},
29+
});
30+
31+
export default CustomButton;

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-spinner-button",
3-
"version": "1.0.9",
4-
"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.",
3+
"version": "1.4.1",
4+
"description": "React Native Spinner Button component library",
55
"author": "Simform Solutions",
66
"main": "lib/index",
77
"types": "lib/index.d.ts",
@@ -18,7 +18,9 @@
1818
},
1919
"peerDependencies": {
2020
"react": "*",
21-
"react-native": "*"
21+
"react-native": "*",
22+
"react-native-svg": "*",
23+
"react-native-gradients": "*"
2224
},
2325
"repository": {
2426
"type": "git",

src/components/AnimatedView/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ViewStyle, Animated } from 'react-native';
22
import type { CommonViewProps } from '../../components';
33

4-
type AnimatedStyle = Animated.WithAnimatedValue<ViewStyle>;
4+
export type AnimatedStyle = Animated.WithAnimatedValue<ViewStyle>;
55

66
export type AnimatedViewProps = CommonViewProps & {
77
animatedChildHideStyle?: AnimatedStyle;

0 commit comments

Comments
 (0)