Add bar to libview #9

This commit is contained in:
prayag17 committed 2023-04-05 14:24:26 +05:30
1 parent 7cba5a39f6
commit 628f90ef57
4 files changed
+78 -33

No files matched your search

+43 -8
View File
@@ -4,8 +4,7 @@ import { useDispatch, useSelector } from "react-redux";
import {
showAppBar,
setBackdrop,
setPage,
removePage,
showBackButton,
} from "../../utils/slice/appBar";
import { useParams } from "react-router-dom";
@@ -14,6 +13,14 @@ import { useQuery } from "@tanstack/react-query";
import Box from "@mui/material/Box";
import Grid2 from "@mui/material/Unstable_Grid2";
import useScrollTrigger from "@mui/material/useScrollTrigger";
import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import Typography from "@mui/material/Typography";
import CircularProgress from "@mui/material/CircularProgress";
import Divider from "@mui/material/Divider";
import Chip from "@mui/material/Chip";
import { theme } from "../../theme";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
@@ -69,7 +76,7 @@ const LibraryView = () => {
if (currentLib.isSuccess) {
// console.log(currentLib.data.)
dispatch(setPage(currentLib.data.Items[0].Name));
dispatch(showBackButton());
}
const items = useQuery({
@@ -79,12 +86,12 @@ const LibraryView = () => {
});
useEffect(() => {
dispatch(setBackdrop(trigger));
dispatch(setBackdrop(true));
}, [trigger]);
if (currentLib.isLoading || items.isLoading) {
return <h1>Loading...</h1>;
}
// if (currentLib.isLoading || items.isLoading) {
// return <h1>Loading...</h1>;
// }
return (
<Box
@@ -97,7 +104,7 @@ const LibraryView = () => {
className="scrollY"
sx={{
flexGrow: 1,
pt: 11,
pt: 19,
px: 3,
pb: 3,
position: "relative",
@@ -108,6 +115,34 @@ const LibraryView = () => {
}
}}
>
<AppBar
position="fixed"
elevation={0}
sx={{
width: `calc(100vw - ${theme.spacing(7)} - 10px)`,
mt: 8,
}}
>
<Divider />
<Toolbar>
<Typography variant="h5" sx={{ mr: 2 }}>
{currentLib.isLoading ? (
<CircularProgress sx={{ p: 1 }} />
) : (
currentLib.data.Items[0].Name
)}
</Typography>
<Chip
label={
items.isLoading ? (
<CircularProgress sx={{ p: 1 }} />
) : (
items.data.TotalRecordCount
)
}
/>
</Toolbar>
</AppBar>
<Grid2 container columns={{ xs: 3, sm: 5, md: 8 }}>
{items.isSuccess &&
items.data.Items.map((item, index) => {