UNPKG

@tra-tech/react-native-kitra

Version:
51 lines 1.54 kB
import { useState } from 'react'; import { StyleSheet, TouchableOpacity } from 'react-native'; import Animated, { FadeIn, FadeOut } from 'react-native-reanimated'; import { applyDefaults } from '../../core/KitraProvider'; const RadioButton = _ref => { let { theme, onChange, testID, style } = _ref; const [value, setValue] = useState(false); return /*#__PURE__*/React.createElement(TouchableOpacity, { activeOpacity: 0.5, onPress: () => { setValue(prev => !prev); onChange(!value); }, testID: testID, style: [value ? { borderColor: theme === null || theme === void 0 ? void 0 : theme.primary, backgroundColor: theme === null || theme === void 0 ? void 0 : theme.white } : { borderColor: theme === null || theme === void 0 ? void 0 : theme.disabledDark, backgroundColor: theme === null || theme === void 0 ? void 0 : theme.disabledLight }, styles.container, style] }, value && /*#__PURE__*/React.createElement(Animated.View, { entering: FadeIn, exiting: FadeOut, style: [{ backgroundColor: theme === null || theme === void 0 ? void 0 : theme.primary }, styles.innerCircle] })); }; export default applyDefaults(RadioButton); const styles = StyleSheet.create({ container: { height: 20, width: 20, borderWidth: 1, alignItems: 'center', justifyContent: 'center', borderRadius: 10 }, innerCircle: { height: 12, width: 12, borderRadius: 10 } }); //# sourceMappingURL=RadioButton.js.map