import React, { FC, isValidElement } from 'react'; import { TouchableOpacity, View, Text, StyleSheet, TouchableWithoutFeedback, } from 'react-native'; import { useTheme } from '../Theme/Theme'; import { UploadBtnProps } from './interface'; import createStyle from './style'; import { IconXAdd1, IconXBackside1, IconXUpload2, } from '../../icons'; import { UploadListTypes } from './enum'; import { useLocale } from '../Locale/locale'; import Button from '../Button'; import { Fill } from '../Button/enum'; const UploadButton: FC = ({ renderBtn, style, onPress, tip, tipStyle, tipIcon, contentStyle, isCredentials = false, disabled, onDisabledPress, listType, subTip, subTipStyle, status, }) => { const token = useTheme(); const styles = createStyle(token); const isTextListType = listType === UploadListTypes.Text; const { Uploader } = useLocale(); const iconColor = disabled ? token['--color-text-2'] : token['--color-text-5']; const defaultIcon = !isCredentials ? ( ) : ( ); const tipIconFinal = tipIcon || (isTextListType && ) || defaultIcon; const defaultTip = isTextListType ? Uploader.upload : ''; const tipFinal = tip || defaultTip; const isError = status === 'error'; const renderText = () => isTextListType ? ( ) : ( {tipFinal} ); const renderContent = ( {renderBtn ? ( renderBtn ) : ( {tipIconFinal} {!!tipFinal && ( {isValidElement(tipFinal) ? tipFinal : renderText()} {isTextListType && subTip && (isValidElement(subTip) ? ( subTip ) : ( {subTip} ))} )} )} ); return disabled ? ( {renderContent} ) : ( {renderContent} ); }; export default UploadButton;