/* * SPDX-License-Identifier: GPL-3.0 * Vencord Desktop, a desktop app aiming to give you a snappier Discord Experience * Copyright (c) 2023 Vendicated and Vencord contributors */ import "./screenSharePicker.css"; import { classes, closeModal, Margins, Modals, openModal, useAwaiter } from "@vencord/types/utils"; import { findByPropsLazy } from "@vencord/types/webpack"; import { Button, Card, Forms, Switch, Text, useState } from "@vencord/types/webpack/common"; import type { Dispatch, SetStateAction } from "react"; const StreamResolutions = ["720", "1080", "1440", "Source"] as const; const StreamFps = ["15", "30", "60"] as const; const WarningIconClasses = findByPropsLazy("warning", "error", "container"); export type StreamResolution = (typeof StreamResolutions)[number]; export type StreamFps = (typeof StreamFps)[number]; interface StreamSettings { resolution: StreamResolution; fps: StreamFps; audio: boolean; } export interface StreamPick extends StreamSettings { id: string; } interface Source { id: string; name: string; url: string; } export function openScreenSharePicker(screens: Source[]) { return new Promise((resolve, reject) => { const key = openModal( props => ( { props.onClose(); reject("Aborted"); }} /> ), { onCloseRequest() { closeModal(key); reject("Aborted"); } } ); }); } function ScreenPicker({ screens, onPick }: { screens: Source[]; onPick: (id: string) => void; }) { return (
{screens.map(({ id, name, url }) => ( ))}
); } function StreamSettings({ source, settings, setSettings }: { source: Source; settings: StreamSettings; setSettings: Dispatch>; }) { const [thumb] = useAwaiter(() => VencordDesktopNative.capturer.getLargeThumbnail(source.id), { fallbackValue: source.url, deps: [source.id] }); return (
What you're streaming {source.name} Stream Settings Resolution and Frame Rate aren't implemented for now. Locked to 720p 30fps
Resolution
{StreamResolutions.map(res => ( ))}
Frame Rate
{StreamFps.map(fps => ( ))}
setSettings(s => ({ ...s, audio: checked }))} hideBorder className="vcd-screen-picker-audio" > Stream With Audio
); } function ModalComponent({ screens, modalProps, submit, close }: { screens: Source[]; modalProps: any; submit: (data: StreamPick) => void; close: () => void; }) { const [selected, setSelected] = useState(); const [settings, setSettings] = useState({ resolution: "1080", fps: "60", audio: true }); return ( ScreenShare {!selected ? ( ) : ( s.id === selected)!} settings={settings} setSettings={setSettings} /> )} {selected ? ( ) : ( )} ); }