From d15b47419456c411aac89fd22b4f17c6475aeb16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ruifanyuan=28=E8=A2=81=E7=91=9E=E7=B9=81=29?= Date: Thu, 19 Oct 2023 19:22:22 +0800 Subject: [PATCH] fix(ios): fix modal view layout issue --- .../component/modal/NativeRenderModalHostViewManager.mm | 6 ++++++ .../ios/renderer/component/view/HippyShadowView.mm | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/renderer/native/ios/renderer/component/modal/NativeRenderModalHostViewManager.mm b/renderer/native/ios/renderer/component/modal/NativeRenderModalHostViewManager.mm index 1edc7e129bc..075ed802fa4 100644 --- a/renderer/native/ios/renderer/component/modal/NativeRenderModalHostViewManager.mm +++ b/renderer/native/ios/renderer/component/modal/NativeRenderModalHostViewManager.mm @@ -33,6 +33,12 @@ @interface NativeRenderObjectModalHost : HippyShadowView @implementation NativeRenderObjectModalHost +- (void)insertNativeRenderSubview:(NativeRenderObjectView *)subview atIndex:(NSInteger)atIndex{ + [super insertNativeRenderSubview:subview atIndex:atIndex]; + CGRect frame = { .origin = CGPointZero, .size = NativeRenderScreenSize() }; + [subview setLayoutFrame:frame]; +} + - (void)setDomManager:(std::weak_ptr)domManager { [super setDomManager:domManager]; CGRect frame = { .origin = CGPointZero, .size = NativeRenderScreenSize() }; diff --git a/renderer/native/ios/renderer/component/view/HippyShadowView.mm b/renderer/native/ios/renderer/component/view/HippyShadowView.mm index 42e59869d60..712a090958a 100644 --- a/renderer/native/ios/renderer/component/view/HippyShadowView.mm +++ b/renderer/native/ios/renderer/component/view/HippyShadowView.mm @@ -343,13 +343,14 @@ - (void)setLayoutFrame:(CGRect)frame dirtyPropagation:(BOOL)dirtyPropagation { node->SetLayoutSize(frame.size.width, frame.size.height); std::vector> changed_nodes; node->DoLayout(changed_nodes); - if (!changed_nodes.empty()) { - renderManager->UpdateLayout(strongSelf.rootNode, changed_nodes); - } if (dirtyPropagation) { [strongSelf dirtyPropagation:NativeRenderUpdateLifecycleLayoutDirtied]; } - renderManager->EndBatch(strongSelf.rootNode); + if (!changed_nodes.empty()) { + if(auto renderManager = domManager->GetRenderManager().lock()){ + renderManager->UpdateLayout(strongSelf.rootNode, changed_nodes); + } + } } }}; domManager->PostTask(hippy::dom::Scene(std::move(ops)));