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 #include "view_abstract.h" 16 17 #include <regex> 18 19 #include "base/geometry/animatable_dimension.h" 20 #include "base/json/json_util.h" 21 #include "base/memory/referenced.h" 22 #include "bridge/common/utils/utils.h" 23 #include "bridge/declarative_frontend/view_stack_processor.h" 24 #include "core/common/ace_application_info.h" 25 #include "core/common/container.h" 26 #include "core/components/box/box_component_helper.h" 27 #include "core/components/common/layout/align_declaration.h" 28 #include "core/components/common/layout/position_param.h" 29 #include "core/components/common/properties/motion_path_option.h" 30 #include "core/components/display/display_component.h" 31 #include "core/components/option/option_component.h" 32 #include "core/components/split_container/column_split_component.h" 33 #include "core/components/split_container/row_split_component.h" 34 #include "core/components/split_container/split_container_component.h" 35 #include "core/components/text/text_component.h" 36 #include "core/components/theme/theme_manager.h" 37 #include "core/components_ng/base/view_abstract.h" 38 #include "core/components_ng/base/view_abstract_model.h" 39 #include "core/components_ng/base/view_stack_processor.h" 40 #include "core/components_v2/extensions/events/on_area_change_extension.h" 41 #include "core/gestures/long_press_gesture.h" 42 43 namespace OHOS::Ace::Framework { GetThemeConstants()44RefPtr<ThemeConstants> ViewAbstract::GetThemeConstants() 45 { 46 auto currentObj = Container::Current(); 47 if (!currentObj) { 48 LOGW("container is null"); 49 return nullptr; 50 } 51 auto pipelineContext = currentObj->GetPipelineContext(); 52 if (!pipelineContext) { 53 LOGE("pipeline context is null!"); 54 return nullptr; 55 } 56 auto themeManager = pipelineContext->GetThemeManager(); 57 if (!themeManager) { 58 LOGE("theme manager is null!"); 59 return nullptr; 60 } 61 return themeManager->GetThemeConstants(); 62 } 63 CjEnabled(bool enabled)64void ViewAbstract::CjEnabled(bool enabled) 65 { 66 ViewAbstractModel::GetInstance()->SetEnabled(enabled); 67 } 68 69 } // namespace OHOS::Ace::Framework 70