From 5eac3db8b019548214f2ebe35a4d04c48d976469 Mon Sep 17 00:00:00 2001 From: Hernand Azevedo Date: Fri, 11 Nov 2022 17:19:41 -0300 Subject: [PATCH] feat: Lazy Componentes childrenAsList (#40) * Fixes modal Signed-off-by: Hernand Azevedo * Removing shared flow Signed-off-by: Hernand Azevedo * Removing shared flow Signed-off-by: Hernand Azevedo * upgrading navigation-compose version to fix popToView crash Signed-off-by: Hernand Azevedo * upgrading navigation-compose version to fix popToView crash Signed-off-by: Hernand Azevedo * upgrades gradle wrapper Signed-off-by: Hernand Azevedo * Disable jacoco and sonar since its crashing with gradle 7.5.x until fixing Signed-off-by: Hernand Azevedo * Simplify navigation Signed-off-by: Hernand Azevedo * Fixes popTo first screen url Signed-off-by: Hernand Azevedo * Fixes modal Signed-off-by: Hernand Azevedo * Fixes modal Signed-off-by: Hernand Azevedo * Fixes modal Signed-off-by: Hernand Azevedo * Simplify modal Signed-off-by: Hernand Azevedo * Simplify modal 2 Signed-off-by: Hernand Azevedo * Simplify modal 3 Signed-off-by: Hernand Azevedo * Extract modal state Signed-off-by: Hernand Azevedo * Extract modal state Signed-off-by: Hernand Azevedo * Rafactor json name Signed-off-by: Hernand Azevedo * Mitigation of recomposition Signed-off-by: Hernand Azevedo * Refactor internal Signed-off-by: Hernand Azevedo * Lazy components childrenAsList Signed-off-by: Hernand Azevedo * Renaming file Signed-off-by: Hernand Azevedo Signed-off-by: Hernand Azevedo --- .../br/zup/com/nimbus/compose/ComponentData.kt | 1 + .../com/nimbus/compose/internal/RenderedNode.kt | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/compose/src/main/java/br/zup/com/nimbus/compose/ComponentData.kt b/compose/src/main/java/br/zup/com/nimbus/compose/ComponentData.kt index 948b6a4..2e6f91f 100644 --- a/compose/src/main/java/br/zup/com/nimbus/compose/ComponentData.kt +++ b/compose/src/main/java/br/zup/com/nimbus/compose/ComponentData.kt @@ -6,4 +6,5 @@ import com.zup.nimbus.core.tree.ServerDrivenNode class ComponentData( val node: ServerDrivenNode, val children: @Composable () -> Unit, + val childrenAsList: List<@Composable () -> Unit>, ) diff --git a/compose/src/main/java/br/zup/com/nimbus/compose/internal/RenderedNode.kt b/compose/src/main/java/br/zup/com/nimbus/compose/internal/RenderedNode.kt index dfa88dc..d72d7f0 100644 --- a/compose/src/main/java/br/zup/com/nimbus/compose/internal/RenderedNode.kt +++ b/compose/src/main/java/br/zup/com/nimbus/compose/internal/RenderedNode.kt @@ -42,7 +42,20 @@ fun RenderedNode(flow: NodeFlow) { children?.forEach { key(it.id) { RenderedNode(it) } } - } + }, + childrenAsList = childrenList(children) ) ) } + +fun childrenList(children: List?): List<@Composable () -> Unit> { + val mutableList = mutableListOf<@Composable () -> Unit>() + + children?.forEach { + mutableList.add { + key(it.id) { RenderedNode(it) } + } + } + + return mutableList +}