import {AbstractModal} from "tc-shared/ui/react-elements/modal/Definitions"; import {IpcRegistryDescription, Registry} from "tc-events"; import {ModalYesNoEvents, ModalYesNoVariables} from "tc-shared/ui/modal/yes-no/Definitions"; import {UiVariableConsumer} from "tc-shared/ui/utils/Variable"; import {createIpcUiVariableConsumer} from "tc-shared/ui/utils/IpcVariable"; import React from "react"; import {Translatable} from "tc-shared/ui/react-elements/i18n"; import {Button} from "tc-shared/ui/react-elements/Button"; const cssStyle = require("./Renderer.scss"); const QuestionRenderer = React.memo((props: { variables: UiVariableConsumer }) => { const question = props.variables.useReadOnly("question", undefined, undefined); return (
{question}
); }); const TitleRenderer = React.memo((props: { variables: UiVariableConsumer }) => { const title = props.variables.useReadOnly("title", undefined, undefined); if(typeof title !== "undefined") { return {title}; } else { return loading; } }); const TextYes = React.memo((props: { variables: UiVariableConsumer }) => { const text = props.variables.useReadOnly("textYes", undefined, undefined); if(typeof text !== "undefined") { return {text}; } else { return Yes; } }); const TextNo = React.memo((props: { variables: UiVariableConsumer }) => { const text = props.variables.useReadOnly("textNo", undefined, undefined); if(typeof text !== "undefined") { return {text}; } else { return No; } }); class Modal extends AbstractModal { private readonly events: Registry; private readonly variables: UiVariableConsumer; constructor(events: IpcRegistryDescription, variables: IpcRegistryDescription) { super(); this.events = Registry.fromIpcDescription(events); this.variables = createIpcUiVariableConsumer(variables); } protected onDestroy() { super.onDestroy(); this.events.destroy(); this.variables.destroy(); } color(): "none" | "blue" | "red" { return "red"; } renderBody(): React.ReactElement { return (
); } renderTitle(): string | React.ReactElement { return ( ); } } export default Modal;