mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-24 05:34:45 -07:00
[FL-3925, FL-3942, FL-3944] JS features & bugfixes (SDK 0.2) (#4075)
* feat: JS GPIO PWM, JS GUI Widget view; fix: JS EvtLoop stop on request, JS EvtLoop stop on error * fix: f18 build * docs: widget * fix: js unit test * change feature naming Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
66
applications/system/js_app/packages/fz-sdk/gui/widget.d.ts
vendored
Normal file
66
applications/system/js_app/packages/fz-sdk/gui/widget.d.ts
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Displays a combination of custom elements on one screen.
|
||||
*
|
||||
* <img src="../images/widget.png" width="200" alt="Sample screenshot of the view" />
|
||||
*
|
||||
* ```js
|
||||
* let eventLoop = require("event_loop");
|
||||
* let gui = require("gui");
|
||||
* let emptyView = require("gui/widget");
|
||||
* ```
|
||||
*
|
||||
* This module depends on the `gui` module, which in turn depends on the
|
||||
* `event_loop` module, so they _must_ be imported in this order. It is also
|
||||
* recommended to conceptualize these modules first before using this one.
|
||||
*
|
||||
* # Example
|
||||
* For an example refer to the GUI example.
|
||||
*
|
||||
* # View props
|
||||
* This view does not have any props.
|
||||
*
|
||||
* # Children
|
||||
* This view has the elements as its children.
|
||||
*
|
||||
* @version Added in JS SDK 0.2, extra feature `"gui-widget"`
|
||||
* @module
|
||||
*/
|
||||
|
||||
import type { View, ViewFactory } from ".";
|
||||
import type { IconData } from "./icon";
|
||||
import type { Contract } from "../event_loop";
|
||||
|
||||
type Position = { x: number, y: number };
|
||||
type Size = { w: number, h: number };
|
||||
type Alignment = { align: `${"t" | "c" | "b"}${"l" | "m" | "r"}` };
|
||||
type Font = { font: "primary" | "secondary" | "keyboard" | "big_numbers" };
|
||||
type Text = { text: string };
|
||||
|
||||
type StringMultilineElement = { element: "string_multiline" } & Position & Alignment & Font & Text;
|
||||
type StringElement = { element: "string" } & Position & Alignment & Font & Text;
|
||||
type TextBoxElement = { element: "text_box", stripToDots: boolean } & Position & Size & Alignment & Text;
|
||||
type TextScrollElement = { element: "text_scroll" } & Position & Size & Text;
|
||||
type ButtonElement = { element: "button", button: "left" | "center" | "right" } & Text;
|
||||
type IconElement = { element: "icon", iconData: IconData } & Position;
|
||||
type FrameElement = { element: "frame", radius: number } & Position & Size;
|
||||
|
||||
type Element = StringMultilineElement
|
||||
| StringElement
|
||||
| TextBoxElement
|
||||
| TextScrollElement
|
||||
| ButtonElement
|
||||
| IconElement
|
||||
| FrameElement;
|
||||
|
||||
type Props = {};
|
||||
type Child = Element;
|
||||
declare class Widget extends View<Props, Child> {
|
||||
/**
|
||||
* Event source for buttons. Only gets fired if there's a corresponding
|
||||
* button element.
|
||||
*/
|
||||
button: Contract<"left" | "center" | "right">;
|
||||
}
|
||||
declare class WidgetFactory extends ViewFactory<Props, Child, Widget> { }
|
||||
declare const factory: WidgetFactory;
|
||||
export = factory;
|
||||
Reference in New Issue
Block a user