UNPKG

react-native-animated-radio-button

Version:

Fully customizable animated radio button for React Native

40 lines 1.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const react_native_1 = require("react-native"); const react_native_bounceable_1 = tslib_1.__importDefault(require("@freakycoder/react-native-bounceable")); /** * ? Local Imports */ const RadioButton_style_1 = tslib_1.__importStar(require("./RadioButton.style")); class RadioButton extends React.Component { constructor(props) { super(props); this.handlePress = () => { const { isActive = undefined } = this.props; if (isActive !== undefined && isActive !== null) { this.props.onPress && this.props.onPress(isActive); } else { this.setState({ isActive: !this.state.isActive }, () => { this.props.onPress && this.props.onPress(this.state.isActive); }); } }; this.state = { isActive: props.initial || false, }; } render() { const { style, isActive = undefined, innerContainerStyle, innerBackgroundColor = "red", } = this.props; return (<react_native_bounceable_1.default style={[RadioButton_style_1.default.container, style]} onPress={this.handlePress}> <react_native_1.View style={[ RadioButton_style_1._innerStyle(isActive || this.state.isActive, innerBackgroundColor), innerContainerStyle, ]}/> </react_native_bounceable_1.default>); } } exports.default = RadioButton; //# sourceMappingURL=RadioButton.js.map