[Epic] Modify the ScreenComponent contract
Closed this issue · 0 comments
Tiagoperes commented
The problem
Today, the ScreenComponent JSON doesn't make much sense. See the example below:
{
"_beagleComponent_": "beagle:screenComponent",
"navigationBar": {
"title": "Beagle NavigationBar",
"showBackButton": true,
"styleId": "DesignSystem.Navigationbar.Style.Default",
"navigationBarItems": [
{
"_beagleComponent_": "beagle:navigationBarItem",
"image": {
"_beagleImagePath_": "local",
"mobileId": "informationImage"
},
"action": {
"_beagleAction_": "beagle:alert",
"title": "NavigationBar",
"message": "This component that allows to place titles and button action.",
"labelOk": "OK"
},
"accessibility": {
"accessible": true,
"accessibilityLabel": "Content Description",
"isHeader": false
},
"id": "nbiInformation"
}
],
"backButtonAccessibility": {
"accessible": true,
"accessibilityLabel": "Voltar",
"isHeader": false
}
},
"child": {
"_beagleComponent_": "beagle:container"
}
}
- The component doesn't really represent a tree, since there are two children array for this component:
child
andnavigationBarItems
. - The
navigationBarItems
despite its resemblance with a component tree, is not really a component tree, the user can't include a "beagle:text", for instance. There must be only components of the type NavigationBarItem in this array. Because of this, it makes much more sense to receive a List of NavigationBarItem than a component tree. - The image inside a NavigationBarItem can only be a Local Image. For some reason, the current contract lets it be any type of Image, giving the impression Remote Images can also be used. To clear this confusion, it's better to accept only the mobile Id and never the
_beagleImagePath_
.
Solution
- Remove the component "beagle:navigationBarItem" from Beagle.
- Create the class NavigationBarItem without the fields
_beagleComponent_
andid
(not a component, just a class). - When creating the NavigationBarItem make sure it now accepts a String as the type of the parameter
image
and not anImagePath
. This string is equivalent to themobileId
of a local image. Attention:image
must accept expressions, i.e. it must be bindable. - Make NavigationBar.navigationItems a list of NavigationBarItem
- Render the components for the navigationItems inside the ScreenComponent.
Tasks
- Implement in Android
- Implement in iOS
- Implement in the backend
- Edit the documentation