xref: /MusicFree/src/pages/searchPage/components/resultPanel/results/artistResultItem.tsx (revision ed067386d74ad02ad6f817b5bcbae7b589b9e81f)
1import React from 'react';
2import ListItem from '@/components/base/listItem';
3import {ImgAsset} from '@/constants/assetsConst';
4import {ROUTE_PATH, useNavigate} from '@/core/router';
5import TitleAndTag from '@/components/mediaItem/titleAndTag';
6
7interface IArtistResultsProps {
8    item: IArtist.IArtistItem;
9    index: number;
10    pluginHash: string;
11}
12export default function ArtistResultItem(props: IArtistResultsProps) {
13    const {item: artistItem, pluginHash} = props;
14    const navigate = useNavigate();
15    return (
16        <ListItem
17            withHorizontalPadding
18            heightType="big"
19            onPress={() => {
20                navigate(ROUTE_PATH.ARTIST_DETAIL, {
21                    artistItem: artistItem,
22                    pluginHash,
23                });
24            }}>
25            <ListItem.ListItemImage
26                uri={artistItem.avatar}
27                fallbackImg={ImgAsset.albumDefault}
28            />
29            <ListItem.Content
30                description={
31                    artistItem.desc
32                        ? artistItem.desc
33                        : `${
34                              artistItem.worksNum
35                                  ? artistItem.worksNum + '个作品' // TODO 用字符串模板函数更好
36                                  : ''
37                          }    ${artistItem.description ?? ''}`
38                }
39                title={
40                    <TitleAndTag
41                        title={artistItem.name}
42                        tag={artistItem.platform}
43                    />
44                }
45            />
46        </ListItem>
47    );
48}
49