import React from 'react'
import { Text } from 'react-native'

import CoreButton from '../../core/CoreButton/CoreButton'

import type { ButtonProps } from './Button.types'
import defaultButtonPreset from './styles'

const Button: React.FC<ButtonProps> = ({ label, disabled, stylePreset = defaultButtonPreset, onPress, leftSlot, rightSlot }) => {
  const buttonStyle = [stylePreset.button.style, disabled ? stylePreset.button.disabledStyle : null]
  const labelStyle = [stylePreset.label.style, disabled ? stylePreset.label.disabledStyle : null]

  return (
    <CoreButton
      onPress={onPress}
      disabled={disabled}
      touchType={stylePreset.button.touchType}
      activeOpacity={stylePreset.button.activeOpacity}
      underlayColor={stylePreset.button.underlayColor}
      style={buttonStyle}
    >
      {leftSlot}

      <Text style={labelStyle}>
        {label}
      </Text>

      {rightSlot}
    </CoreButton>
  )
}

export default Button

