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 * as React from 'react';
import { StyleSheet } from 'react-native';
import TouchableRipple from '../TouchableRipple/TouchableRipple.native';
import Icon from '../Icon';
import { withTheme } from '../../core/theming';
import { getIconButtonColor } from './utils';
import Surface from '../Surface';
const PADDING = 12;
const IconButton = _ref => {
  let {
    icon,
    iconColor: customIconColor,
    containerColor: customContainerColor,
    size = 24,
    accessibilityLabel,
    disabled,
    onPress,
    selected = false,
    animated = false,
    mode,
    theme,
    style,
    ...rest
  } = _ref;
  const IconComponent = Icon; //if animatd pick a diff one - like CrossFade

  const {
    iconColor,
    rippleColor,
    backgroundColor,
    borderColor
  } = getIconButtonColor({
    theme,
    disabled,
    selected,
    mode,
    customIconColor,
    customContainerColor
  });
  const buttonSize = size + 2 * PADDING;
  const borderStyles = {
    // borderRadius: buttonSize / 2,
    borderRadius: 12,
    borderColor
  };
  return /*#__PURE__*/React.createElement(Surface, {
    style: [{
      backgroundColor,
      width: buttonSize,
      height: buttonSize
    }, styles.container, borderStyles, disabled && styles.disabled, style],
    elevation: 0
  }, /*#__PURE__*/React.createElement(TouchableRipple, _extends({
    borderless: true,
    centered: true,
    onPress: onPress,
    rippleColor: rippleColor,
    accessibilityLabel: accessibilityLabel,
    style: styles.touchable
    // @ts-expect-error We keep old a11y props for backwards compat with old RN versions
    ,
    accessibilityTraits: disabled ? ['button', 'disabled'] : 'button',
    accessibilityComponentType: "button",
    accessibilityRole: "button",
    accessibilityState: {
      disabled
    },
    disabled: disabled,
    hitSlop: TouchableRipple.supported ? {
      top: 10,
      left: 10,
      bottom: 10,
      right: 10
    } : {
      top: 6,
      left: 6,
      bottom: 6,
      right: 6
    }
  }, rest), /*#__PURE__*/React.createElement(IconComponent, {
    color: iconColor,
    source: icon,
    size: size
  })));
};
const styles = StyleSheet.create({
  container: {
    overflow: 'hidden',
    margin: 6,
    elevation: 0
  },
  touchable: {
    flexGrow: 1,
    justifyContent: 'center',
    alignItems: 'center'
  },
  disabled: {
    opacity: 0.32
  }
});
export default withTheme(IconButton);
//# sourceMappingURL=IconButton.js.map