import React, { type ReactNode } from 'react'; import { ActivityIndicator, TouchableOpacity, View, type StyleProp, type TextStyle, type ViewStyle, } from 'react-native'; import { globalStyles } from '../styles/globalStyles'; import Text from './Text'; interface Props { title?: string; icon?: ReactNode; outline?: boolean; color?: string; styles?: StyleProp; onPress: () => void; type?: 'primary' | 'text' | 'link' | 'dashed'; textStyleProps?: StyleProp; size?: 'large' | 'default' | 'small'; onLongPress?: () => void; inline?: boolean; isShadow?: boolean; iconPosition?: 'left' | 'right'; textLine?: number; iconExtra?: boolean; loading?: boolean; disable?: boolean; radius?: number; } const Button = (props: Props) => { const { title, icon, outline, color, styles, onPress, type, textStyleProps, size, onLongPress, inline, isShadow, iconPosition, textLine, iconExtra, disable, loading, radius, } = props; const localstyles: StyleProp = loading || disable ? { backgroundColor: '#e0e0e0', paddingVertical: size === 'large' ? 14 : size === 'small' ? 6 : 12, borderRadius: radius ?? 100, } : type === 'text' || type === 'link' ? {} : { paddingVertical: size === 'large' ? 14 : size === 'small' ? 6 : 12, paddingHorizontal: size === 'large' ? 30 : size === 'small' ? 12 : 20, backgroundColor: outline ? 'white' : color ? color : type === 'primary' ? '#0d6efd' : 'white', borderWidth: 1, borderColor: outline ? color ? color : '#0d6efd' : type === 'primary' ? '#0d6efd' : color ? color : '#e0e0e0', borderStyle: type === 'dashed' ? 'dashed' : 'solid', borderRadius: radius ?? 100, minHeight: size === 'small' ? 38 : 42, }; return ( {loading ? ( ) : ( <> {icon && (iconPosition === 'left' || !iconPosition) && icon} {title && ( )} {icon && iconPosition === 'right' && icon} )} ); }; export default Button;