mirror of
https://github.com/SnapEnhance/scripting-docs.git
synced 2026-08-30 20:24:23 +00:00
add toasts & interface builder
This commit is contained in:
79
SCRIPTING.md
79
SCRIPTING.md
@@ -24,6 +24,10 @@ type("java.lang.System").out.println("Hello!") // prints "Hello!"
|
|||||||
```js
|
```js
|
||||||
logInfo(findClass("java.lang.System")) // prints "class java.lang.System"
|
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
|
## Execution sides
|
||||||
@@ -154,3 +158,78 @@ module.onSnapActivity = () => {
|
|||||||
hookerUnhook();
|
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!")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user