Files
Momentum-Firmware/applications/system/js_app/packages/create-fz-app/template/index.ts
Willy-JL bbe69e77c3 Initial JS CFW SDK changes
TODO: Check documentation and other package options

TODO: Transform CFW SDK name to OFW SDK name in build step so all firmwares understand it
2024-11-01 13:57:28 +00:00

31 lines
988 B
TypeScript

// import modules
// caution: `eventLoop` HAS to be imported before `gui`, and `gui` HAS to be
// imported before any `gui` submodules.
import * as eventLoop from "@next-flip/fz-sdk-mntm/event_loop";
import * as gui from "@next-flip/fz-sdk-mntm/gui";
import * as dialog from "@next-flip/fz-sdk-mntm/gui/dialog";
// a common pattern is to declare all the views that your app uses on one object
const views = {
dialog: dialog.makeWith({
header: "Hello from <app_name>",
text: "Check out index.ts and\nchange something :)",
center: "Gonna do that!",
}),
};
// stop app on center button press
eventLoop.subscribe(views.dialog.input, (_sub, button, eventLoop) => {
if (button === "center")
eventLoop.stop();
}, eventLoop);
// stop app on back button press
eventLoop.subscribe(gui.viewDispatcher.navigation, (_sub, _item, eventLoop) => {
eventLoop.stop();
}, eventLoop);
// run app
gui.viewDispatcher.switchTo(views.dialog);
eventLoop.run();