From e7b797c71706546f61a7386d1fa22698fc4e599d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B5=A9?= Date: Mon, 2 Jun 2025 16:51:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4=E9=99=90?= =?UTF-8?q?=E9=A2=9D=E6=96=87=E5=AD=97=E6=9C=AA=E8=B7=9F=E9=9A=8F=E6=B7=B1?= =?UTF-8?q?=E6=B5=85=E6=A8=A1=E5=BC=8F=E5=88=87=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈浩 --- .../pattern/form/form_pattern.cpp | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/frameworks/core/components_ng/pattern/form/form_pattern.cpp b/frameworks/core/components_ng/pattern/form/form_pattern.cpp index 44067bf5260..173c5eb1180 100644 --- a/frameworks/core/components_ng/pattern/form/form_pattern.cpp +++ b/frameworks/core/components_ng/pattern/form/form_pattern.cpp @@ -966,13 +966,24 @@ void FormPattern::UpdateTimeLimitFontCfg() CHECK_NULL_VOID(textNode); auto textLayoutProperty = textNode->GetLayoutProperty(); CHECK_NULL_VOID(textLayoutProperty); - + auto context = GetContext(); + CHECK_NULL_VOID(context); + auto isNeedUpdate = false; + auto currentColor = textLayoutProperty->GetTextColor(); + auto newColor = context->GetColorMode() == ColorMode::DARK ? Color(FONT_COLOR_DARK) : Color(FONT_COLOR_LIGHT); + if (currentColor != newColor) { + textLayoutProperty->UpdateTextColor(newColor); + isNeedUpdate = true; + } Dimension fontSize(GetTimeLimitFontSize()); if (!textLayoutProperty->GetFontSize().has_value() || !NearEqual(textLayoutProperty->GetFontSize().value(), fontSize)) { TAG_LOGD(AceLogTag::ACE_FORM, "bundleName = %{public}s, id: %{public}" PRId64 ", UpdateFontSize:%{public}f.", cardInfo_.bundleName.c_str(), cardInfo_.id, fontSize.Value()); textLayoutProperty->UpdateFontSize(fontSize); + isNeedUpdate = true; + } + if (isNeedUpdate) { textNode->MarkModifyDone(); textNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); } @@ -985,11 +996,17 @@ void FormPattern::UpdateAppLockCfg() auto imageLayoutProperty = node->GetLayoutProperty(); CHECK_NULL_VOID(imageLayoutProperty); auto sourceInfo = imageLayoutProperty->GetImageSourceInfo(); + CHECK_NULL_VOID(sourceInfo); auto currentColor = sourceInfo->GetFillColor(); - auto newColor = Container::CurrentColorMode() == ColorMode::DARK ? Color::WHITE : Color::BLACK; + auto context = GetContext(); + CHECK_NULL_VOID(context); + auto newColor = context->GetColorMode() == ColorMode::DARK ? Color::WHITE : Color::BLACK; if (currentColor != newColor) { sourceInfo->SetFillColor(newColor); imageLayoutProperty->UpdateImageSourceInfo(sourceInfo.value()); + auto imageRenderProperty = node->GetPaintProperty(); + CHECK_NULL_VOID(imageRenderProperty); + imageRenderProperty->UpdateSvgFillColor(newColor); node->MarkModifyDone(); node->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); } @@ -1225,8 +1242,14 @@ RefPtr FormPattern::CreateAppLockNode() CHECK_NULL_RETURN(imageLayoutProperty, nullptr); auto info = ImageSourceInfo(""); info.SetResourceId(InternalResource::ResourceId::APP_LOCK_SVG); - info.SetFillColor(Container::CurrentColorMode() == ColorMode::DARK ? Color::BLACK:Color::WHITE); + auto context = host->GetContext(); + CHECK_NULL_RETURN(context, nullptr); + auto newColor = context->GetColorMode() == ColorMode::DARK ? Color::WHITE : Color::BLACK; + info.SetFillColor(newColor); imageLayoutProperty->UpdateImageSourceInfo(info); + auto imageRenderProperty = imageNode->GetPaintProperty(); + CHECK_NULL_RETURN(imageRenderProperty, nullptr); + imageRenderProperty->UpdateSvgFillColor(newColor); CalcSize idealSize = { CalcLength(32, DimensionUnit::VP), CalcLength(32, DimensionUnit::VP) }; imageLayoutProperty->UpdateUserDefinedIdealSize(idealSize); auto externalContext = DynamicCast(imageNode->GetRenderContext()); -- Gitee