import React from 'react'; import { Button as RNEButton, ButtonProps as RNEButtonProps, } from 'react-native-elements'; import {GestureResponderEvent, StyleProp, ViewStyle} from 'react-native'; import {Text} from './Text'; import {Theme, Spacing} from './styleUtils'; import testIDProps from '../../shared/commonUtil'; export const Button: React.FC = props => { const type = props.type || 'solid' || 'radius' || 'gradient' || 'clearAddIdBtnBg'; const buttonStyle: StyleProp = [ props.fill ? Theme.ButtonStyles.fill : null, Theme.ButtonStyles[type], {width: props.width ?? '100%'}, ]; const containerStyle: StyleProp = [ !(type === 'gradient') ? Theme.ButtonStyles.container : null, props.disabled ? Theme.ButtonStyles.disabled : null, props.margin ? Theme.spacing('margin', props.margin) : null, type === 'gradient' ? props.isVcThere ? Theme.ButtonStyles.float : Theme.ButtonStyles.gradient : null, props.styles, ]; const handleOnPress = (event: GestureResponderEvent) => { if (!props.disabled && props.onPress) { props.onPress(event); } }; return !(type === 'gradient') ? ( {props.title} } style={[buttonStyle]} icon={props.icon} onPress={handleOnPress} loading={props.loading} /> ) : ( {props.title} } style={[buttonStyle]} icon={props.icon} onPress={handleOnPress} loading={props.loading} /> ); }; interface ButtonProps { testID?: string; title: string; disabled?: boolean; margin?: Spacing; type?: RNEButtonProps['type'] | 'gradient'; isVcThere?: boolean; onPress?: RNEButtonProps['onPress']; fill?: boolean; raised?: boolean; loading?: boolean; icon?: RNEButtonProps['icon']; styles?: StyleProp; colors?: (string | number)[]; width?: number; }