/* eslint-disable no-underscore-dangle */
import * as React from 'react';
import Svg, { Path, Defs, Stop, LinearGradient } from 'react-native-svg';
import { View } from 'react-native';
import { withTheme, Badge } from 'react-native-paper';
import svgMap from '../Utils/SvgUtilsNew';
function Icon(props) {
const { name, type, theme, fillAll, Flip, style, badge } = props;
let { color, width, height } = props;
const { colors } = theme;
if (type) {
color = colors[type];
}
if (!width) {
width = 32;
}
if (!height) {
height = 32;
}
const svgInfo = svgMap.get(name);
const viewBox = svgInfo
? svgInfo.viewBox || '0 0 1024 1024'
: '0 0 1024 1024';
const pathList = svgInfo
? svgInfo.pathList || [
{
...svgInfo,
},
]
: [];
let transform = '';
if (Flip) {
transform = `rotate(180 ${(svgInfo.defaultWidth || 1024) / 2} ${
(svgInfo.defaultWidth || 1024) / 2
})`;
}
const pathComList = () => {
return pathList.map((item, index) => {
const pathProps = { ...item };
if ((fillAll || item.changeFill) && color) {
pathProps.fill = color;
}
if (item.strokeWidth && !item.changeFill && color) {
pathProps.stroke = color;
}
delete pathProps.viewBox;
delete pathProps.defaultWidth;
delete pathProps.changeFill;
return ;
});
};
return (
{badge > 0 && (
{badge}
)}
);
}
export default withTheme(Icon);