diff --git a/frameworks/core/components_ng/base/view_abstract_model_ng.cpp b/frameworks/core/components_ng/base/view_abstract_model_ng.cpp index ca1b4269d9f4077d0185a34eb8efc66efbba1471..0da0ccb6d2758789f0bbb52580183006ae10f584 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_ng.cpp +++ b/frameworks/core/components_ng/base/view_abstract_model_ng.cpp @@ -464,6 +464,17 @@ RefPtr ViewAbstractModelNG::GetSheetContext(NG::SheetStyle& she return context; } +void ViewAbstractModelNG::ApplyTheme2CustomNode(RefPtr customNode, int32_t themeId) +{ + auto theme = customNode->GetThemeScopeId(); + if (!theme) + { + // Update only if not set another value + customNode->AllowUseParentTheme(false); + customNode->UpdateThemeScopeId(themeId); + } +} + void ViewAbstractModelNG::BindSheet(bool isShow, std::function&& callback, std::function&& buildFunc, std::function&& titleBuildFunc, NG::SheetStyle& sheetStyle, std::function&& onAppear, std::function&& onDisappear, std::function&& shouldDismiss, @@ -480,20 +491,15 @@ void ViewAbstractModelNG::BindSheet(bool isShow, std::functionFinish(); - auto theme = customNode->GetThemeScopeId(); - if (!theme) { - // Update only if not set another value - customNode->AllowUseParentTheme(false); - customNode->UpdateThemeScopeId(themeId); - customNode->UpdateThemeScopeUpdate(themeId); - } + ApplyTheme2CustomNode(customNode, themeId); return customNode; }; - auto buildTitleNodeFunc = [titleBuildFunc, instanceId]() -> RefPtr { + auto buildTitleNodeFunc = [titleBuildFunc, instanceId, themeId]() -> RefPtr { CHECK_NULL_RETURN(titleBuildFunc, nullptr); NG::ScopedViewStackProcessor builderViewStackProcess(instanceId); titleBuildFunc(); auto customNode = NG::ViewStackProcessor::GetInstance()->Finish(); + ApplyTheme2CustomNode(customNode, themeId); return customNode; }; auto context = GetSheetContext(sheetStyle); diff --git a/frameworks/core/components_ng/base/view_abstract_model_ng.h b/frameworks/core/components_ng/base/view_abstract_model_ng.h index 95a7c614771e36428f8d7fefa5b6b4c4fa72365e..1e15024ae51f88dd17999631723a9518e83a2147 100755 --- a/frameworks/core/components_ng/base/view_abstract_model_ng.h +++ b/frameworks/core/components_ng/base/view_abstract_model_ng.h @@ -1514,6 +1514,8 @@ private: { ViewAbstract::SetOffsetLocalizedEdges(needLocalized); } + + static void ApplyTheme2CustomNode(RefPtr customNode, int32_t themeId); }; } // namespace OHOS::Ace::NG