mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
feat: source selection & ugly source selector
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user