feat: source selection & ugly source selector

This commit is contained in:
Adrian Castro
2024-02-18 12:22:07 +01:00
parent 68ec709c51
commit ec1300c6d6
7 changed files with 113 additions and 5 deletions

View File

@@ -3,16 +3,21 @@ import * as ScreenOrientation from "expo-screen-orientation";
import type { Stream } from "@movie-web/provider-utils";
import type { MakeSlice } from "./types";
import type { ItemData } from "~/components/item/item";
export interface InterfaceSlice {
interface: {
isIdle: boolean;
idleTimeout: NodeJS.Timeout | null;
stream: Stream | null;
sourceId: string | null;
data: ItemData | null;
selectedCaption: Stream["captions"][0] | null;
};
setIsIdle(state: boolean): void;
setStream(stream: Stream): void;
setSourceId(sourceId: string): void;
setData(data: ItemData): void;
lockOrientation: () => Promise<void>;
unlockOrientation: () => Promise<void>;
presentFullscreenPlayer: () => Promise<void>;
@@ -24,6 +29,8 @@ export const createInterfaceSlice: MakeSlice<InterfaceSlice> = (set, get) => ({
isIdle: true,
idleTimeout: null,
stream: null,
sourceId: null,
data: null,
selectedCaption: null,
},
setIsIdle: (state) => {
@@ -46,6 +53,16 @@ export const createInterfaceSlice: MakeSlice<InterfaceSlice> = (set, get) => ({
s.interface.stream = stream;
});
},
setSourceId: (sourceId: string) => {
set((s) => {
s.interface.sourceId = sourceId;
});
},
setData: (data: ItemData) => {
set((s) => {
s.interface.data = data;
});
},
lockOrientation: async () => {
await ScreenOrientation.lockAsync(
ScreenOrientation.OrientationLock.LANDSCAPE,