Add app backdrop

This commit is contained in:
Prayag Prajapati committed 2023-08-14 18:58:59 +05:30
1 parent c568cf2be4
commit 73085f736f
5 files changed
+66 -5

No files matched your search

+28 -4
View File
@@ -2,8 +2,6 @@
import React, { useState, useEffect } from "react";
import { appWindow } from "@tauri-apps/api/window";
import useKonami from "react-use-konami";
import { ThemeProvider } from "@mui/material/styles";
@@ -38,8 +36,7 @@ import DialogContentText from "@mui/material/DialogContentText";
import DialogTitle from "@mui/material/DialogTitle";
import Button from "@mui/material/Button";
import Slide from "@mui/material/Slide";
// import Slide from "@mui/material/Slide";
import CircularProgress from "@mui/material/CircularProgress";
import Box from "@mui/material/Box";
// Routes
import { ServerSetup, ServerList } from "./routes/setup/server";
@@ -71,6 +68,7 @@ import { delServer, getServer } from "./utils/storage/servers.js";
import { delUser, getUser } from "./utils/storage/user.js";
import axios from "axios";
import { useBackdropStore } from "./utils/store/backdrop.js";
const jellyfin = new Jellyfin({
clientInfo: {
@@ -268,6 +266,12 @@ function App() {
}
});
}
const [backdropUrl, backdropId] = useBackdropStore((state) => [
state.backdropUrl,
state.backdropId,
]);
const [easterEgg, setEasterEgg] = useState(false);
const sixtyNine = () => {
setEasterEgg(true);
@@ -362,6 +366,26 @@ function App() {
width: "calc(100vw - 14px)",
}}
>
<Box className="app-backdrop-container">
<motion.img
key={backdropId}
src={backdropUrl}
alt=""
className="app-backdrop"
initial={{
opacity: 0,
}}
animate={{
opacity: 0.5,
}}
exit={{
opacity: 0,
}}
transition={{
duration: 1,
}}
/>
</Box>
<CssBaseline />
<SideMenu />
<AppBar />
-1
View File
@@ -1 +0,0 @@
/** @format */
+10
View File
@@ -53,6 +53,7 @@ import { ErrorBoundary } from "react-error-boundary";
import CarouselSlideError from "../../components/errors/carousel";
import { motion } from "framer-motion";
import { useBackdropStore } from "../../utils/store/backdrop";
const Home = () => {
const authUser = useQuery({
queryKey: ["home", "authenticateUser"],
@@ -196,6 +197,8 @@ const Home = () => {
});
}
const [setAppBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
if (user.isPaused) {
user.refetch();
console.log(user.isError);
@@ -245,6 +248,13 @@ const Home = () => {
sx={{
marginBottom: "1.5em",
}}
onChange={(now) => {
console.log(latestMedia.data[now]);
setAppBackdrop(
`${window.api.basePath}/Items/${latestMedia.data[now].Id}/Images/Backdrop`,
latestMedia.data[now].Id,
);
}}
duration={400}
interval={10000}
>
+18
View File
@@ -41,6 +41,24 @@ body {
overflow-y: overlay;
}
.app-backdrop {
object-fit: cover;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
filter: blur(50px);
&-container {
position: fixed;
width: 100vw;
height: 100vh;
left: 0;
top: 0;
}
}
#root,
.root-page {
height: fit-content;
+10
View File
@@ -0,0 +1,10 @@
/** @format */
import { create } from "zustand";
export const useBackdropStore = create((set) => ({
backdropUrl: "",
backdropId: "",
setBackdrop: (url, id) =>
set((state) => ({ backdropUrl: url, backdropId: id })),
}));