import React, { FC, useRef } from 'react'; import { View, TouchableWithoutFeedback, StyleSheet, Text, Animated, Platform } from 'react-native'; import type { TextStyle } from 'react-native'; import Icon from '@pingtou/rn-vant-icons'; import { useUpdateEffect } from '../hooks'; import { useThemeFactory } from '../Theme'; import type { TagProps } from './interface'; import createStyle from './style'; const Tag: FC = props => { const { onPress, children, style, innerStyle, textStyle, color, show = true, textColor = '#fff', mark = false, plain = false, round = false, size = 'mini', type = 'default', closeable = false, onClose, hairline = false, } = props; const { styles } = useThemeFactory(createStyle, { color, textColor, plain, round, size, type, hairline, }); const fadeAnim = useRef(new Animated.Value(show ? 1 : 0)).current; useUpdateEffect(() => { Animated.timing(fadeAnim, { toValue: show ? 1 : 0, duration: 300, useNativeDriver: Platform.OS !== 'web', }).start(); }, [show]); const textStyleSummary: TextStyle = StyleSheet.flatten([styles.text, textStyle]); return ( {children} {closeable ? ( ) : null} ); }; export default Tag;