import React, {useContext} from 'react'; import { TouchableOpacity, Image, StyleProp, TouchableOpacityProps, ViewStyle, Text, View, Platform, } from 'react-native'; import PropsContext, {IconsInterface} from '../Contexts/PropsContext'; import styles from '../Style'; import icons from './Icons'; import useImageDelay from '../hooks/useImageDelay'; import {Either} from './types'; interface BtnTemplateBasicInterface { color?: string; onPress?: TouchableOpacityProps['onPress']; style?: StyleProp; btnText?: string; disabled?: boolean; } interface BtnTemplateInterfaceWithName extends BtnTemplateBasicInterface { name?: keyof IconsInterface; } interface BtnTemplateInterfaceWithIcon extends BtnTemplateBasicInterface { icon?: any; } type BtnTemplateInterface = Either< BtnTemplateInterfaceWithIcon, BtnTemplateInterfaceWithName >; const BtnTemplate: React.FC = (props) => { const {disabled = false} = props; const {styleProps} = useContext(PropsContext); const {BtnTemplateStyles, theme, iconSize, customIcon} = styleProps || {}; const imageRef = React.useRef(null); // This fixes the tint issue in safari browser useImageDelay(imageRef, 10, '', props?.color || ''); return ( {props.btnText} ); }; export default BtnTemplate;