2023-01-13 13:51:19 -08:00
|
|
|
import { Flex, Group } from '@mantine/core';
|
|
|
|
|
import { RiMoreFill } from 'react-icons/ri';
|
|
|
|
|
import { QueueSong } from '/@/renderer/api/types';
|
|
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
DropdownMenu,
|
|
|
|
|
PageHeader,
|
|
|
|
|
TextTitle,
|
|
|
|
|
Badge,
|
|
|
|
|
SpinnerIcon,
|
|
|
|
|
} from '/@/renderer/components';
|
|
|
|
|
import { usePlayQueueAdd } from '/@/renderer/features/player';
|
|
|
|
|
import { useContainerQuery } from '/@/renderer/hooks';
|
|
|
|
|
import { Play } from '/@/renderer/types';
|
|
|
|
|
|
|
|
|
|
interface AlbumArtistDetailTopSongsListHeaderProps {
|
|
|
|
|
data: QueueSong[];
|
|
|
|
|
itemCount?: number;
|
|
|
|
|
title: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AlbumArtistDetailTopSongsListHeader = ({
|
|
|
|
|
title,
|
|
|
|
|
itemCount,
|
|
|
|
|
data,
|
|
|
|
|
}: AlbumArtistDetailTopSongsListHeaderProps) => {
|
|
|
|
|
const handlePlayQueueAdd = usePlayQueueAdd();
|
|
|
|
|
const cq = useContainerQuery();
|
|
|
|
|
|
|
|
|
|
const handlePlay = async (play: Play) => {
|
|
|
|
|
handlePlayQueueAdd?.({
|
|
|
|
|
byData: data,
|
|
|
|
|
play,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<PageHeader p="1rem">
|
|
|
|
|
<Flex
|
|
|
|
|
ref={cq.ref}
|
|
|
|
|
direction="row"
|
|
|
|
|
justify="space-between"
|
|
|
|
|
>
|
|
|
|
|
<Flex
|
|
|
|
|
align="center"
|
|
|
|
|
gap="md"
|
|
|
|
|
justify="center"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
compact
|
|
|
|
|
size="xl"
|
|
|
|
|
sx={{ paddingLeft: 0, paddingRight: 0 }}
|
|
|
|
|
variant="subtle"
|
|
|
|
|
>
|
|
|
|
|
<Group noWrap>
|
|
|
|
|
<TextTitle
|
|
|
|
|
maw="20vw"
|
2023-01-30 01:36:36 -08:00
|
|
|
order={2}
|
2023-01-13 13:51:19 -08:00
|
|
|
overflow="hidden"
|
2023-01-28 20:46:07 -08:00
|
|
|
weight={700}
|
2023-01-13 13:51:19 -08:00
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</TextTitle>
|
|
|
|
|
<Badge
|
|
|
|
|
radius="xl"
|
|
|
|
|
size="lg"
|
|
|
|
|
>
|
|
|
|
|
{itemCount === null || itemCount === undefined ? <SpinnerIcon /> : itemCount}
|
|
|
|
|
</Badge>
|
|
|
|
|
</Group>
|
|
|
|
|
</Button>
|
|
|
|
|
<DropdownMenu position="bottom-start">
|
|
|
|
|
<DropdownMenu.Target>
|
|
|
|
|
<Button
|
|
|
|
|
compact
|
|
|
|
|
fw="600"
|
|
|
|
|
variant="subtle"
|
|
|
|
|
>
|
|
|
|
|
<RiMoreFill size={15} />
|
|
|
|
|
</Button>
|
|
|
|
|
</DropdownMenu.Target>
|
|
|
|
|
<DropdownMenu.Dropdown>
|
|
|
|
|
<DropdownMenu.Item onClick={() => handlePlay(Play.NOW)}>Play</DropdownMenu.Item>
|
|
|
|
|
<DropdownMenu.Item onClick={() => handlePlay(Play.LAST)}>
|
|
|
|
|
Add to queue
|
|
|
|
|
</DropdownMenu.Item>
|
|
|
|
|
<DropdownMenu.Item onClick={() => handlePlay(Play.NEXT)}>
|
|
|
|
|
Add to queue next
|
|
|
|
|
</DropdownMenu.Item>
|
|
|
|
|
</DropdownMenu.Dropdown>
|
|
|
|
|
</DropdownMenu>
|
|
|
|
|
</Flex>
|
|
|
|
|
</Flex>
|
|
|
|
|
</PageHeader>
|
|
|
|
|
);
|
|
|
|
|
};
|