1 /* 2 * Copyright (c) 2025 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 #ifndef UPDATER_UI_BOX_PROGRESS_ADAPTER_H 17 #define UPDATER_UI_BOX_PROGRESS_ADAPTER_H 18 19 #include <string> 20 #include "component_common.h" 21 #include "component_factory.h" 22 #include "components/ui_box_progress.h" 23 #include "macros_updater.h" 24 25 namespace Updater { 26 struct UxBoxProgressInfo { 27 uint32_t defaultValue; 28 std::string fgColor; 29 std::string bgColor; 30 std::string endPoint; 31 bool hasEp; 32 }; 33 34 class ImgViewAdapter; 35 class BoxProgressAdapter : public OHOS::UIBoxProgress, public ComponentCommon<BoxProgressAdapter, UxBoxProgressInfo> { 36 static constexpr uint32_t MAX_PROGRESS_VALUE = 100; 37 DISALLOW_COPY_MOVE(BoxProgressAdapter); 38 public: 39 40 static constexpr auto COMPONENT_TYPE = "UIBoxProgress"; 41 BoxProgressAdapter() = default; 42 explicit BoxProgressAdapter(const UxViewInfo &info); ~BoxProgressAdapter()43 virtual ~BoxProgressAdapter() {} 44 void SetValue(float value); 45 void SetVisible(bool isVisible); 46 [[nodiscard]] bool InitEp(); 47 static bool IsValid(const UxBoxProgressInfo &info); 48 private: 49 OHOS::Point GetPosOfEp(); 50 std::string epId_ = {}; 51 bool hasEp_ = false; 52 ImgViewAdapter *ep_ = {}; 53 }; 54 } // namespace Updater 55 #endif // UPDATER_UI_PROGRESS_BAR_H 56