Counter
This example shows how to create an app with a counter.
class MyApp extends App{
counter = 0
createStartPage(){
return CounterPage
}
incrementCounter(){
a.counter += 1
}
decrementCounter(){
a.counter -= 1
}
resetCounter(){
a.counter = 0
}
}
class CounterPage extends Page{
createGui(){
return Rows.children(
Text.text(`${a.counter}`).grow(1),
Columns.grow(1).children(
Rows.grow(1).children(
Button.text(`-`).grow(1).onClick(a.decrementCounter),
Button.text(`Reset`).grow(1).onClick(a.resetCounter),
),
Button.text(`+`).grow(1).onClick(a.incrementCounter),
),
)
}
}