feat(player): restyle the floating media bar as liquid glass
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 1s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
- cover-tinted translucent surface with a specular rim, grain and glow - centered transport dock and right-hand control capsule - adaptive accent colour, glass cover treatment and shared artwork between the bar and the full player
This commit is contained in:
1 parent
72909fd3b2
commit
94decd674c
7 files changed
+695
-451
No files matched your search
@@ -11,9 +11,15 @@ import {
|
||||
Tooltip,
|
||||
} from "@mui/material";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
|
||||
import { createFileRoute, Link, useNavigate, useRouter } from "@tanstack/react-router";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import React, {
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from "react";
|
||||
import CastButton from "@/components/buttons/castButton";
|
||||
import LikeButton from "@/components/buttons/likeButton";
|
||||
import LyricsPanel, {
|
||||
@@ -23,8 +29,11 @@ import PlayerVolume from "@/components/playback/audioPlayer/components/PlayerVol
|
||||
import StatsPanel from "@/components/playback/audioPlayer/components/StatsPanel";
|
||||
import WindowControls from "@/components/windowControls";
|
||||
import { getRuntimeMusic, secToTicks, ticksToSec } from "@/utils/date/time";
|
||||
import { consumeAudioPlayerReturn } from "@/utils/methods/audioPlayerReturn";
|
||||
import { getCoverPalette } from "@/utils/methods/coverColor";
|
||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||
import getImageUrlsApi, {
|
||||
getPlayerCoverUrl,
|
||||
} from "@/utils/methods/getImageUrlsApi";
|
||||
import { getItemQueryOptions } from "@/utils/queries/items";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import {
|
||||
@@ -133,7 +142,7 @@ const CoverArt = ({ src, alt }: { src?: string; alt: string }) => {
|
||||
const [current, setCurrent] = useState<string | undefined>(src);
|
||||
const [previous, setPrevious] = useState<string | undefined>();
|
||||
const currentRef = useRef<string | undefined>(src);
|
||||
const hasSwappedRef = useRef(false);
|
||||
const hasSwappedRef = useRef(true);
|
||||
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -204,6 +213,7 @@ function AudioPlayerRoute() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const navigate = useNavigate();
|
||||
const router = useRouter();
|
||||
const [queue, currentTrack, repeatMode] = useQueue((s) => [
|
||||
s.tracks,
|
||||
s.currentItemIndex,
|
||||
@@ -223,6 +233,15 @@ function AudioPlayerRoute() {
|
||||
const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
|
||||
const [statsOpen, setStatsOpen] = useState(false);
|
||||
|
||||
// Hide the floating bar only after this route has committed, so the view
|
||||
// transition still has it in the old frame and can morph its cover.
|
||||
useLayoutEffect(() => {
|
||||
document.documentElement.classList.add("player-full-open");
|
||||
return () => {
|
||||
document.documentElement.classList.remove("player-full-open");
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const player = audioPlayerRef?.current;
|
||||
if (!player) return;
|
||||
@@ -274,14 +293,8 @@ function AudioPlayerRoute() {
|
||||
};
|
||||
|
||||
const imageUrl = useMemo(
|
||||
() =>
|
||||
item?.ImageTags?.Primary
|
||||
? api &&
|
||||
getImageUrlsApi(api).getItemImageUrlById(item.Id ?? "", "Primary", {
|
||||
tag: item.ImageTags.Primary,
|
||||
})
|
||||
: undefined,
|
||||
[item?.Id, item?.ImageTags?.Primary, api],
|
||||
() => getPlayerCoverUrl(api, item, 600),
|
||||
[api, item?.Id, item?.AlbumId, item?.ImageTags?.Primary],
|
||||
);
|
||||
|
||||
const coverFor = (track: BaseItemDto) =>
|
||||
@@ -309,6 +322,15 @@ function AudioPlayerRoute() {
|
||||
setPanelOpen(true);
|
||||
};
|
||||
|
||||
const collapsePlayer = () => {
|
||||
const returnTo = consumeAudioPlayerReturn();
|
||||
if (returnTo) {
|
||||
void router.navigate({ href: returnTo });
|
||||
} else {
|
||||
void router.navigate({ to: "/home" });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
@@ -340,7 +362,7 @@ function AudioPlayerRoute() {
|
||||
<button
|
||||
type="button"
|
||||
className="music-player-collapse"
|
||||
onClick={() => window.history.back()}
|
||||
onClick={collapsePlayer}
|
||||
aria-label="Свернуть плеер"
|
||||
>
|
||||
<span className="material-symbols-rounded">expand_more</span>
|
||||
|
||||
Reference in new issue
Block a user