ui: implement new appBar #284

This commit is contained in:
Prayag Prajapati committed 2024-04-23 09:48:01 +05:30
1 parent fae934dbe1
commit 41ff0f1d15
6 files changed
+248 -289

No files matched your search

+36 -61
View File
@@ -3,9 +3,18 @@
transition: background-color $transition-time-fast, transition: background-color $transition-time-fast,
backdrop-filter $transition-time-fast, backdrop-filter $transition-time-fast,
box-shadow $transition-time-default !important; box-shadow $transition-time-default !important;
&.backdropVisible { padding: 0.8em ($page-margin - 1.7em);
background-color: rgb(0 0 0 / 0.6) !important; .flex {
backdrop-filter: blur(10px); transition: $transition-time-fast;
border-radius: 1000px;
}
&.elevated{
.flex {
padding: 0.5em;
background: rgb(0 0 0 / 0.4);
backdrop-filter: blur(40px);
box-shadow: 0 0 15px rgb(0 0 0 / 0.2);
}
} }
&-avatar { &-avatar {
background: rgb(255 255 255 / 0.1) !important; background: rgb(255 255 255 / 0.1) !important;
@@ -50,81 +59,47 @@
} }
} }
} }
&-library { }
.library-drawer{
.library-drawer-item{
position: relative; position: relative;
width: 20rem; overflow: hidden;
text-decoration: none; border-radius: 1000px;
&::after { > div::before{
content: ""; content: "";
position: absolute; position: absolute;
inset: 5px; top: 0;
background: rgb(0 0 0 / 0.3); left: 0;
opacity: 0; right: 0;
transition: opacity $transition-time-fast; bottom: 0;
border-radius: 5px; background: transparent;
transition: $transition-time-default;
z-index: -1;
border-radius: 100px;
} }
> img {
border: 0px solid white;
width: inherit;
object-fit: cover;
height: 100%;
border-radius: 10px;
transition: border $transition-time-fast;
} }
&-icon { .active.library-drawer-item {
height: 100%;
width: inherit;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: white !important;
background: rgb(255 255 255 / 0.1);
border: 0px solid white;
border-radius: 10px;
transition: border $transition-time-fast;
.material-symbols-rounded{ .material-symbols-rounded{
font-size: 3em; --fill: 1;
}
&> div::before {
background: $clr-accent-default;
} }
} }
&.active {
&::after {
opacity: 1;
}
> img {
border: 5px solid white;
}
.material-symbols-rounded {
font-variation-settings: "FILL" 1, "wght" 300, "GRAD" 25,
"opsz" 40;
}
.appBar-library-icon {
border: 5px solid white;
}
}
&-scrollContainer {
display: flex;
max-width: 35vw;
overflow: auto;
gap: 1em;
height: inherit;
padding: 15px;
// Magic scrollbar // Magic scrollbar
&::-webkit-scrollbar { &::-webkit-scrollbar {
&-thumb { &-thumb {
width: 150px; height: 150px;
max-width: 33%; max-height: 33%;
} }
&-track { &-track {
margin-left: 25px; margin-top: 15px;
margin-right: 25px; margin-bottom: 15px;
background: transparent !important; background: transparent !important;
} }
} }
} }
}
}
.appLoading { .appLoading {
opacity: 0; opacity: 0;
+170 -200
View File
@@ -18,7 +18,13 @@ import useScrollTrigger from "@mui/material/useScrollTrigger";
import { red } from "@mui/material/colors"; import { red } from "@mui/material/colors";
import { Link, NavLink, useLocation, useNavigate } from "react-router-dom"; import {
NavLink as NavLinkBase,
Link as RouterLink,
type LinkProps as RouterLinkProps,
useLocation,
useNavigate,
} from "react-router-dom";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api"; import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
@@ -35,27 +41,63 @@ import { useApi } from "../../utils/store/api";
import { getTypeIcon } from "../utils/iconsCollection"; import { getTypeIcon } from "../utils/iconsCollection";
import { Divider } from "@mui/material";
import logo from "../../assets/icon.svg";
import { import {
Divider,
Drawer,
List,
ListItem,
ListItemButton,
ListItemText,
} from "@mui/material";
import logo from "../../assets/icon.svg";
import useSettingsStore, {
setSettingsDialogOpen, setSettingsDialogOpen,
setSettingsTabValue, setSettingsTabValue,
} from "../../utils/store/settings"; } from "../../utils/store/settings";
const forwardRefNavLink = React.forwardRef({ interface ListItemLinkProps {
displayName: "NavLink", icon?: React.ReactElement;
render: (props, ref) => ( primary: string;
<NavLink to: string;
}
const NavLink = React.forwardRef((props, ref) => (
<NavLinkBase
ref={ref} ref={ref}
to={props.to} {...props}
style={{ textDecoration: "none" }}
className={({ isActive }) => className={({ isActive }) =>
`${props.className} ${isActive ? props.activeClassName : ""}` `${props.className} ${isActive ? props.activeClassName : ""}`
} }
/>
));
function ListItemLink(props: ListItemLinkProps) {
const { icon, primary, to } = props;
return (
<li>
<ListItem
component={NavLink}
activeClassName="active"
className="library-drawer-item"
to={to}
> >
{props.children} <ListItemButton
</NavLink> style={{
), borderRadius: "100px",
}); gap: "0.85em",
color: "white",
textDecoration: "none",
}}
>
<div className="material-symbols-rounded">{icon}</div>
<ListItemText primary={primary} />
</ListItemButton>
</ListItem>
</li>
);
}
export const AppBar = () => { export const AppBar = () => {
const [api] = useApi((state) => [state.api]); const [api] = useApi((state) => [state.api]);
@@ -108,11 +150,8 @@ export const AppBar = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [setDrawerOpen] = useDrawerStore((state) => [state.setOpen]); const [tabValue] = useSettingsStore((state) => [state.tabValue]);
const handleDrawerOpen = () => {
setDrawerOpen(true);
};
const handleLogout = async () => { const handleLogout = async () => {
console.log("Logging out user..."); console.log("Logging out user...");
await api.logout(); await api.logout();
@@ -124,19 +163,6 @@ export const AppBar = () => {
navigate("/login/index"); navigate("/login/index");
}; };
const [librariesPopper, setLibrariesPopper] = useState(false);
const librariesText = useRef(null);
const handlePopper = (event) => {
if (librariesPopper) {
setLibrariesPopper(null);
} else {
setLibrariesPopper(event.currentTarget);
}
};
const [isBrowsingLibrary, setIsBrowsingLibrary] = useState(false);
useEffect(() => { useEffect(() => {
if ( if (
location.pathname.includes("login") || location.pathname.includes("login") ||
@@ -156,202 +182,53 @@ export const AppBar = () => {
} else { } else {
setBackButtonVisible(true); setBackButtonVisible(true);
} }
if (location.pathname.includes("library")) {
setIsBrowsingLibrary(true);
} else {
setIsBrowsingLibrary(false);
}
}, [location]); }, [location]);
const [showDrawer, setShowDrawer] = useState(false);
if (!display) { if (!display) {
return <></>; return <></>;
} }
if (display) { if (display) {
return ( return (
<>
<MuiAppBar <MuiAppBar
style={{ style={{
backgroundColor: "transparent", backgroundColor: "transparent",
paddingRight: "0 !important", paddingRight: "0 !important",
}} }}
className={trigger ? "appBar backdropVisible" : "appBar"} className={
elevation={trigger ? 4 : 0} trigger
? "appBar flex flex-row flex-justify-spaced-between elevated"
: "appBar flex flex-row flex-justify-spaced-between"
}
elevation={0}
color="transparent" color="transparent"
> >
<Toolbar <div className="flex flex-row" style={{ gap: "0.6em" }}>
sx={{ <IconButton onClick={() => setShowDrawer(true)}>
display: "grid", <div className="material-symbols-rounded">menu</div>
gap: "0.6em", </IconButton>
gridTemplateColumns: "30% 1fr 30%",
}}
>
<IconButton <IconButton
onClick={() => navigate(-1)}
disabled={!backButtonVisible} disabled={!backButtonVisible}
style={{ onClick={() => navigate(-1)}
justifySelf: "left",
}}
> >
<div className="material-symbols-rounded">arrow_back</div> <div className="material-symbols-rounded">arrow_back</div>
</IconButton> </IconButton>
<IconButton onClick={() => navigate("/home")}>
<div <div
className="flex flex-row flex-center"
style={{
gap: "2.6em",
}}
>
<NavLink to="/home">
{({ isActive }) =>
isActive ? (
<Button
style={{
textTransform: "none",
}}
size="large"
className="appBar-text active"
>
<Typography variant="subtitle1" fontWeight={600}>
Home
</Typography>
</Button>
) : (
<Button
style={{
textTransform: "none",
}}
className="appBar-text"
size="large"
color="white"
>
<Typography variant="subtitle1" fontWeight={600}>
Home
</Typography>
</Button>
)
}
</NavLink>
<Button
variant="text"
// disableRipple
disableElevation
onClick={handlePopper}
style={{ textTransform: "none" }}
size="large"
disableFocusRipple={false}
color={isBrowsingLibrary ? "primary" : "white"}
className={ className={
isBrowsingLibrary ? "appBar-text active" : "appBar-text" location.pathname === "/home"
? "material-symbols-rounded fill"
: "material-symbols-rounded"
} }
> >
<Typography variant="subtitle1" fontWeight={600}> home
Libraries
</Typography>
</Button>
{/* <Typography
variant="subtitle1"
fontWeight={600}
onMouseEnter={popoverEnter}
onFocus={popoverEnter}
tabIndex={0}
className={
isBrowsingLibrary
? "appBar-text active"
: "appBar-text"
}
// onMouseLeave={popoverLeave}
></Typography> */}
<Popper
open={Boolean(librariesPopper)}
anchorEl={librariesPopper}
placement="bottom"
disablePortal
modifiers={[
{
name: "flip",
enabled: true,
options: {
altBoundary: true,
rootBoundary: "document",
padding: 8,
},
},
{
name: "preventOverflow",
enabled: true,
options: {
altAxis: true,
altBoundary: true,
tether: true,
rootBoundary: "document",
padding: 8,
},
},
]}
transition
>
{({ TransitionProps }) => (
<Grow
{...TransitionProps}
style={{
transformOrigin: "50% 0 0",
}}
timeout={250}
>
<Paper
sx={{
mt: "1.1em",
maxHeight: "72em",
}}
style={{
boxShadow:
"0px 5px 5px -3px rgba(0,0,0,0.2), 0px 8px 10px 1px rgba(0,0,0,0.14), 0px 3px 14px 2px rgba(0,0,0,0.12)",
overflow: "hidden",
borderRadius: "25px",
}}
>
<div className="appBar-library-scrollContainer">
{libraries.isPending
? "loading..."
: libraries.data.Items.map((library) => (
<NavLink
key={library.Id}
className="appBar-library"
to={`library/${library.Id}`}
style={{
borderRadius: "10px",
}}
>
{Object.keys(library.ImageTags).includes(
"Primary",
) ? (
<img
alt={library.Name}
src={`${api.basePath}/Items/${library.Id}/Images/Primary?quality=90&fillHeight=226&fillWidth=127`}
/>
) : (
<div className="appBar-library-icon">
{" "}
{getTypeIcon(library.CollectionType)}{" "}
<Typography variant="h6">
{library.Name}
</Typography>
</div> </div>
)} </IconButton>
</NavLink>
))}
</div>
</Paper>
</Grow>
)}
</Popper>
</div> </div>
<div <div className="flex flex-row" style={{ gap: "0.6em" }}>
className="flex flex-row"
style={{ justifySelf: "right", gap: "0.6em" }}
>
<IconButton onClick={() => navigate("/search")}> <IconButton onClick={() => navigate("/search")}>
<div className="material-symbols-rounded">search</div> <div className="material-symbols-rounded">search</div>
</IconButton> </IconButton>
@@ -423,8 +300,101 @@ export const AppBar = () => {
</MenuItem> </MenuItem>
</Menu> </Menu>
</div> </div>
</Toolbar>
</MuiAppBar> </MuiAppBar>
<Drawer
open={showDrawer}
PaperProps={{
className: "glass library-drawer",
style: {
width: "20em",
margin: "1.4em",
height: "calc(100vh - 2.8em)",
borderRadius: "20px",
overflowX: "hidden",
overflowY: "auto",
border: "1.2px solid rgb(255 255 255 / 0.2)",
},
}}
className="library-drawer"
onClose={() => setShowDrawer(false)}
>
<List>
<ListItem>
<ListItemButton
onClick={() => setShowDrawer(false)}
style={{
borderRadius: "100px",
gap: "0.85em",
}}
>
<span className="material-symbols-rounded">menu_open</span>
Close
</ListItemButton>
</ListItem>
</List>
<Divider variant="middle" />
<List>
<ListItemLink to="/home" icon="home" primary="Home" />
{libraries.isSuccess &&
libraries.data.Items?.map((library, index) => (
<ListItemLink
key={library.Id}
to={`/library/${library.Id}`}
icon={getTypeIcon(library.CollectionType)}
primary={library.Name}
/>
))}
</List>
<Divider variant="middle" />
<List>
<ListItem>
<ListItemButton
onClick={() => {
setSettingsDialogOpen(true);
setSettingsTabValue(1);
}}
style={{
borderRadius: "100px",
gap: "0.85em",
}}
>
<span className="material-symbols-rounded">settings</span>
Settings
</ListItemButton>
</ListItem>
<ListItem>
<ListItemButton
onClick={() => {
setSettingsDialogOpen(true);
setSettingsTabValue(2);
}}
style={{
borderRadius: "100px",
gap: "0.85em",
}}
>
<span className="material-symbols-rounded">dns</span>
Change Server
</ListItemButton>
</ListItem>
<ListItem>
<ListItemButton
onClick={() => {
setSettingsDialogOpen(true);
setSettingsTabValue(10);
}}
style={{
borderRadius: "100px",
gap: "0.85em",
}}
>
<span className="material-symbols-rounded">info</span>
About
</ListItemButton>
</ListItem>
</List>
</Drawer>
</>
); );
} }
}; };
+23 -19
View File
@@ -17,6 +17,7 @@ import {
SortOrder, SortOrder,
type UserItemDataDto, type UserItemDataDto,
} from "@jellyfin/sdk/lib/generated-client"; } from "@jellyfin/sdk/lib/generated-client";
import { getDlnaApi } from "@jellyfin/sdk/lib/utils/api/dlna-api";
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api"; import { getPlaylistsApi } from "@jellyfin/sdk/lib/utils/api/playlists-api";
import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api"; import { getTvShowsApi } from "@jellyfin/sdk/lib/utils/api/tv-shows-api";
@@ -135,6 +136,8 @@ const PlayButton = ({
mutationFn: async () => { mutationFn: async () => {
setPlaybackDataLoading(true); setPlaybackDataLoading(true);
let result: any; let result: any;
const deviceProfile = await getDlnaApi(api).getDefaultProfile();
console.log(deviceProfile);
if (playlistItem) { if (playlistItem) {
result = await getPlaylistsApi(api).getPlaylistItems({ result = await getPlaylistsApi(api).getPlaylistItems({
userId: userId, userId: userId,
@@ -246,31 +249,32 @@ const PlayButton = ({
enableSubtitles = false; enableSubtitles = false;
} }
playItem( // playItem(
itemName, // itemName,
episodeTitle, // episodeTitle,
currentVideoTrack, // currentVideoTrack,
currentAudioTrack, // currentAudioTrack,
selectedSubtitleTrack, // selectedSubtitleTrack,
result.Items[0].Container, // result.Items[0].Container,
enableSubtitles, // enableSubtitles,
`${api.basePath}/Videos/${result.Items[0].Id}/stream.${result.Items[0].Container}?Static=true&mediaSourceId=${result.Items[0].Id}&deviceId=${api.deviceInfo.id}&api_key=${api.accessToken}&Tag=${result.Items[0].MediaSources[0].ETag}&videoStreamIndex=${currentVideoTrack}&audioStreamIndex=${currentAudioTrack}`, // `${api.basePath}/Videos/${result.Items[0].Id}/stream.${result.Items[0].Container}?Static=true&mediaSourceId=${result.Items[0].Id}&deviceId=${api.deviceInfo.id}&api_key=${api.accessToken}&Tag=${result.Items[0].MediaSources[0].ETag}&videoStreamIndex=${currentVideoTrack}&audioStreamIndex=${currentAudioTrack}`,
userId, // userId,
result?.Items[0].UserData?.PlaybackPositionTicks, // result?.Items[0].UserData?.PlaybackPositionTicks,
result.Items[0].RunTimeTicks, // result.Items[0].RunTimeTicks,
result.Items[0], // result.Items[0],
queue, // queue,
0, // 0,
subtitles, // subtitles,
result?.Items[0].MediaSources[0].Id, // result?.Items[0].MediaSources[0].Id,
); // );
navigate("/player"); // navigate("/player");
} }
}, },
onSettled: () => { onSettled: () => {
setPlaybackDataLoading(false); setPlaybackDataLoading(false);
}, },
onError: (error) => { onError: (error) => {
console.error(error);
enqueueSnackbar(`${error}`, { enqueueSnackbar(`${error}`, {
variant: "error", variant: "error",
}); });
+3 -3
View File
@@ -34,7 +34,7 @@ import { createApi, useApi } from "../../utils/store/api";
import { useCentralStore } from "../../utils/store/central"; import { useCentralStore } from "../../utils/store/central";
import "./settings.module.scss"; import "./settings.module.scss";
import { RecommendedServerInfo } from "@jellyfin/sdk"; import type { RecommendedServerInfo } from "@jellyfin/sdk";
import { LoadingButton } from "@mui/lab"; import { LoadingButton } from "@mui/lab";
import { red, yellow } from "@mui/material/colors"; import { red, yellow } from "@mui/material/colors";
import { relaunch } from "@tauri-apps/api/process"; import { relaunch } from "@tauri-apps/api/process";
@@ -194,7 +194,7 @@ const Settings = () => {
fullWidth fullWidth
maxWidth="md" maxWidth="md"
PaperProps={{ PaperProps={{
className: "settings", className: "settings glass",
}} }}
onClose={() => setSettingsDialogOpen(false)} onClose={() => setSettingsDialogOpen(false)}
> >
@@ -205,7 +205,7 @@ const Settings = () => {
setSettingsTabValue(newValue); setSettingsTabValue(newValue);
}} }}
style={{ style={{
borderRight: "1.2px solid rgb(255 255 255 / 0.1)", background: "rgb(0 0 0 / 0.6)",
}} }}
> >
<Tab <Tab
+6 -1
View File
@@ -226,7 +226,7 @@ h1 {
.flex { .flex {
display: flex; display: flex;
&-row { &-row {
flex-direction: row; flex-direction: row !important;
} }
&-column { &-column {
flex-direction: column; flex-direction: column;
@@ -289,3 +289,8 @@ h1 {
.fullWidth { .fullWidth {
width: 100%; width: 100%;
} }
.glass {
background: rgb(0 0 0 / 0.4) !important;
backdrop-filter: blur(40px);
}
+10 -5
View File
@@ -55,8 +55,6 @@ export const theme = createTheme({
styleOverrides: { styleOverrides: {
paper: { paper: {
borderRadius: "10px", borderRadius: "10px",
background: "hsl(256, 100%, 2%, 40%)",
backdropFilter: "blur(20px)",
border: "1px solid rgb(255 255 255 / 0.1)", border: "1px solid rgb(255 255 255 / 0.1)",
}, },
list: { list: {
@@ -65,6 +63,11 @@ export const theme = createTheme({
}, },
defaultProps: { defaultProps: {
disableScrollLock: true, disableScrollLock: true,
slotProps: {
paper: {
className: "glass",
},
},
}, },
}, },
MuiMenuItem: { MuiMenuItem: {
@@ -79,9 +82,11 @@ export const theme = createTheme({
styleOverrides: { styleOverrides: {
paper: { paper: {
borderRadius: "20px", borderRadius: "20px",
background: "rgb(0 0 0 / 0.5)", },
backdropFilter: "blur(10px)", },
border: "1px solid rgb(255 255 255 / 0.2)", defaultProps: {
PaperProps: {
className: "glass",
}, },
}, },
}, },