add_loadingProgress_inspector

Signed-off-by: yaoyuchi <yaoyuchi@huawei.com>
This commit is contained in:
yaoyuchi
2022-03-19 14:48:22 +08:00
parent ccfaa7b6aa
commit 131dd6b127
7 changed files with 123 additions and 2 deletions
@@ -56,6 +56,11 @@ public:
return loadingMode_;
}
Color GetProgressColor() const
{
return progressColor_;
}
void SetLoadingMode(int32_t mode);
void SetDragRange(double minDistance, double maxDistance);
@@ -45,6 +45,7 @@ build_component("inspector_v2") {
"inspector_constants.cpp",
"list_composed_element.cpp",
"list_item_composed_element.cpp",
"loading_progress_composed_element.cpp",
"marquee_composed_element.cpp",
"menu_composed_element.cpp",
"navigation_composed_element.cpp",
@@ -46,6 +46,7 @@
#include "core/components_v2/inspector/inspector_constants.h"
#include "core/components_v2/inspector/list_composed_element.h"
#include "core/components_v2/inspector/list_item_composed_element.h"
#include "core/components_v2/inspector/loading_progress_composed_element.h"
#include "core/components_v2/inspector/marquee_composed_element.h"
#include "core/components_v2/inspector/menu_composed_element.h"
#include "core/components_v2/inspector/navigation_composed_element.h"
@@ -229,7 +230,9 @@ const std::unordered_map<std::string, CreateElementFunc> CREATE_ELEMENT_MAP {
{ DATE_PICKER_DIALOG_COMPONENT_TAG,
[](const std::string& id) {return AceType::MakeRefPtr<V2::DatePickerDialogComposedElement>(id); } },
{ SIDE_BAR_COMPONENT_TAG,
[](const std::string& id) {return AceType::MakeRefPtr<V2::SideBarComposedElement>(id); } }
[](const std::string& id) {return AceType::MakeRefPtr<V2::SideBarComposedElement>(id); } },
{ LOADING_PROGRESS_COMPONENT_TAG,
[](const std::string& id) {return AceType::MakeRefPtr<V2::LoadingProgressComposedElement>(id); } }
};
} // namespace
@@ -303,7 +306,8 @@ const std::unordered_map<std::string, std::string> COMPONENT_TAG_TO_ETS_TAG_MAP
{ ALERTDIALOG_COMPONENT_TAG, ALERTDIALOG_ETS_TAG },
{ CUSTOMDIALOG_COMPONENT_TAG, CUSTOMDIALOG_ETS_TAG },
{ DATE_PICKER_DIALOG_COMPONENT_TAG, DATE_PICKER_DIALOG_ETS_TAG },
{ SIDE_BAR_COMPONENT_TAG, SIDE_BAR_ETS_TAG }
{ SIDE_BAR_COMPONENT_TAG, SIDE_BAR_ETS_TAG },
{ LOADING_PROGRESS_COMPONENT_TAG, LOADING_PROGRESS_ETS_TAG }
};
RefPtr<Element> InspectorComposedComponent::CreateElement()
@@ -320,4 +320,8 @@ ACE_EXPORT extern const char DATE_PICKER_DIALOG_ETS_TAG[] = "DatePickerDialog";
ACE_EXPORT extern const char SIDE_BAR_COMPONENT_TAG[] = "SideBarContainerComponent";
ACE_EXPORT extern const char SIDE_BAR_ETS_TAG[] = "SideBarContainer";
// loadingProgress
ACE_EXPORT extern const char LOADING_PROGRESS_COMPONENT_TAG[] = "LoadingProgressComponent";
ACE_EXPORT extern const char LOADING_PROGRESS_ETS_TAG[] = "LoadingProgress";
} // namespace OHOS::Ace::V2
@@ -331,6 +331,10 @@ ACE_EXPORT extern const char DATE_PICKER_DIALOG_ETS_TAG[];
ACE_EXPORT extern const char SIDE_BAR_COMPONENT_TAG[];
ACE_EXPORT extern const char SIDE_BAR_ETS_TAG[];
// loadingProgress
ACE_EXPORT extern const char LOADING_PROGRESS_COMPONENT_TAG[];
ACE_EXPORT extern const char LOADING_PROGRESS_ETS_TAG[];
} // namespace OHOS::Ace::V2
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INSPECTOR_INSPECTOR_CONSTANTS_H
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "core/components_v2/inspector/loading_progress_composed_element.h"
#include "base/log/dump_log.h"
#include "core/components/progress/loading_progress_element.h"
#include "core/components_v2/inspector/utils.h"
namespace OHOS::Ace::V2 {
namespace {
const std::unordered_map<std::string,
std::function<std::string(const LoadingProgressComposedElement&)>> CREATE_JSON_MAP {
{ "color", [](const LoadingProgressComposedElement& inspector) { return inspector.GetProgressColor(); } }
};
}
void LoadingProgressComposedElement::Dump()
{
InspectorComposedElement::Dump();
DumpLog::GetInstance().AddDesc(std::string("color: ").append(GetProgressColor()));
}
std::unique_ptr<JsonValue> LoadingProgressComposedElement::ToJsonObject() const
{
auto resultJson = InspectorComposedElement::ToJsonObject();
for (const auto& value : CREATE_JSON_MAP) {
resultJson->Put(value.first.c_str(), value.second(*this).c_str());
}
return resultJson;
}
std::string LoadingProgressComposedElement::GetProgressColor() const
{
auto render = GetRenderLoadingProgress();
if (render) {
return ConvertColorToString(render->GetProgressColor());
}
return "";
}
RefPtr<RenderLoadingProgress> LoadingProgressComposedElement::GetRenderLoadingProgress() const
{
auto node = GetInspectorNode(LoadingProgressElement::TypeId());
if (node) {
return AceType::DynamicCast<RenderLoadingProgress>(node);
}
return nullptr;
}
} // namespace OHOS::Ace::V2
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INSPECTOR_LOADING_PROGRESS_COMPOSED_ELEMENT_H
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INSPECTOR_LOADING_PROGRESS_COMPOSED_ELEMENT_H
#include "core/components/progress/render_loading_progress.h"
#include "core/components_v2/inspector/inspector_composed_element.h"
#include "core/pipeline/base/composed_element.h"
namespace OHOS::Ace::V2 {
class ACE_EXPORT LoadingProgressComposedElement : public InspectorComposedElement {
DECLARE_ACE_TYPE(LoadingProgressComposedElement, InspectorComposedElement)
public:
explicit LoadingProgressComposedElement(const ComposeId& id) : InspectorComposedElement(id) {}
~LoadingProgressComposedElement() override = default;
void Dump() override;
std::unique_ptr<JsonValue> ToJsonObject() const override;
std::string GetProgressColor() const;
private:
RefPtr<RenderLoadingProgress> GetRenderLoadingProgress() const;
};
} // namespace OHOS::Ace::V2
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INSPECTOR_LOADING_PROGRESS_COMPOSED_ELEMENT_H