diff --git a/frameworks/core/components/select/select_theme.h b/frameworks/core/components/select/select_theme.h index 2794c7691355cdd551b8966847d97d2a8e12c25b..0cd9d5316bb1c8df0e68b25965850ace48c4f9e0 100644 --- a/frameworks/core/components/select/select_theme.h +++ b/frameworks/core/components/select/select_theme.h @@ -1150,8 +1150,9 @@ protected: Color secondaryFontColor_; Color selectedColor_; Color selectedColorText_ = Color(0xff0a59f7); - Color selectDefaultBgColor_; Color menuTextColor_; + Color menuTitleFontColor_; + Color lineColor_ = Color(0x33000000); private: Color disabledColor_; @@ -1159,13 +1160,11 @@ private: Color disabledBackgroundColor_; Color hoverColor_ = Color(0x0c000000); - Color lineColor_ = Color(0x33000000); Color spinnerColor_ = Color(0xE5182431); Color disabledSpinnerColor_; Color disabledSpinnerSymbolColor_; uint32_t spinnerSource_ = 983615; Color disabledMenuFontColor_; - Color menuTitleFontColor_; bool allowScale_ = true; Dimension fontSize_; @@ -1249,6 +1248,7 @@ private: bool expandDisplay_ = false; Dimension maxPaddingStart_; Dimension maxPaddingEnd_; + Color selectDefaultBgColor_; std::unordered_map selectMinWidthMap_; std::unordered_map selectMinHeightMap_; std::unordered_map selectBorderRadiusMap_; diff --git a/frameworks/core/components_ng/pattern/select/select_pattern.cpp b/frameworks/core/components_ng/pattern/select/select_pattern.cpp index db0dbe98aca02a75e56127408bedbb5fc2f5c4f8..c21e1861e9521b844f8a2dadd3d1c42cbc993f15 100644 --- a/frameworks/core/components_ng/pattern/select/select_pattern.cpp +++ b/frameworks/core/components_ng/pattern/select/select_pattern.cpp @@ -1222,9 +1222,6 @@ void SelectPattern::OnColorConfigurationUpdate() bool SelectPattern::OnThemeScopeUpdate(int32_t themeScopeId) { auto result = false; - - BuildChild(); - auto host = GetHost(); CHECK_NULL_RETURN(host, result); auto pipeline = PipelineBase::GetCurrentContext(); @@ -1239,6 +1236,19 @@ bool SelectPattern::OnThemeScopeUpdate(int32_t themeScopeId) auto menuPattern = menuNode->GetPattern(); CHECK_NULL_RETURN(menuPattern, result); + BuildChild(); + auto selectRenderContext = host->GetRenderContext(); + CHECK_NULL_RETURN(selectRenderContext, result); + auto selectPaintProperty = host->GetPaintProperty(); + CHECK_NULL_RETURN(selectPaintProperty, result); + if (!selectPaintProperty->HasBackgroundColor()) { + if (Container::LessThanAPITargetVersion(PlatformVersion::VERSION_TWELVE)) { + selectRenderContext->UpdateBackgroundColor(selectTheme->GetBackgroundColor()); + } else { + selectRenderContext->UpdateBackgroundColor(selectTheme->GetButtonBackgroundColor()); + } + } + auto renderContext = menuNode->GetRenderContext(); renderContext->UpdateBackgroundColor(selectTheme->GetBackgroundColor()); if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_ELEVEN) && renderContext->IsUniRenderEnabled()) { @@ -1248,13 +1258,26 @@ bool SelectPattern::OnThemeScopeUpdate(int32_t themeScopeId) auto optionNode = menuPattern->GetOptions(); for (auto child : optionNode) { auto optionsPattern = child->GetPattern(); - optionsPattern->SetFontColor(selectTheme->GetFontColor()); - - result = true; + CHECK_NULL_RETURN(optionsPattern, result); + // update unselected option fontColor + if (!optionFont_.FontColor.has_value()) { + optionsPattern->SetFontColor(selectTheme->GetFontColor()); + result = true; + } child->MarkModifyDone(); child->MarkDirtyNode(PROPERTY_UPDATE_MEASURE_SELF); } - SetOptionBgColor(selectTheme->GetBackgroundColor()); + + // update selected option backgroundColor + if (!selectedBgColor_.has_value()) { + SetSelectedOptionBgColor(selectTheme->GetSelectedColor()); + } + // update selected option fontColor + if (!selectedFont_.FontColor.has_value()) { + auto selectPattern = ViewStackProcessor::GetInstance()->GetMainFrameNodePattern(); + CHECK_NULL_RETURN(selectPattern, result); + selectPattern->SetSelectedOptionFontColor(selectTheme->GetSelectedColorText()); + } host->SetNeedCallChildrenUpdate(false); return result; diff --git a/frameworks/core/components_ng/pattern/select/select_theme_wrapper.h b/frameworks/core/components_ng/pattern/select/select_theme_wrapper.h index ff3287b47bf0e345d51eac6ff6d032ed90f4a5a2..fd41083eae0238bbff3b992335783b53df136cc5 100644 --- a/frameworks/core/components_ng/pattern/select/select_theme_wrapper.h +++ b/frameworks/core/components_ng/pattern/select/select_theme_wrapper.h @@ -65,6 +65,8 @@ public: selectedColor_ = themeColors->CompEmphasizeSecondary(); selectedColorText_ = themeColors->FontEmphasize(); menuTextColor_ = themeColors->FontPrimary(); + menuTitleFontColor_ = themeColors>FontPrimary(); + lineColor_ = themeColors->CompDivider(); } }