UNPKG

@tra-tech/react-native-kitra

Version:
73 lines 2.31 kB
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import { Pressable, Platform } from 'react-native'; import { applyDefaults } from '../../core/KitraProvider'; import Icon from '../Icons/Icon'; const IconButton = _ref => { let { theme, icon = { name: 'camera', size: 20, type: 'material-community' }, containerColor = theme === null || theme === void 0 ? void 0 : theme.primary, style, iconColor = theme === null || theme === void 0 ? void 0 : theme.error, focusedColor, ...props } = _ref; const statusStyles = { default: { container: { backgroundColor: theme === null || theme === void 0 ? void 0 : theme.primary }, iconColor: { color: theme === null || theme === void 0 ? void 0 : theme.white } }, focused: { container: { backgroundColor: theme === null || theme === void 0 ? void 0 : theme.focused } }, disabled: { container: { backgroundColor: theme === null || theme === void 0 ? void 0 : theme.disabledLight, opacity: 0.3 } } }; const scale = { default: { borderRadius: 50, width: 30, height: 30 } }; return /*#__PURE__*/React.createElement(Pressable, _extends({ android_ripple: { color: statusStyles.focused.container.backgroundColor }, style: _ref2 => { let { pressed } = _ref2; return [{ alignItems: 'center', justifyContent: 'center' }, Platform.OS === 'ios' ? pressed ? { backgroundColor: focusedColor } : { backgroundColor: containerColor } : statusStyles.default.container, props.disabled ? statusStyles.disabled.container : null, scale.default, style]; } }, props), /*#__PURE__*/React.createElement(Icon, { type: icon.type, name: icon.name, size: icon.size, color: iconColor })); }; export default applyDefaults(IconButton); //# sourceMappingURL=IconButton.js.map