This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
How yoga works with beagle flutter
Today to use Yoga, we have the classes
YogaLayout (MultiChildWidgets)-> that is rendered by RenderYoga
YogaNode (single child widgets) -> That wraps the widgets to represent a leaf for the yoga tree.
The process is as following:
1- We need to create a yoga tree with all the widgets flex attributes (_attachNodesFromWidgetsHierarchy)
2- We need to call the nodeProperties.calculateLayout(maxWidth, maxHeight); on the root node.
3- Read the sizes and apply to the widgets with child.layout(childConstraints, parentUsesSize: true); (_applyLayoutToWidgetsHierarchy)
4- Set the size for the root node reading the width/height calculated by yoga.
The problem of recalculate layouts
When using a widget with yoga, if the size of the widget changes during the rendering we need to recalculate the yoga width/height . For that the current implementation is marking the nodeProperties as dirty and deleting the nodes to let the performLayout method inside the RenderYoga re-create the yoga tree
Current implementation in draft
#23
Below some screenshots of the current code working with image example without fixed sizes
Image starting to render starting with size 0
Image finishing to render and its size is calculated
Known issues for this implementation
The error is below
Currently if we have the example as it is on https://github.com/Orangestack-com/beagle-backend-kotlin/tree/feaeture/recalculate-layout it works. But if we wrap the bff code with one more BeagleContainer, for some reason the image is rendering small, need some more investigation to know if the BeagleContainer is not being recalculated, or the image is being calculated with small(older) BoxConstraints and its small because of that.
How to Configure for local development
Download yoga repository inside the beagle flutter's repository root folder for local development
Change beagle's pubspec .yaml to point to the local development yoga as following
yoga_engine:
path: ../yoga/flutter
[Beagle Flutter]
https://github.com/Orangestack-com/beagle-flutter
Yoga
https://github.com/ZupIT/yoga/tree/feature/recalculate-layout
[BFF]
https://github.com/Orangestack-com/beagle-backend-kotlin/tree/feaeture/recalculate-layout
yoga_engine:
path: ../yoga/flutter
[Beagle Flutter]
https://github.com/Orangestack-com/beagle-flutter
Yoga
https://github.com/ZupIT/yoga/tree/feature/recalculate-layout
[BFF]
https://github.com/Orangestack-com/beagle-backend-kotlin/tree/feaeture/recalculate-layout