Operators | Example | Action |
---|---|---|
sum | sum(constant(1), constant(2)) | Sum operator for elements Int and Double. |
subtract | subtract(constant(2), constant(1)) | Subtraction operator for elements Int and Double. |
multiply | multiply(constant(2), constant(2)) | Multiplication operator for elements Int and Double. |
divide | divide(constant(10.0), constant(2.0)) | Division operator for elements Int and Double. |
The example below is a simples counter, where:
increment
and decrement
, has SetContext action.addition
and subtraction
, it increments and decreases the value of 1 to a text value, see below:fun screen() = Screen(
navigationBar = NavigationBar(
title = "Operations",
showBackButton = true
),
child = Container(
context = ContextData("counter", 2),
children = listOf(
Text(constant("Sum of 2 + 1 = ").plus(sum(constant(2), constant(1)).toBindString())),
Text(expressionOf("Counter: @{counter}")),
Container(
children = listOf(
Button(
text = "increment",
onPress = listOf(
SetContext("counter", "@{sum(counter, 1)}")
)
),
Button(
text = "decrement",
onPress = listOf(
SetContext("counter", "@{subtract(counter, 1)}")
)
)
)
)
)
)
)
}
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.