1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "core/components_ng/pattern/navigation/navigation_drag_bar_pattern.h" 17 #include "core/components_ng/pattern/navigation/navigation_declaration.h" 18 19 namespace OHOS::Ace::NG { 20 constexpr float BLUR_OPACITY = 0.1f; 21 UpdateDefaultColor()22void NavigationDragBarPattern::UpdateDefaultColor() 23 { 24 auto dragBarNode = GetHost(); 25 CHECK_NULL_VOID(dragBarNode); 26 auto renderContext = dragBarNode->GetRenderContext(); 27 CHECK_NULL_VOID(renderContext); 28 auto theme = NavigationGetTheme(); 29 CHECK_NULL_VOID(theme); 30 renderContext->UpdateBackgroundColor(theme->GetDragBarDefaultColor().ChangeOpacity(BLUR_OPACITY)); 31 auto barNode = AceType::DynamicCast<FrameNode>(dragBarNode->GetChildAtIndex(0)); 32 CHECK_NULL_VOID(barNode); 33 auto barRenderContext = (barNode)->GetRenderContext(); 34 CHECK_NULL_VOID(barRenderContext); 35 barRenderContext->UpdateBackgroundColor(theme->GetDragBarItemDefaultColor()); 36 } 37 UpdateActiveColor()38void NavigationDragBarPattern::UpdateActiveColor() 39 { 40 auto theme = NavigationGetTheme(); 41 CHECK_NULL_VOID(theme); 42 auto dragBarNode = GetHost(); 43 CHECK_NULL_VOID(dragBarNode); 44 auto dragBarRenderContext = dragBarNode->GetRenderContext(); 45 CHECK_NULL_VOID(dragBarRenderContext); 46 dragBarRenderContext->UpdateBackgroundColor(theme->GetDragBarActiveColor()); 47 auto barNode = AceType::DynamicCast<FrameNode>(dragBarNode->GetChildAtIndex(0)); 48 CHECK_NULL_VOID(barNode); 49 auto barRenderContext = barNode->GetRenderContext(); 50 CHECK_NULL_VOID(barRenderContext); 51 barRenderContext->UpdateBackgroundColor(theme->GetDragBarItemActiveColor()); 52 } 53 } // namespace OHOS::Ace::NG 54