From 61717ca606a5940eee83eb711017104701c4c093 Mon Sep 17 00:00:00 2001 From: kseniakukushkina_c098 Date: Thu, 14 Nov 2024 13:06:18 +0300 Subject: [PATCH] adding theme color into json --- .../pattern/counter/counter_layout_property.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frameworks/core/components_ng/pattern/counter/counter_layout_property.h b/frameworks/core/components_ng/pattern/counter/counter_layout_property.h index 2bd6db9550f9..e64972f500dd 100644 --- a/frameworks/core/components_ng/pattern/counter/counter_layout_property.h +++ b/frameworks/core/components_ng/pattern/counter/counter_layout_property.h @@ -20,6 +20,7 @@ #include "core/components_ng/layout/layout_property.h" #include "core/components_ng/pattern/linear_layout/linear_layout_property.h" #include "core/components_ng/property/property.h" +#include "core/components/counter/counter_theme.h" namespace OHOS::Ace::NG { class ACE_EXPORT CounterLayoutProperty : public LinearLayoutProperty { @@ -47,6 +48,20 @@ public: ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(TextColorForeground, Color, PROPERTY_UPDATE_MEASURE); ACE_DISALLOW_COPY_AND_MOVE(CounterLayoutProperty); + + void ToJsonValue(std::unique_ptr& json, const InspectorFilter& filter) const override { + LayoutProperty::ToJsonValue(json, filter); + /* no fixed attr below, just return */ + if (filter.IsFastFilter()) { + return; + } + auto context = PipelineBase::GetCurrentContext(); + auto host = GetHost(); + CHECK_NULL_VOID(host); + auto theme = context ? context->GetTheme(host->GetThemeScopeId()) : nullptr; + auto defaultForegroundColor = theme ? theme->GetContentTextStyle().GetTextColor() : Color::BLACK; + json->PutExtAttr("foregroundColor", GetTextColorForeground().value_or(defaultForegroundColor).ToString().c_str(), filter); + } }; } -- Gitee