From fabb40c8a7a23c7c578ac341dcccc5f7ceb0e877 Mon Sep 17 00:00:00 2001 From: Luke Zhao Date: Fri, 31 May 2024 11:17:14 -0700 Subject: [PATCH] Support renderOnly componentView --- .../Core/ComponentView/ComponentEngine.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Sources/UIComponent/Core/ComponentView/ComponentEngine.swift b/Sources/UIComponent/Core/ComponentView/ComponentEngine.swift index 1ac31b50..4a04a9a1 100644 --- a/Sources/UIComponent/Core/ComponentView/ComponentEngine.swift +++ b/Sources/UIComponent/Core/ComponentView/ComponentEngine.swift @@ -42,14 +42,14 @@ public class ComponentEngine { /// The current `RenderNode`. This is `nil` before the layout is done. var renderNode: (any RenderNode)? + /// Only render the renderNode, skipping layout. + var renderOnly: Bool = false + /// Internal state to track if a reload is needed. var needsReload = true /// Internal state to track if a render is needed. var needsRender = false - - /// Internal state to determine if the next layout should be skipped. - var skipNextLayout = false /// The number of times the view has been reloaded. var reloadCount = 0 @@ -180,8 +180,7 @@ public class ComponentEngine { } } - if skipNextLayout { - skipNextLayout = false + if renderOnly { adjustContentOffset(contentOffsetAdjustFn: contentOffsetAdjustFn) render(updateViews: true) } else if asyncLayout { @@ -376,6 +375,6 @@ public class ComponentEngine { public func reloadWithExisting(component: any Component, renderNode: any RenderNode) { self.component = component self.renderNode = renderNode - self.skipNextLayout = true + self.renderOnly = true } }