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