import React from 'react'; import {StyleSheet, View} from 'react-native'; import rpx from '@/utils/rpx'; import {List} from 'react-native-paper'; import Tag from './tag'; import ThemeText from './themeText'; import IconButton from './iconButton'; import FastImage from './fastImage'; export interface ILeftProps { /** 序号 */ index?: number | string; /** 封面图 */ artwork?: string; /** 封面图的兜底 */ fallback?: any; /** icon */ icon?: Parameters[0]; /** 宽度 */ width?: number; /** 组件 */ component?: () => JSX.Element; } function Left(props?: ILeftProps) { const { index, artwork, fallback, icon, width = rpx(100), component: Component, } = props ?? {}; return props && Object.keys(props).length ? ( Component ? ( ) : ( {index !== undefined ? ( {index} ) : icon !== undefined ? ( ) : ( )} ) ) : ( <> ); } const leftStyle = StyleSheet.create({ artworkWrapper: { justifyContent: 'center', alignItems: 'center', }, artwork: { width: rpx(76), height: rpx(76), borderRadius: rpx(16), }, }); /** 歌单item */ interface IListItemProps { /** 标题 */ title: string | number; /** 描述 */ desc?: string | JSX.Element; /** 标签 */ tag?: string; left?: ILeftProps; /** 右侧按钮 */ right?: () => JSX.Element; itemPaddingHorizontal?: number; itemHeight?: number; onPress?: () => void; } export default function ListItem(props: IListItemProps) { const { title, desc, tag, right, itemHeight, onPress, left, itemPaddingHorizontal = rpx(24), } = props; return ( } style={[ style.wrapper, { paddingHorizontal: itemPaddingHorizontal, height: itemHeight ?? rpx(120), paddingVertical: 0, }, ]} title={() => ( {title} {tag ? : <>} {desc ? ( {desc} ) : ( <> )} )} titleStyle={{ paddingVertical: 0, marginLeft: 0, marginVertical: 0, }} right={right ? right : () => <>} onPress={onPress} /> ); } const style = StyleSheet.create({ wrapper: { justifyContent: 'center', }, titleWrapper: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', }, textWidth: { maxWidth: rpx(460), }, artworkWrapper: { width: rpx(76), justifyContent: 'center', alignItems: 'center', marginRight: rpx(12), }, artwork: { width: rpx(76), height: rpx(76), borderRadius: rpx(16), }, });