2023-10-30 19:22:45 -07:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-02-07 22:47:23 -08:00
|
|
|
import { RiAddBoxFill, RiAddCircleFill, RiMoreFill, RiPlayFill } from 'react-icons/ri';
|
2023-01-13 13:51:19 -08:00
|
|
|
import { QueueSong } from '/@/renderer/api/types';
|
2023-02-07 22:47:23 -08:00
|
|
|
import { Button, DropdownMenu, PageHeader, SpinnerIcon, Paper } from '/@/renderer/components';
|
2023-01-13 13:51:19 -08:00
|
|
|
import { usePlayQueueAdd } from '/@/renderer/features/player';
|
2023-02-07 22:47:23 -08:00
|
|
|
import { LibraryHeaderBar } from '/@/renderer/features/shared';
|
|
|
|
|
import { usePlayButtonBehavior } from '/@/renderer/store/settings.store';
|
2023-01-13 13:51:19 -08:00
|
|
|
import { Play } from '/@/renderer/types';
|
|
|
|
|
|
|
|
|
|
interface AlbumArtistDetailTopSongsListHeaderProps {
|
2023-07-01 19:10:05 -07:00
|
|
|
data: QueueSong[];
|
|
|
|
|
itemCount?: number;
|
|
|
|
|
title: string;
|
2023-01-13 13:51:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AlbumArtistDetailTopSongsListHeader = ({
|
2023-07-01 19:10:05 -07:00
|
|
|
title,
|
|
|
|
|
itemCount,
|
|
|
|
|
data,
|
2023-01-13 13:51:19 -08:00
|
|
|
}: AlbumArtistDetailTopSongsListHeaderProps) => {
|
2023-10-30 19:22:45 -07:00
|
|
|
const { t } = useTranslation();
|
2023-07-01 19:10:05 -07:00
|
|
|
const handlePlayQueueAdd = usePlayQueueAdd();
|
|
|
|
|
const playButtonBehavior = usePlayButtonBehavior();
|
2023-01-13 13:51:19 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const handlePlay = async (playType: Play) => {
|
|
|
|
|
handlePlayQueueAdd?.({
|
|
|
|
|
byData: data,
|
|
|
|
|
playType,
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-01-13 13:51:19 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return (
|
|
|
|
|
<PageHeader p="1rem">
|
|
|
|
|
<LibraryHeaderBar>
|
|
|
|
|
<LibraryHeaderBar.PlayButton onClick={() => handlePlay(playButtonBehavior)} />
|
|
|
|
|
<LibraryHeaderBar.Title>Top songs from {title}</LibraryHeaderBar.Title>
|
|
|
|
|
<Paper
|
|
|
|
|
fw="600"
|
|
|
|
|
px="1rem"
|
|
|
|
|
py="0.3rem"
|
|
|
|
|
radius="sm"
|
|
|
|
|
>
|
|
|
|
|
{itemCount === null || itemCount === undefined ? <SpinnerIcon /> : itemCount}
|
|
|
|
|
</Paper>
|
|
|
|
|
<DropdownMenu position="bottom-start">
|
|
|
|
|
<DropdownMenu.Target>
|
|
|
|
|
<Button
|
|
|
|
|
compact
|
|
|
|
|
fw="600"
|
|
|
|
|
variant="subtle"
|
|
|
|
|
>
|
|
|
|
|
<RiMoreFill size={15} />
|
|
|
|
|
</Button>
|
|
|
|
|
</DropdownMenu.Target>
|
|
|
|
|
<DropdownMenu.Dropdown>
|
|
|
|
|
<DropdownMenu.Item
|
|
|
|
|
icon={<RiPlayFill />}
|
|
|
|
|
onClick={() => handlePlay(Play.NOW)}
|
|
|
|
|
>
|
2023-10-30 19:22:45 -07:00
|
|
|
{t('player.add', { postProcess: 'sentenceCase' })}
|
2023-07-01 19:10:05 -07:00
|
|
|
</DropdownMenu.Item>
|
|
|
|
|
<DropdownMenu.Item
|
|
|
|
|
icon={<RiAddBoxFill />}
|
|
|
|
|
onClick={() => handlePlay(Play.LAST)}
|
|
|
|
|
>
|
2023-10-30 19:22:45 -07:00
|
|
|
{t('player.addLast', { postProcess: 'sentenceCase' })}
|
2023-07-01 19:10:05 -07:00
|
|
|
</DropdownMenu.Item>
|
|
|
|
|
<DropdownMenu.Item
|
|
|
|
|
icon={<RiAddCircleFill />}
|
|
|
|
|
onClick={() => handlePlay(Play.NEXT)}
|
|
|
|
|
>
|
2023-10-30 19:22:45 -07:00
|
|
|
{t('player.addNext', { postProcess: 'sentenceCase' })}
|
2023-07-01 19:10:05 -07:00
|
|
|
</DropdownMenu.Item>
|
|
|
|
|
</DropdownMenu.Dropdown>
|
|
|
|
|
</DropdownMenu>
|
|
|
|
|
</LibraryHeaderBar>
|
|
|
|
|
</PageHeader>
|
|
|
|
|
);
|
2023-01-13 13:51:19 -08:00
|
|
|
};
|