|
|
@@ -1,18 +1,41 @@
|
|
|
import * as React from 'react'
|
|
|
import { svg, path } from 'react-native-svg'
|
|
|
import { withTheme } from 'react-native-paper'
|
|
|
-import names from '../Utils/SvgUtils'
|
|
|
+import svgMap from '../Utils/SvgUtilsNew'
|
|
|
|
|
|
function Icon(props) {
|
|
|
- const { name, width, height, type, theme } = props
|
|
|
+ const { name, width, height, type, theme, fillAll } = props
|
|
|
let { color } = props
|
|
|
const { colors } = theme
|
|
|
if (type) {
|
|
|
color = colors[type]
|
|
|
}
|
|
|
+ const svgInfo = svgMap.get(name)
|
|
|
+ const viewBox = svgInfo ? svgInfo.viewBox || '0 0 1024 1024' : '0 0 1024 1024'
|
|
|
+ const pathList = svgInfo
|
|
|
+ ? svgInfo.pathList || [
|
|
|
+ {
|
|
|
+ ...svgInfo,
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ : []
|
|
|
+ const pathComList = () => {
|
|
|
+ return pathList.map((item, index) => {
|
|
|
+ const pathProps = { ...item }
|
|
|
+ if (fillAll || !item.fillRule) {
|
|
|
+ pathProps.fill = color
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.fillRule) {
|
|
|
+ pathProps.stroke = color
|
|
|
+ }
|
|
|
+ delete pathProps.viewBox
|
|
|
+ return <path {...pathProps} key={index} />
|
|
|
+ })
|
|
|
+ }
|
|
|
return (
|
|
|
- <svg width={width || 32} height={height || 32} viewBox="0 0 1024 1024">
|
|
|
- <path fill={color || '#000000'} d={names[name || 'home']} />
|
|
|
+ <svg width={width} height={height} viewBox={viewBox}>
|
|
|
+ {pathComList()}
|
|
|
</svg>
|
|
|
)
|
|
|
}
|