// 这个组件只用来渲染多色SVG
import React from 'react';
import {Platform, Image, ImageRequireSource, StyleSheet, View} from 'react-native';

interface SvgImageProps {
    uri: ImageRequireSource;
    size?: number;
    color?: string;
    style?: any;
    highlight?: boolean;
}
const SVGImg: React.FC<SvgImageProps> = ({uri, highlight, color, style, size, ...ext}) => {
    const ImgSize = size || style?.fontSize || 24;
    const styles = React.useMemo(
        () =>
            StyleSheet.create({
                iconStyle: {
                    width: ImgSize,
                    height: ImgSize,
                },
            }),
        [ImgSize],
    );
    const SVG = uri as any;
    return (
        <View style={[styles.iconStyle, {position: 'relative'}]}>
            {Platform.OS === 'web' ? (
                <Image source={SVG} style={[styles.iconStyle, style]} height={ImgSize} width={ImgSize} {...ext} />
            ) : (
                <SVG style={styles.iconStyle} size={ImgSize} {...ext} />
            )}
        </View>
    );
};

export default SVGImg;
