import React from "react"; import { observer } from "mobx-react"; import { IEezObject, PropertyProps } from "project-editor/core/object"; import { ProjectContext } from "project-editor/project/context"; import { Dialog, showDialog } from "eez-studio-ui/dialog"; import { Button } from "eez-studio-ui/button"; import { getProjectStore } from "project-editor/store"; import { LVGLPropertyInfo, lvglProperties, LVGLPropertiesGroup, isLvglStylePropertySupported } from "project-editor/lvgl/style-catalog"; import { SearchInput } from "eez-studio-ui/search-input"; import { action, makeObservable, observable } from "mobx"; import { IListNode, List, ListContainer, ListItem } from "eez-studio-ui/list"; //////////////////////////////////////////////////////////////////////////////// export const LVGLStylesExperimentalDefinitionProperty = observer( class LVGLStylesExperimentalDefinitionProperty extends React.Component { static contextType = ProjectContext; declare context: React.ContextType; showProperties = () => { selectLVGLStyleProperty(this.props.objects[0]); }; render() { return ( ); } } ); //////////////////////////////////////////////////////////////////////////////// async function selectLVGLStyleProperty(object: IEezObject) { let disposed = false; return new Promise((resolve, reject) => { const onDispose = () => { if (!disposed) { if (modalDialog) { modalDialog.close(); } disposed = true; } }; const onOk = (value: LVGLPropertyInfo) => { resolve(value); onDispose(); }; const [modalDialog] = showDialog( , { jsPanel: { id: "lvgl-style-properties", title: "Select LVGL style property", width: 600, height: 800 } } ); }); } //////////////////////////////////////////////////////////////////////////////// const LVGLStylePropertiesDialog = observer( class LVGLStylePropertiesDialog extends React.Component<{ onOk: (value: LVGLPropertyInfo) => void; onCancel: () => void; }> { static contextType = ProjectContext; declare context: React.ContextType; searchText: string = ""; constructor(props: any) { super(props); makeObservable(this, { searchText: observable, onSearchChange: action.bound }); } get nodes() { const nodes: IListNode[] = []; lvglProperties.forEach(propertyGroup => { nodes.push({ id: propertyGroup.groupName, label: `${propertyGroup.groupName}: ${propertyGroup.groupDescription}`, data: propertyGroup, selected: false }); propertyGroup.properties .filter(propertyInfo => isLvglStylePropertySupported( this.context.project, propertyInfo ) ) .forEach(property => { nodes.push({ id: property.name, label: `${property.displayName}: ${property.lvglStyleProp.description}`, data: property, selected: false }); }); }); return nodes; } onSearchChange(event: any) { this.searchText = ($(event.target).val() as string).trim(); } onOkEnabled = () => { return true; }; onOk = () => { this.props.onCancel(); return true; }; onDoubleClick = () => { this.onOk(); }; render() { return (
{ this.searchText = ""; })} onChange={this.onSearchChange} onKeyDown={this.onSearchChange} /> ) => { return ; }} selectNode={( node: IListNode< LVGLPropertiesGroup | LVGLPropertyInfo > ) => {}} >
); } } );