mirror of
https://github.com/SteamDeckHomebrew/decky-frontend-lib.git
synced 2026-06-04 16:46:57 +02:00
add modal support, showModal->showContextMenu and new showModal
This commit is contained in:
24
src/deck-components/Modal.tsx
Normal file → Executable file
24
src/deck-components/Modal.tsx
Normal file → Executable file
@@ -1,12 +1,28 @@
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
import { FC, ReactNode } from 'react';
|
||||
import { findModuleChild } from '../webpack';
|
||||
|
||||
export const showModal: (children: ReactNode, parent: EventTarget) => void = findModuleChild((m) => {
|
||||
// TODO: there is another argument, figure out what it does
|
||||
export const showModal: (children: ReactNode, parent?: EventTarget) => void = findModuleChild((m) => {
|
||||
if (typeof m !== 'object') return undefined;
|
||||
for (let prop in m) {
|
||||
if (typeof m[prop] === 'function' && m[prop].toString().includes('stopPropagation))')) {
|
||||
if (typeof m[prop] === 'function' && m[prop].toString().includes('bHideMainWindowForPopouts:!0')) {
|
||||
return m[prop];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
interface ModalRootProps {
|
||||
onMiddleButton?(): void,
|
||||
onCancel?(): void;
|
||||
onOK?(): void;
|
||||
bAllowFullSize?: boolean;
|
||||
}
|
||||
|
||||
export const ModalRoot = findModuleChild(m => {
|
||||
if (typeof m !== "object") return undefined;
|
||||
for (let prop in m) {
|
||||
if (!m[prop]?.prototype?.OK && m[prop]?.prototype?.Cancel && m[prop]?.prototype?.render) {
|
||||
return m[prop];
|
||||
}
|
||||
}
|
||||
}) as FC<ModalRootProps>;
|
||||
Reference in New Issue
Block a user