import React from 'react'; import { observer } from 'mobx-react'; import { Image, Text, View, SafeView } from '../../../../'; import { px } from '../../../../utils'; // @ts-ignore import defaultIcon from '../../../../assets/images/default_img.png'; export interface FootbarItem { name: string; text?: string; iconPath: string; selectedIconPath: string; width?: number; height?: number; /** * 图标距离文字距离 */ spacing?: number; style?: React.CSSProperties; styleSelected?: React.CSSProperties; /** * 徽标提示 */ badge?: string; /** * 红点 */ dot?: boolean; } interface FooterBarProps { /** * 文字颜色 */ color?: string; /** * 选中颜色 */ selectedColor?: string; // position?: 'top' | 'bottom'; /** * 按钮列表 */ list?: FootbarItem[]; style?: React.CSSProperties; /** * 当前项 */ current?: number | string; onChange?: (index: number, name?: string) => void; } const FooterBar = observer( ({ current = 0, list = [], color, selectedColor, style, onChange }: FooterBarProps) => { const changeTab = (index: number, name?: string) => { onChange && onChange(index, name); }; return ( {list.map((item, index) => { const isSelect = typeof current === 'string' ? current === item.name : current === index; return ( {/* Badge */} {!!item.badge && ( {item.badge} )} {item.text || 'text'} ); })} ); }, ); export default FooterBar;