diff --git a/frameworks/bridge/declarative_frontend/ark_theme/theme_apply/js_text_picker_theme.h b/frameworks/bridge/declarative_frontend/ark_theme/theme_apply/js_text_picker_theme.h deleted file mode 100644 index c6a0e83d3ea84e70a4ae3ab0df3f63b5d88998fd..0000000000000000000000000000000000000000 --- a/frameworks/bridge/declarative_frontend/ark_theme/theme_apply/js_text_picker_theme.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_THEME_JS_TEXTPICKER_THEME_H -#define FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_THEME_JS_TEXTPICKER_THEME_H - -#include "bridge/declarative_frontend/ark_theme/theme_apply/js_theme_utils.h" -#include "bridge/declarative_frontend/jsview/js_view_abstract.h" -#include "core/components_ng/base/view_abstract_model.h" -#include "core/components_ng/base/view_stack_model.h" -#include "core/components_ng/pattern/text_picker/textpicker_model.h" - -namespace OHOS::Ace::Framework { -class JSTextPickerTheme { -public: - static void ApplyTheme() - { - auto themePicker = JSViewAbstract::GetTheme(); - CHECK_NULL_VOID(themePicker); - auto themeColors = JSThemeUtils::GetThemeColors(); - if (!themeColors) { - return; - } - NG::PickerTextStyle textStyle; - auto selectedStyle = themePicker->GetOptionStyle(true, false); - textStyle.textColor = themeColors.value().FontEmphasize(); - textStyle.fontSize = selectedStyle.GetFontSize(); - textStyle.fontWeight = selectedStyle.GetFontWeight(); - TextPickerModel::GetInstance()->SetSelectedTextStyle(themePicker, textStyle); - - auto disappearStyle = themePicker->GetDisappearOptionStyle(); - textStyle.textColor = themeColors.value().FontPrimary(); - textStyle.fontSize = disappearStyle.GetFontSize(); - textStyle.fontWeight = disappearStyle.GetFontWeight(); - TextPickerModel::GetInstance()->SetDisappearTextStyle(themePicker, textStyle); - - auto normalStyle = themePicker->GetOptionStyle(false, false); - textStyle.textColor = themeColors.value().FontPrimary(); - textStyle.fontSize = normalStyle.GetFontSize(); - textStyle.fontWeight = normalStyle.GetFontWeight(); - TextPickerModel::GetInstance()->SetNormalTextStyle(themePicker, textStyle); - - auto targetNode = NG::ViewStackProcessor::GetInstance()->GetMainFrameNode(); - CHECK_NULL_VOID(targetNode); - targetNode->MarkModifyDone(); - } - - static bool ObtainSelectedTextStyle(NG::PickerTextStyle& textStyle) - { - if (auto themeColors = JSThemeUtils::GetThemeColors(); themeColors.has_value()) { - textStyle.textColor = themeColors.value().FontEmphasize(); - return true; - } - return false; - } - - static bool ObtainTextStyle(NG::PickerTextStyle& textStyle) - { - if (auto themeColors = JSThemeUtils::GetThemeColors(); themeColors.has_value()) { - textStyle.textColor = themeColors.value().FontPrimary(); - return true; - } - return false; - } -}; -} // namespace OHOS::Ace::Framework -#endif // FRAMEWORKS_BRIDGE_DECLARATIVE_FRONTEND_THEME_JS_TEXTPICKER_THEME_H diff --git a/frameworks/bridge/declarative_frontend/ark_theme/theme_manager/src/theme/ArkThemeWhiteList.ts b/frameworks/bridge/declarative_frontend/ark_theme/theme_manager/src/theme/ArkThemeWhiteList.ts index 73469ec31f9e72b1cb8dbb2fcf2df1ba99f941bc..1d55795a1b8bc171ae908fb9de032b243937696c 100644 --- a/frameworks/bridge/declarative_frontend/ark_theme/theme_manager/src/theme/ArkThemeWhiteList.ts +++ b/frameworks/bridge/declarative_frontend/ark_theme/theme_manager/src/theme/ArkThemeWhiteList.ts @@ -28,7 +28,6 @@ class ArkThemeWhiteList { 'MenuItem', 'Search', 'Select', - 'TextPicker', 'TimePicker', 'Toggle', ]; diff --git a/frameworks/bridge/declarative_frontend/engine/arkTheme.js b/frameworks/bridge/declarative_frontend/engine/arkTheme.js index 424742e1d3c908509554af60ff3cb9f55e3a29d5..6181797909fe1d0537094a592d12f309460bf97e 100644 --- a/frameworks/bridge/declarative_frontend/engine/arkTheme.js +++ b/frameworks/bridge/declarative_frontend/engine/arkTheme.js @@ -1082,7 +1082,6 @@ ArkThemeWhiteList.whiteList = [ 'MenuItem', 'Search', 'Select', - 'TextPicker', 'TimePicker', 'Toggle', ]; diff --git a/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp b/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp index 17eed4049e6dbcced44f9342d4b8f0f3be48d98a..da4bf86ced8b730a678293d7634cc9fbad3ecc3b 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_textpicker.cpp @@ -20,7 +20,6 @@ #include "base/log/ace_scoring_log.h" #include "bridge/common/utils/engine_helper.h" -#include "bridge/declarative_frontend/ark_theme/theme_apply/js_text_picker_theme.h" #include "bridge/declarative_frontend/engine/functions/js_function.h" #include "bridge/declarative_frontend/jsview/js_datepicker.h" #include "bridge/declarative_frontend/jsview/js_interactable_view.h" @@ -370,7 +369,6 @@ void JSTextPicker::Create(const JSCallbackInfo& info) if (param.selectedChangeEventVal->IsFunction()) { ParseTextPickerSelectedObject(info, param.selectedChangeEventVal); } - JSTextPickerTheme::ApplyTheme(); } } @@ -986,10 +984,11 @@ void JSTextPicker::SetDisappearTextStyle(const JSCallbackInfo& info) auto theme = GetTheme(); CHECK_NULL_VOID(theme); NG::PickerTextStyle textStyle; - JSTextPickerTheme::ObtainTextStyle(textStyle); - if (info[0]->IsObject()) { - JSTextPickerParser::ParseTextStyle(info[0], textStyle, "disappearTextStyle"); + if (!info[0]->IsObject()) { + TextPickerModel::GetInstance()->ResetDisappearTextStyle(); + return; } + JSTextPickerParser::ParseTextStyle(info[0], textStyle, "disappearTextStyle"); TextPickerModel::GetInstance()->SetDisappearTextStyle(theme, textStyle); } @@ -998,10 +997,11 @@ void JSTextPicker::SetTextStyle(const JSCallbackInfo& info) auto theme = GetTheme(); CHECK_NULL_VOID(theme); NG::PickerTextStyle textStyle; - JSTextPickerTheme::ObtainTextStyle(textStyle); - if (info[0]->IsObject()) { - JSTextPickerParser::ParseTextStyle(info[0], textStyle, "textStyle"); + if (!info[0]->IsObject()) { + TextPickerModel::GetInstance()->ResetTextStyle(); + return; } + JSTextPickerParser::ParseTextStyle(info[0], textStyle, "textStyle"); TextPickerModel::GetInstance()->SetNormalTextStyle(theme, textStyle); } @@ -1010,10 +1010,11 @@ void JSTextPicker::SetSelectedTextStyle(const JSCallbackInfo& info) auto theme = GetTheme(); CHECK_NULL_VOID(theme); NG::PickerTextStyle textStyle; - JSTextPickerTheme::ObtainSelectedTextStyle(textStyle); - if (info[0]->IsObject()) { - JSTextPickerParser::ParseTextStyle(info[0], textStyle, "selectedTextStyle"); + if (!info[0]->IsObject()) { + TextPickerModel::GetInstance()->ResetSelectedTextStyle(); + return; } + JSTextPickerParser::ParseTextStyle(info[0], textStyle, "selectedTextStyle"); TextPickerModel::GetInstance()->SetSelectedTextStyle(theme, textStyle); } diff --git a/frameworks/bridge/declarative_frontend/jsview/models/textpicker_model_impl.h b/frameworks/bridge/declarative_frontend/jsview/models/textpicker_model_impl.h index 761e51cc41bd97547e40dc6e099e2c7e43fe9d2b..0eeb593049d8a4247e88a8c97c68a774a002d7cb 100644 --- a/frameworks/bridge/declarative_frontend/jsview/models/textpicker_model_impl.h +++ b/frameworks/bridge/declarative_frontend/jsview/models/textpicker_model_impl.h @@ -74,6 +74,9 @@ public: { return true; } + void ResetTextStyle() override {}; + void ResetDisappearTextStyle() override {}; + void ResetSelectedTextStyle() override{}; }; class ACE_EXPORT TextPickerDialogModelImpl : public TextPickerDialogModel { diff --git a/frameworks/core/components/picker/picker_theme.h b/frameworks/core/components/picker/picker_theme.h index 296e23b9719d16dfce1bc2fd72894db9437a62bb..dbeb578ca7668b7dfb65308b2a466a2619b599bc 100644 --- a/frameworks/core/components/picker/picker_theme.h +++ b/frameworks/core/components/picker/picker_theme.h @@ -34,11 +34,11 @@ namespace { constexpr Dimension DIVIDER_THICKNESS = 1.0_px; } // namespace -class PickerTheme final : public virtual Theme { +class PickerTheme : public virtual Theme { DECLARE_ACE_TYPE(PickerTheme, Theme); public: - class Builder final { + class Builder { public: Builder() = default; ~Builder() = default; @@ -141,6 +141,7 @@ public: } } +protected: void InitializeTextStyles(const RefPtr& theme, const RefPtr& themeStyle) const { InitializeItemTextStyles(theme, themeStyle); @@ -507,8 +508,14 @@ public: { return pickerDialogMaxThirdFontScale_; } + +protected: + PickerTheme() = default; + TextStyle selectedOptionStyle_; + TextStyle normalOptionStyle_; + TextStyle disappearOptionStyle_; private: - PickerTheme() = default; + Color focusColor_; Color hoverColor_; @@ -530,9 +537,6 @@ private: // text style TextStyle focusOptionStyle_; - TextStyle selectedOptionStyle_; - TextStyle normalOptionStyle_; - TextStyle disappearOptionStyle_; TextStyle buttonStyle_; TextStyle titleStyle_; diff --git a/frameworks/core/components/theme/theme_manager_impl.cpp b/frameworks/core/components/theme/theme_manager_impl.cpp index 392b0fc6bce4795255e94fbfffb6fc10c89ba88d..28ae7c1271b14d46d62ab554b3c8e1dab3f95fc4 100644 --- a/frameworks/core/components/theme/theme_manager_impl.cpp +++ b/frameworks/core/components/theme/theme_manager_impl.cpp @@ -87,6 +87,7 @@ #include "core/components_ng/pattern/swiper/swiper_theme_wrapper.h" #include "core/components_ng/pattern/text/text_theme_wrapper.h" #include "core/components_ng/pattern/text_field/text_field_theme_wrapper.h" +#include "core/components_ng/pattern/picker/picker_theme_wrapper.h" #include "core/components_ng/token_theme/token_theme_storage.h" namespace OHOS::Ace { @@ -183,7 +184,8 @@ const std::unordered_map(*)(const RefPt { SliderTheme::TypeId(), &ThemeWrapperBuildFunc }, { SwiperIndicatorTheme::TypeId(), &ThemeWrapperBuildFunc }, { TextTheme::TypeId(), &ThemeWrapperBuildFunc }, - { TextFieldTheme::TypeId(), &ThemeWrapperBuildFunc } + { TextFieldTheme::TypeId(), &ThemeWrapperBuildFunc }, + { PickerTheme::TypeId(), &ThemeWrapperBuildFunc } }; } // namespace diff --git a/frameworks/core/components_ng/pattern/picker/picker_theme_wrapper.h b/frameworks/core/components_ng/pattern/picker/picker_theme_wrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..d29d5d677f38a24c62fe02954aa54311b9fb2b64 --- /dev/null +++ b/frameworks/core/components_ng/pattern/picker/picker_theme_wrapper.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_PICKER_PICKER_THEME_WRAPPER_H +#define FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_PICKER_PICKER_THEME_WRAPPER_H + +#include "core/components/picker/picker_theme.h" +#include "core/components_ng/token_theme/token_theme_wrapper.h" + +namespace OHOS::Ace::NG { + +class PickerThemeWrapper : public PickerTheme, public TokenThemeWrapper +{ + DECLARE_ACE_TYPE(PickerThemeWrapper, PickerTheme); + +public: + class WrapperBuilder : public Builder + { + public: + WrapperBuilder() = default; + ~WrapperBuilder() = default; + + RefPtr BuildWrapper(const RefPtr& themeConstants) const + { + auto themeWrapper = AceType::Claim(new PickerThemeWrapper()); + auto theme = AceType::DynamicCast(themeWrapper); + if (!themeConstants) { + return themeWrapper; + } + auto themeStyle = themeConstants->GetThemeStyle(); + if(!themeStyle) { + return themeWrapper; + } + InitializeTextStyles(theme, themeStyle); + return themeWrapper; + } + }; + + ~PickerThemeWrapper() override = default; + + void ApplyTokenTheme(const TokenTheme& theme) override + { + if (auto colors = theme.Colors(); colors) { + selectedOptionStyle_.SetTextColor(colors->FontEmphasize()); + normalOptionStyle_.SetTextColor(colors->FontPrimary()); + disappearOptionStyle_.SetTextColor(colors->FontPrimary()); + } + } + +protected: + PickerThemeWrapper() = default; + +}; + +} // namespace OHOS::Ace::NG +#endif // FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_PICKER_PICKER_THEME_WRAPPER_H \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_column_pattern.cpp b/frameworks/core/components_ng/pattern/text_picker/textpicker_column_pattern.cpp index c4141306bd6992a170198ff0df5c6e9a63399ad6..53c5eadc212bf94c09c4586db95f682c75a1297c 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_column_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_column_pattern.cpp @@ -825,7 +825,7 @@ void TextPickerColumnPattern::UpdatePickerTextProperties(const RefPtrGetContext(); CHECK_NULL_VOID(context); - auto pickerTheme = context->GetTheme(); + auto pickerTheme = context->GetTheme(host->GetThemeScopeId()); CHECK_NULL_VOID(pickerTheme); if (currentIndex == middleIndex) { UpdateSelectedTextProperties(pickerTheme, textLayoutProperty, textPickerLayoutProperty); diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_layout_property.h b/frameworks/core/components_ng/pattern/text_picker/textpicker_layout_property.h index fd19a346e04cc3edefc99e9627f725cd4dc4af4c..690f464d6052329920a8b8a40e8b66fb9a36970b 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_layout_property.h +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_layout_property.h @@ -117,12 +117,20 @@ public: } json->PutExtAttr("values", jsonArrayValue, filter); + auto host = GetHost(); + auto themeScopeId = host ? host->GetThemeScopeId() : 0; + auto pipelineContext = PipelineContext::GetCurrentContext(); + auto theme = pipelineContext->GetTheme(themeScopeId); + auto disappearColor = theme ? theme->GetDisappearOptionStyle().GetTextColor() : Color::BLACK; + auto selectedColor = theme ? theme->GetOptionStyle(true,false).GetTextColor() : Color::BLACK; + auto normalColor = theme ? theme->GetOptionStyle(false,false).GetTextColor() : Color::BLACK; + auto disappearFont = JsonUtil::Create(true); disappearFont->Put("size", GetDisappearFontSizeValue(Dimension(0)).ToString().c_str()); disappearFont->Put("weight", V2::ConvertWrapFontWeightToStirng( GetDisappearWeight().value_or(FontWeight::NORMAL)).c_str()); auto disappearTextStyle = JsonUtil::Create(true); - disappearTextStyle->Put("color", GetDisappearColor().value_or(Color::BLACK).ColorToString().c_str()); + disappearTextStyle->Put("color", GetDisappearColor().value_or(disappearColor).ColorToString().c_str()); disappearTextStyle->Put("font", disappearFont); json->PutExtAttr("disappearTextStyle", disappearTextStyle, filter); @@ -130,7 +138,7 @@ public: normalFont->Put("size", GetFontSizeValue(Dimension(0)).ToString().c_str()); normalFont->Put("weight", V2::ConvertWrapFontWeightToStirng(GetWeight().value_or(FontWeight::NORMAL)).c_str()); auto normalTextStyle = JsonUtil::Create(true); - normalTextStyle->Put("color", GetColor().value_or(Color::BLACK).ColorToString().c_str()); + normalTextStyle->Put("color", GetColor().value_or(normalColor).ColorToString().c_str()); normalTextStyle->Put("font", normalFont); json->PutExtAttr("textStyle", normalTextStyle, filter); @@ -139,7 +147,7 @@ public: selectedFont->Put("weight", V2::ConvertWrapFontWeightToStirng( GetSelectedWeight().value_or(FontWeight::NORMAL)).c_str()); auto selectedTextStyle = JsonUtil::Create(true); - selectedTextStyle->Put("color", GetSelectedColor().value_or(Color::BLACK).ColorToString().c_str()); + selectedTextStyle->Put("color", GetSelectedColor().value_or(selectedColor).ColorToString().c_str()); selectedTextStyle->Put("font", selectedFont); json->PutExtAttr("selectedTextStyle", selectedTextStyle, filter); auto canLoop = GetCanLoopValue(); diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_model.h b/frameworks/core/components_ng/pattern/text_picker/textpicker_model.h index bd44a319a4abf7f78413155dfca04f0feb31ef7f..9dcd13e9b4654651933a79f506d3d521d9f49d23 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_model.h +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_model.h @@ -87,6 +87,9 @@ public: virtual bool GetSingleRange() = 0; virtual void SetDivider(const NG::ItemDivider& divider) {}; virtual void HasUserDefinedOpacity() = 0; + virtual void ResetTextStyle() {}; + virtual void ResetDisappearTextStyle() {}; + virtual void ResetSelectedTextStyle() {}; private: static std::unique_ptr textPickerInstance_; diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.cpp b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.cpp index 94614a171eb05d4e0fe64513e54352ff745b5e07..106478b790edd94c96fbcdd79e0b2e8d2a547168 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.cpp @@ -397,7 +397,7 @@ PickerTextStyle TextPickerModelNG::getDisappearTextStyle(FrameNode* frameNode) CHECK_NULL_RETURN(frameNode, pickerTextStyle); auto context = frameNode->GetContext(); CHECK_NULL_RETURN(context, pickerTextStyle); - auto theme = context->GetTheme(); + auto theme = context->GetTheme(frameNode->GetThemeScopeId()); CHECK_NULL_RETURN(theme, pickerTextStyle); auto style = theme->GetDisappearOptionStyle(); ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE( @@ -420,7 +420,7 @@ PickerTextStyle TextPickerModelNG::getNormalTextStyle(FrameNode* frameNode) CHECK_NULL_RETURN(frameNode, pickerTextStyle); auto context = frameNode->GetContext(); CHECK_NULL_RETURN(context, pickerTextStyle); - auto theme = context->GetTheme(); + auto theme = context->GetTheme(frameNode->GetThemeScopeId()); CHECK_NULL_RETURN(theme, pickerTextStyle); auto style = theme->GetOptionStyle(false, false); ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE( @@ -443,7 +443,7 @@ PickerTextStyle TextPickerModelNG::getSelectedTextStyle(FrameNode* frameNode) CHECK_NULL_RETURN(frameNode, pickerTextStyle); auto context = frameNode->GetContext(); CHECK_NULL_RETURN(context, pickerTextStyle); - auto theme = context->GetTheme(); + auto theme = context->GetTheme(frameNode->GetThemeScopeId()); CHECK_NULL_RETURN(theme, pickerTextStyle); auto style = theme->GetOptionStyle(true, false); ACE_GET_NODE_LAYOUT_PROPERTY_WITH_DEFAULT_VALUE( @@ -1230,4 +1230,15 @@ void TextPickerModelNG::HasUserDefinedOpacity() textPickerPattern->SetUserDefinedOpacity(renderContext->GetOpacityValue(1.0)); } +void TextPickerModelNG::ResetTextStyle(){ + ACE_RESET_PAINT_PROPERTY_WITH_FLAG(TextPickerLayoutProperty, TextStyle, PROPERTY_UPDATE_RENDER); +} + +void TextPickerModelNG::ResetSelectedTextStyle(){ + ACE_RESET_PAINT_PROPERTY_WITH_FLAG(TextPickerLayoutProperty, SelectedTextStyle, PROPERTY_UPDATE_RENDER); +} +void TextPickerModelNG::ResetDisappearTextStyle(){ + ACE_RESET_PAINT_PROPERTY_WITH_FLAG(TextPickerLayoutProperty, DisappearTextStyle, PROPERTY_UPDATE_RENDER); +} + } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.h b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.h index 3a3ae88a6f9251ed660db7dbdee4a2a1f4b7fb2b..331548a1352284617c09fc857bd52753b4fdb975 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.h +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_ng.h @@ -89,6 +89,9 @@ public: void SetOnSelectedChangeEvent(TextCascadeSelectedChangeEvent&& onChange) override; void SetDivider(const ItemDivider& divider) override; void HasUserDefinedOpacity() override; + void ResetTextStyle() override; + void ResetDisappearTextStyle() override; + void ResetSelectedTextStyle() override; static void SetCanLoop(FrameNode* frameNode, const bool value); static void SetSelected(FrameNode* frameNode, uint32_t value); diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_pattern.cpp b/frameworks/core/components_ng/pattern/text_picker/textpicker_pattern.cpp index f9fd92e015635c706771289367665c47bd946606..9853d87a329d83b1978f1405691bea85a5f221cb 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_pattern.cpp @@ -1047,7 +1047,7 @@ void TextPickerPattern::OnColorConfigurationUpdate() host->SetNeedCallChildrenUpdate(false); auto context = host->GetContext(); CHECK_NULL_VOID(context); - auto pickerTheme = context->GetTheme(); + auto pickerTheme = context->GetTheme(host->GetThemeScopeId()); CHECK_NULL_VOID(pickerTheme); auto disappearStyle = pickerTheme->GetDisappearOptionStyle(); auto normalStyle = pickerTheme->GetOptionStyle(false, false); @@ -1077,6 +1077,24 @@ void TextPickerPattern::OnColorConfigurationUpdate() host->MarkModifyDone(); } +bool TextPickerPattern::OnThemeScopeUpdate(int32_t themeScopeId) +{ + bool result = false; + auto host = GetHost(); + CHECK_NULL_RETURN(host,result); + auto pipeline = PipelineBase::GetCurrentContext(); + CHECK_NULL_RETURN(pipeline, result); + auto pickerTheme = pipeline->GetTheme(themeScopeId); + CHECK_NULL_RETURN(pickerTheme, result); + + auto pickerProperty = host->GetLayoutProperty(); + CHECK_NULL_RETURN(pickerProperty,result); + result = !pickerProperty->HasDisappearColor()|| + !pickerProperty->HasColor()|| + !pickerProperty->HasSelectedColor(); + return result; +} + void TextPickerPattern::OnDirectionConfigurationUpdate() { isNeedUpdateSelectedIndex_ = false; diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_pattern.h b/frameworks/core/components_ng/pattern/text_picker/textpicker_pattern.h index d23c0e4ffe3c24f0af8faa8a23abfcd1f5dcb7df..783a57f455a4f7dffff1ca2d3765c8e86797997b 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_pattern.h +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_pattern.h @@ -322,6 +322,8 @@ public: void OnColorConfigurationUpdate() override; + bool OnThemeScopeUpdate(int32_t themeScopeId) override; + void OnDirectionConfigurationUpdate() override; void SetContentRowNode(RefPtr& contentRowNode)