add toasts & interface builder

This commit is contained in:
rhunk
2023-10-03 00:37:19 +02:00
committed by GitHub
parent 0f720667ee
commit ef7940cd60

View File

@@ -24,6 +24,10 @@ type("java.lang.System").out.println("Hello!") // prints "Hello!"
```js
logInfo(findClass("java.lang.System")) // prints "class java.lang.System"
```
- **longToast**/**shortToast**(message: String) show a toast on the screen
```js
longToast("Hello!")
```
## Execution sides
@@ -154,3 +158,78 @@ module.onSnapActivity = () => {
hookerUnhook();
}
```
## Interface builder
Allows to build dynamic interface in the manager
Create a menu:
```js
im.create("settings", builder => {
builder.text("Hello world!")
}
```
### Node
- setAttribute(key: String, value: Object) -> Node : set a custom attribute of the node
- padding(value: Integer) -> Node : set the padding of the node
- color(value: Integer) -> Node : set the color of the node
- fontSize(value: Integer) -> Node : set the font size of the node
- label(value: String) -> Node : set the label of the node
### enum Arrangement
start
end
top
bottom
center
spaceBetween
spaceAround
spaceEvenly
### enum Alignment
start
end
top
bottom
centerVertically
centerHorizontally
### RowColumnNode
- arrangement(value: Arrangement) -> RowColumnNode : set the arrangement of the node
- alignment(value: Alignment) -> RowColumnNode : set the alignment of the node
- spacedBy(value: Integer) -> RowColumnNode : set the spacing of the child nodes
### Builder functions:
- row(builderCallback) -> RowColumnNode: create a row
- column(builderCallback) -> RowColumnNode: create a column
- text(content: String) -> Node : create a text view
- switch(state: Boolean?, callback: (Boolean) -> Void) -> Node : create a switch node
- button(label: String, callback: () -> Void) : create a button
- slider(min: Int, max: Int, step: Int, value: Int, callback: (Integer) -> Void): create a integer slider
- onLaunched(callback) : Trigger callback when the menu appear on the screen
Example:
```js
im.create("settings", builder => {
builder.text("My Title").padding(10).color(0xff000000).fontSize(20)
builder.row(builder => {
var textView = builder.text("myValue : unknown")
builder.slider(0, 100, 50, 1, value => {
// set the textview value
textView.label("myValue : " + value)
})
}).spacedBy(10)
builder.row(builder => {
var mySwitchText = builder.text("mySwitch: unknown")
builder.switch(false, value => {
mySwitchText.label("mySwitch: " + switchValue)
})
}).arrangement("spaceBetween").alignment("centerVertically")
builder.onLaunched(() => {
longToast("menu shown!")
})
}
```