2022-12-31 17:50:05 -08:00
|
|
|
import { PageHeader, ScrollArea, TextTitle } from '/@/renderer/components';
|
|
|
|
|
import { AnimatedPage, PlayButton } from '/@/renderer/features/shared';
|
2022-12-29 18:45:01 -08:00
|
|
|
import { useRef } from 'react';
|
|
|
|
|
import type { AgGridReact as AgGridReactType } from '@ag-grid-community/react/lib/agGridReact';
|
|
|
|
|
import { useAlbumDetail } from '/@/renderer/features/albums/queries/album-detail-query';
|
|
|
|
|
import { useParams } from 'react-router';
|
2022-12-31 17:50:05 -08:00
|
|
|
import { useFastAverageColor, useShouldPadTitlebar } from '/@/renderer/hooks';
|
2022-12-29 18:45:01 -08:00
|
|
|
import { AlbumDetailContent } from '/@/renderer/features/albums/components/album-detail-content';
|
|
|
|
|
import { AlbumDetailHeader } from '/@/renderer/features/albums/components/album-detail-header';
|
2022-12-31 17:50:05 -08:00
|
|
|
import { useIntersection } from '@mantine/hooks';
|
|
|
|
|
import { Group } from '@mantine/core';
|
2022-12-29 18:45:01 -08:00
|
|
|
|
|
|
|
|
const AlbumDetailRoute = () => {
|
|
|
|
|
const tableRef = useRef<AgGridReactType | null>(null);
|
|
|
|
|
const { albumId } = useParams() as { albumId: string };
|
|
|
|
|
const detailQuery = useAlbumDetail({ id: albumId });
|
|
|
|
|
const background = useFastAverageColor(detailQuery.data?.imageUrl);
|
2022-12-31 17:50:05 -08:00
|
|
|
const padTop = useShouldPadTitlebar();
|
|
|
|
|
|
|
|
|
|
const containerRef = useRef();
|
|
|
|
|
const { ref, entry } = useIntersection({
|
|
|
|
|
root: containerRef.current,
|
|
|
|
|
threshold: 0,
|
|
|
|
|
});
|
2022-12-29 18:45:01 -08:00
|
|
|
|
|
|
|
|
return (
|
2022-12-30 21:12:27 -08:00
|
|
|
<AnimatedPage key={`album-detail-${albumId}`}>
|
2022-12-29 18:45:01 -08:00
|
|
|
<PageHeader
|
2022-12-31 17:50:05 -08:00
|
|
|
backgroundColor="black"
|
|
|
|
|
isHidden={entry?.isIntersecting}
|
2022-12-29 18:45:01 -08:00
|
|
|
position="absolute"
|
2022-12-31 17:50:05 -08:00
|
|
|
>
|
|
|
|
|
<Group p="1rem">
|
|
|
|
|
<PlayButton
|
|
|
|
|
h={40}
|
|
|
|
|
w={40}
|
|
|
|
|
/>
|
|
|
|
|
<TextTitle
|
|
|
|
|
fw="bold"
|
|
|
|
|
order={2}
|
|
|
|
|
>
|
|
|
|
|
{detailQuery?.data?.name}
|
|
|
|
|
</TextTitle>
|
|
|
|
|
</Group>
|
|
|
|
|
</PageHeader>
|
2022-12-29 18:45:01 -08:00
|
|
|
|
|
|
|
|
<ScrollArea
|
2022-12-31 17:50:05 -08:00
|
|
|
ref={containerRef}
|
2022-12-29 18:45:01 -08:00
|
|
|
h="100%"
|
|
|
|
|
offsetScrollbars={false}
|
2022-12-31 17:50:05 -08:00
|
|
|
styles={{ scrollbar: { marginTop: padTop ? '35px' : 0 } }}
|
2022-12-29 18:45:01 -08:00
|
|
|
>
|
2022-12-31 03:16:05 -08:00
|
|
|
{background && (
|
|
|
|
|
<>
|
2022-12-31 17:50:05 -08:00
|
|
|
<AlbumDetailHeader
|
|
|
|
|
ref={ref}
|
|
|
|
|
background={background}
|
|
|
|
|
/>
|
2022-12-31 03:16:05 -08:00
|
|
|
<AlbumDetailContent tableRef={tableRef} />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2022-12-29 18:45:01 -08:00
|
|
|
</ScrollArea>
|
|
|
|
|
</AnimatedPage>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default AlbumDetailRoute;
|