|
1 | | -# react-native-spinner-button [](https://badge.fury.io/js/react-native-spinner-button) [](https://www.android.com) [](https://developer.apple.com/ios) [](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 | + |
6 | 2 |
|
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 [](https://badge.fury.io/js/react-native-spinner-button) [](https://www.android.com) [](https://developer.apple.com/ios) [](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. |
8 | 7 |
|
9 | 8 | ## 🎬 Preview |
10 | 9 |
|
11 | 10 |  |
12 | 11 |
|
13 | 12 | ## Quick Access |
14 | 13 |
|
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) |
16 | 15 |
|
17 | 16 | ## Getting Started |
18 | 17 |
|
@@ -68,7 +67,8 @@ const App: React.FC = () => { |
68 | 67 | onPress={() => { |
69 | 68 | handleButtonPress(); |
70 | 69 | }} |
71 | | - indicatorCount={10}> |
| 70 | + indicatorCount={10} |
| 71 | + > |
72 | 72 | <Text style={styles.buttonText}>Default Or Ball SpinnerButton</Text> |
73 | 73 | </SpinnerButton> |
74 | 74 | </View> |
@@ -96,13 +96,63 @@ const styles = StyleSheet.create({ |
96 | 96 | }); |
97 | 97 | ``` |
98 | 98 |
|
| 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 | + |
99 | 145 | #### 🎬 Preview |
100 | 146 |
|
101 | | -##  |
| 147 | +| Spinner Button | Ripple Button | |
| 148 | +| :-------: | :-----:| |
| 149 | +|  |  | |
102 | 150 |
|
103 | 151 |
|
104 | 152 | ## Properties |
105 | 153 |
|
| 154 | +Props for Spinner Button |
| 155 | + |
106 | 156 | | Props | Default | Type | Description | |
107 | 157 | | :-------------------- | :-----: | :---------------------: | :--------------------------------------------------------------------------------------------------- | |
108 | 158 | | **onPress** | - | function | The function to execute on tap of the button | |
@@ -137,6 +187,16 @@ const styles = StyleSheet.create({ |
137 | 187 | | 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 | |
138 | 188 |
|
139 | 189 |
|
| 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 | + |
140 | 200 | ## Example |
141 | 201 | A full working example project is here [Example](./Example/App/App.tsx) |
142 | 202 |
|
|
0 commit comments