import classNames from 'classnames' import PropTypes, { InferProps } from 'prop-types' import React from 'react' import { Image, View } from '@tarojs/components' import { CommonEvent } from '@tarojs/components/types/common' import { AtTabBarProps, TabItem } from '../../../types/tab-bar' import AtBadge from '../badge/index' import AtIcon from '../icon' export default class AtTabBar extends React.Component { public static defaultProps: AtTabBarProps public static propTypes: InferProps // constructor () { // super(...arguments) // this.state = { // isIPhoneX: false // } // } // componentDidMount () { // const curEnv = Taro.getEnv() // if ( // curEnv === Taro.ENV_TYPE.WEAPP && // Taro.getSystemInfoSync().model.indexOf('iPhone X') >= 0 // ) { // this.setState({ isIPhoneX: true }) // } // } private handleClick(index: number, event: CommonEvent): void { this.props.onClick(index, event) } public render(): JSX.Element { const { customStyle = {}, className, fixed, backgroundColor, tabList, current, color, iconSize, fontSize, selectedColor } = this.props // const { isIPhoneX } = this.state const defaultStyle = { color: color || '' } const selectedStyle = { color: selectedColor || '' } const titleStyle: React.CSSProperties = {} if (fontSize) { titleStyle.fontSize = +fontSize } const rootStyle = { backgroundColor: backgroundColor || '' } const imgStyle: any = { // width: iconSize, // height: iconSize } if (iconSize) { imgStyle.width = iconSize imgStyle.height = iconSize } return ( {tabList.map((item: TabItem, i: number) => ( {item.iconType ? ( {/* */} ) : null} {item.image ? ( ) : null} {item.title} ))} ) } } AtTabBar.defaultProps = { customStyle: {}, className: '', selectedColor: '#6190E8', color: '#333', fixed: false, current: 0, tabList: [], // eslint-disable-next-line @typescript-eslint/no-empty-function onClick: (): void => {} } AtTabBar.propTypes = { customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]), className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]), fixed: PropTypes.bool, backgroundColor: PropTypes.string, current: PropTypes.number, iconSize: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), fontSize: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), color: PropTypes.string, selectedColor: PropTypes.string, tabList: PropTypes.array, onClick: PropTypes.func }