Skip to content

Commit d07be40

Browse files
committed
DisableBuiltinStateManagement feature is added
1 parent 6fda451 commit d07be40

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

README.md

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<img alt="React Native Animated Radio Button" src="assets/logo.png" width="1050"/>
22

3-
43
[![Battle Tested ✅](https://img.shields.io/badge/-Battle--Tested%20%E2%9C%85-03666e?style=for-the-badge)](https://github.com/WrathChaos/react-native-animated-radio-button)
54

6-
75
[![Fully customizable animated radio button for React Native](https://img.shields.io/badge/-Fully%20customizable%20animated%20radio%20button%20for%20React%20Native-lightgrey?style=for-the-badge)](https://github.com/WrathChaos/react-native-animated-radio-button)
86

9-
107
[![npm version](https://img.shields.io/npm/v/react-native-animated-radio-button.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-animated-radio-button)
118
[![npm](https://img.shields.io/npm/dt/react-native-animated-radio-button.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-animated-radio-button)
129
![Platform - Android and iOS](https://img.shields.io/badge/platform-Android%20%7C%20iOS-blue.svg?style=for-the-badge)
@@ -59,15 +56,16 @@ You can check the example out 😏
5956

6057
# Configuration - Props
6158

62-
| Property | Type | Default | Description |
63-
| ------------ | :------: | :--------: | ----------------------------------------------- |
64-
| size | number | 16 | change the size of the radio button |
65-
| isSelected | boolean | false | set the selectable of the radio button |
66-
| isBounceable | boolean | true | enable or disable the bounceable effect |
67-
| innerColor | color | dodgerblue | change the radio button's inner circle color |
68-
| outerColor | color | dodgerblue | change the radio button's outer circle color |
69-
| onPress | function | () | set your own function when onPress is triggered |
70-
59+
| Property | Type | Default | Description |
60+
| ----------------------------- | :------: | :--------: | -------------------------------------------------------------------------------------------------------------------------------------- |
61+
| size | number | 16 | change the size of the radio button |
62+
| isSelected | boolean | false | set the selectable of the radio button |
63+
| isBounceable | boolean | true | enable or disable the bounceable effect |
64+
| innerColor | color | dodgerblue | change the radio button's inner circle color |
65+
| outerColor | color | dodgerblue | change the radio button's outer circle color |
66+
| onPress | function | () | set your own function when onPress is triggered |
67+
| disableBuiltinStateManagement | bool | false | disable the builtin state management to let your state management for the radio button |
68+
| active | bool | false | you can use this prop to set the radio button is active or not, this **ONLY works** when **built-in** state management is **disabled** |
7169

7270
## Credits
7371

@@ -81,7 +79,6 @@ The library itself also has a bouncy animation when onPress is triggered.
8179
- [ ] Left, right, bottom text component as optional
8280
- [ ] Write an article about the lib on Medium
8381

84-
8582
## Author
8683

8784
FreakyCoder, kurayogun@gmail.com

lib/src/RadioButton.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class RadioButton extends Component {
2222
this.setState({ _isSelected: !_isSelected });
2323
const { isBounceable, onPress } = this.props;
2424
if (isBounceable) this.spring(Easing.bounce);
25+
this.props.onChange && this.props.onChange(item);
2526
if (onPress) onPress();
2627
};
2728

@@ -35,10 +36,19 @@ export default class RadioButton extends Component {
3536
};
3637

3738
render() {
38-
const { size, innerColor, outerColor } = this.props;
39-
39+
const {
40+
size,
41+
innerColor,
42+
outerColor,
43+
disableBuiltinStateManagement,
44+
active
45+
} = this.props;
4046
const { springValue, _isSelected } = this.state;
4147

48+
let stateManagement = _isSelected;
49+
if (disableBuiltinStateManagement) stateManagement = active;
50+
else _isSelected;
51+
4252
return (
4353
<TouchableOpacity onPress={this.handleOnPress}>
4454
<Animated.View
@@ -48,7 +58,7 @@ export default class RadioButton extends Component {
4858
styles.center
4959
]}
5060
>
51-
{_isSelected ? (
61+
{stateManagement ? (
5262
<View style={innerStyle(size, innerColor)} {...this.props} />
5363
) : null}
5464
</Animated.View>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-animated-radio-button",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Fully customizable animated radio button for React Native",
55
"keywords": [
66
"bouncy",

0 commit comments

Comments
 (0)