Condition

You will find here the definition of Condition and more details about its attributes

What is it?

It is an action that has a boolean parameter and, according to the value, the action runs onTrue or onFalse.

AttributeTypeRequiredDefinition
conditionBoolean or BindingCondition to define which action will run.
onTrueList<Action>List of actions that it will be run when the condition is true.
onFalseList<Action>List of actions that it will be run when the condition is false.

How to use it?

The example below is a Container with a context that has a 18 value and the event onPress of the button is defined as an action with the Condition type, that verifies if the values is the same as 21 and shows an Alert depending on the context value.

Container(
    context = ContextData(
        id = "age",
        value = 18
    ),
    children = listOf(
        Button(
            text = "Is equal to 21?",
            onPress = listOf(
                Condition(
                     condition = "@{eq(age, 21)}",
                     onTrue = listOf(
                         Alert(message = "The condition is true")
                     ),
                     onFalse = listOf(
                         Alert(message = "The condition is false")
                     )

                )
            )
        )
    )
)