Startup now uses the Android iris animation, and playback can continue in a corner miniplayer while browsing (the video is drawn into a corner rectangle beneath a matching hole in the page). The player keeps the window controls, hides its chrome when the pointer leaves, and gains audio/subtitle tracks, audio sync, source bitrate and playback details in its options. Subtitles can be styled in Settings with a live preview. Categories replace Collections, the A–Z rail magnifies, descriptions expand in place, downloads can be removed in bulk, and search keeps its results while typing. Fixes scroll jank from per-card and scrolling backdrop blurs, the hidden colour wash, the cubic volume curve, loud theme music, the search focus ring, a stray nav indicator, Continue Watching previews and the TV Shows header overlap. Removes the star rating, the duplicate Settings menu entry and the server settings' Show advanced switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
101 lines
3.1 KiB
TypeScript
101 lines
3.1 KiB
TypeScript
import { create } from 'zustand';
|
|
|
|
export type SectionKind = 'movie' | 'show';
|
|
export type SectionTab = 'discover' | 'library' | 'categories';
|
|
|
|
export type Route =
|
|
| { name: 'home' }
|
|
| { name: 'section'; kind: SectionKind; tab: SectionTab; genre?: string; genreTitle?: string }
|
|
| { name: 'item'; id: string; title?: string }
|
|
| { name: 'person'; id: string; title: string; thumb?: string }
|
|
| { name: 'hub'; key: string; title: string }
|
|
| { name: 'search'; query?: string }
|
|
| { name: 'downloads' }
|
|
| { name: 'settings'; mode: 'app' | 'server'; tab: string };
|
|
|
|
export interface Entry {
|
|
id: number;
|
|
route: Route;
|
|
scroll: number;
|
|
/** Per-screen state to restore on Back (e.g. selected season, library offset). */
|
|
state: Record<string, unknown>;
|
|
}
|
|
|
|
interface RouterState {
|
|
entries: Entry[];
|
|
index: number;
|
|
current: Entry;
|
|
navigate(route: Route, opts?: { replace?: boolean }): void;
|
|
back(): void;
|
|
forward(): void;
|
|
canBack(): boolean;
|
|
saveScroll(scroll: number): void;
|
|
setState(patch: Record<string, unknown>): void;
|
|
reset(route: Route): void;
|
|
}
|
|
|
|
let nextId = 1;
|
|
const entry = (route: Route): Entry => ({ id: nextId++, route, scroll: 0, state: {} });
|
|
const MAX = 60;
|
|
|
|
const sameDestination = (a: Route, b: Route) => JSON.stringify(a) === JSON.stringify(b);
|
|
|
|
export const useRouter = create<RouterState>((set, get) => {
|
|
const first = entry({ name: 'home' });
|
|
return {
|
|
entries: [first],
|
|
index: 0,
|
|
current: first,
|
|
navigate(route, opts) {
|
|
const { entries, index } = get();
|
|
if (sameDestination(entries[index].route, route)) return;
|
|
const e = entry(route);
|
|
let next = entries.slice(0, index + 1);
|
|
if (opts?.replace) next[next.length - 1] = e;
|
|
else next.push(e);
|
|
if (next.length > MAX) next = next.slice(next.length - MAX);
|
|
set({ entries: next, index: next.length - 1, current: e });
|
|
},
|
|
back() {
|
|
const { entries, index } = get();
|
|
if (index > 0) set({ index: index - 1, current: entries[index - 1] });
|
|
},
|
|
forward() {
|
|
const { entries, index } = get();
|
|
if (index < entries.length - 1) set({ index: index + 1, current: entries[index + 1] });
|
|
},
|
|
canBack: () => get().index > 0,
|
|
saveScroll(scroll) {
|
|
get().current.scroll = scroll;
|
|
},
|
|
setState(patch) {
|
|
const cur = get().current;
|
|
cur.state = { ...cur.state, ...patch };
|
|
},
|
|
reset(route) {
|
|
const e = entry(route);
|
|
set({ entries: [e], index: 0, current: e });
|
|
},
|
|
};
|
|
});
|
|
|
|
export const navigate = (route: Route, opts?: { replace?: boolean }) => useRouter.getState().navigate(route, opts);
|
|
export const goBack = () => useRouter.getState().back();
|
|
|
|
/** The top-level destination a route belongs to, for the navigation highlight. */
|
|
export function topLevel(route: Route): string {
|
|
switch (route.name) {
|
|
case 'home':
|
|
return 'home';
|
|
case 'section':
|
|
return route.kind === 'movie' ? 'movies' : 'shows';
|
|
case 'search':
|
|
return 'search';
|
|
case 'downloads':
|
|
return 'downloads';
|
|
case 'settings':
|
|
return 'settings';
|
|
default:
|
|
return '';
|
|
}
|
|
}
|