mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
JS: Byte/Text Input fixes, gui example improvements
This commit is contained in:
@@ -8,6 +8,7 @@ let textInputView = require("gui/text_input");
|
||||
let byteInputView = require("gui/byte_input");
|
||||
let textBoxView = require("gui/text_box");
|
||||
let dialogView = require("gui/dialog");
|
||||
let flipper = require("flipper");
|
||||
|
||||
// declare view instances
|
||||
let views = {
|
||||
@@ -15,16 +16,18 @@ let views = {
|
||||
empty: emptyView.make(),
|
||||
keyboard: textInputView.makeWith({
|
||||
header: "Enter your name",
|
||||
defaultText: flipper.getName(),
|
||||
defaultTextClear: true,
|
||||
// Props for makeWith() are passed in reverse order, so maxLength must be after defaultText
|
||||
minLength: 0,
|
||||
maxLength: 32,
|
||||
}),
|
||||
helloDialog: dialogView.makeWith({
|
||||
center: "Hi Flipper! :)",
|
||||
}),
|
||||
helloDialog: dialogView.make(),
|
||||
bytekb: byteInputView.makeWith({
|
||||
header: "Look ma, I'm a header text!",
|
||||
length: 8,
|
||||
defaultData: Uint8Array([0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88]),
|
||||
// Props for makeWith() are passed in reverse order, so length must be after defaultData
|
||||
length: 8,
|
||||
}),
|
||||
longText: textBoxView.makeWith({
|
||||
text: "This is a very long string that demonstrates the TextBox view. Use the D-Pad to scroll backwards and forwards.\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse rhoncus est malesuada quam egestas ultrices. Maecenas non eros a nulla eleifend vulputate et ut risus. Quisque in mauris mattis, venenatis risus eget, aliquam diam. Fusce pretium feugiat mauris, ut faucibus ex volutpat in. Phasellus volutpat ex sed gravida consectetur. Aliquam sed lectus feugiat, tristique lectus et, bibendum lacus. Ut sit amet augue eu sapien elementum aliquam quis vitae tortor. Vestibulum quis commodo odio. In elementum fermentum massa, eu pellentesque nibh cursus at. Integer eleifend lacus nec purus elementum sodales. Nulla elementum neque urna, non vulputate massa semper sed. Fusce ut nisi vitae dui blandit congue pretium vitae turpis.",
|
||||
@@ -67,6 +70,7 @@ eventLoop.subscribe(views.demos.chosen, function (_sub, index, gui, eventLoop, v
|
||||
// say hi after keyboard input
|
||||
eventLoop.subscribe(views.keyboard.input, function (_sub, name, gui, views) {
|
||||
views.helloDialog.set("text", "Hi " + name + "! :)");
|
||||
views.helloDialog.set("center", "Hi Flipper! :)");
|
||||
gui.viewDispatcher.switchTo(views.helloDialog);
|
||||
}, gui, views);
|
||||
|
||||
@@ -83,7 +87,8 @@ eventLoop.subscribe(views.bytekb.input, function (_sub, data, gui, views) {
|
||||
for (let i = 0; i < data_view.length; i++) {
|
||||
text += toString(data_view[i], 16);
|
||||
}
|
||||
views.helloDialog.set("text", "You typed " + text + "! :)");
|
||||
views.helloDialog.set("text", "You typed:\n" + text);
|
||||
views.helloDialog.set("center", "Cool!");
|
||||
gui.viewDispatcher.switchTo(views.helloDialog);
|
||||
}, gui, views);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user