Compose

1. Create your ComponentPropertyClass with properties that you need

  • In this example i used checkbox component

⚠️ Warning: Here we have some points to consider To avoid unnecessary recompositions at your component. We recommend use the @Immutable and @Stable annotations in your properties. More about it below

  • @immutable: This guarantee the composition optimization based on the assumption that values read from the type will not change.

  • @stable: this is used to communicate some guarantees to the compose compiler about how a certain type or function will behave and keep the compose compiler notified about changes

@JsonIgnoreProperties(ignoreUnknown = true)
@Immutable
@Stable
data class CheckBoxProperties(
    @JsonProperty("text") val text: String? = null,
    ... define your properties here
)

2. Add your Component json object in Dymanic.json

{
    "key": "CraftDCheckBox",
    "value": {
     ... define your properties here
     }
 }
  

3. Create your Component

:memo: Note: Your composable component must have three properties.

  • componentProperties: The mapped properties from json

  • modifier: Default for composable componets

  • behaviour: This make reference to the component's behaviour, for example: onclick -> for buttons, onchange -> for checkbox etc...

4. Create your Component Builder

:memo: Note: This Builder must extend CraftBuilder Class and override craft method.

5. In your screen you can add the builder inside of CraftBuilderManager

So now enjoy your component!!!

Last updated