From bcd8a3d11733243d7843a7652fcaaad31a978f0d Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Mon, 23 Dec 2024 11:23:20 +0800 Subject: [PATCH] =?utf8?q?=E7=B3=BB=E7=BB=9F=EF=BC=9A=E5=A2=9E=E5=8A=A0?= =?utf8?q?=E5=8D=A1=E8=B7=AF=E9=87=8C=EF=BC=8C=E6=AD=A5=E6=95=B0=E7=9B=AE?= =?utf8?q?=E6=A0=87=E5=80=BCmodel?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../main/include/dial/DialModelKcalgoalStr.h | 29 ++++++++++++++ .../main/include/dial/DialModelStepgoalStr.h | 0 .../main/src/dial/DialBoxProgressView.cpp | 2 +- .../main/src/dial/DialModelKcalgoalStr.cpp | 0 .../main/src/dial/DialModelStepgoal.cpp | 39 ------------------- .../main/src/dial/DialModelStepgoalMapper.cpp | 39 +++++++++++++++++++ .../main/src/dial/DialModelStepgoalStr.cpp | 0 7 files changed, 69 insertions(+), 40 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelKcalgoalStr.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelStepgoalStr.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelKcalgoalStr.cpp delete mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoal.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoalMapper.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoalStr.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelKcalgoalStr.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelKcalgoalStr.h new file mode 100644 index 000000000..ec3a41434 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelKcalgoalStr.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. + * Description: DialModelCaloriegoal + * Author: + * Create: 2023-12 + */ + +#ifndef DIAL_MODEL_Caloriegoal_H +#define DIAL_MODEL_Caloriegoal_H + +#include "DialBaseModel.h" + +namespace OHOS { +class DialModelCaloriegoal : public DialBaseModel { +public: + DialModelCaloriegoal() {} + ~DialModelCaloriegoal() override {} + static DialModelCaloriegoal *GetInstance() { + static DialModelCaloriegoal instance; + return &instance; + } + bool GetDialFloatData(DialDataType &type, float &out) override; + void UpdateCaloriegoal(uint32_t Caloriegoal); + +private: + float Caloriegoal_ = 0; // 11520.0: default Calorie value as reference +}; +} // namespace OHOS +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelStepgoalStr.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/dial/DialModelStepgoalStr.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialBoxProgressView.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialBoxProgressView.cpp index 746c51474..d2d8b1c7b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialBoxProgressView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialBoxProgressView.cpp @@ -28,7 +28,7 @@ uint32_t DialBoxProgressView::DialBoxDataTypeToBitPattern(DialBoxDataType type) { return static_cast(type) << TYPE_SHIFT; } - +//增加box不同值颜色绘制 uint32_t DialBoxProgressView::ConvertToRequiredFormat(DialBoxDataType type, float data) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelKcalgoalStr.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelKcalgoalStr.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoal.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoal.cpp deleted file mode 100644 index a07e2a643..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoal.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. - * Description: DialModelSteps - * Author: - * Create: 2023-12 - */ - -#include "DialModelStepgoal.h" -#include "DialBoxProgressView.h" -#include "RegisterDialModel.h" -#include "goal/include/goalmodel.h" - -REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_STEPS_GOAL, - OHOS::DialModelStepgoal::GetInstance()); - -namespace OHOS { -bool DialModelStepgoal::GetDialFloatData(DialDataType &type, float &out) { - (void)type; - out = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat( - DialBoxDataType::STEP_TARGET, stepgoal_); - return true; -} - -void DialModelStepgoal::UpdateStepgoal(uint32_t steps) { - uint32_t step_ = static_cast(steps); - uint32_t goal = GoalModel::GetInstance().getstepgoaldata(); - if (goal > 0) { - stepgoal_ = (static_cast(step_) / goal) * 100; - if (stepgoal_ > 100) - stepgoal_ = 100; - stepgoal_ = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat( - DialBoxDataType::STEP_TARGET, stepgoal_); - } - if (onChangeListener_ != nullptr) { - onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_STEPS_GOAL, - stepgoal_); - } -} -} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoalMapper.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoalMapper.cpp new file mode 100644 index 000000000..a4dfc57f9 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoalMapper.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) CompanyNameMagicTag 2023. All rights reserved. + * Description: DialModelSteps + * Author: + * Create: 2023-12 + */ + +#include "DialModelStepgoalMapper.h" +#include "DialBoxProgressView.h" +#include "RegisterDialModel.h" +#include "goalMapper/include/goalMappermodel.h" + +REGIST_DIAL_MODULE(DialDataType::DATA_TYPE_STEPS_goalMapper, + OHOS::DialModelStepgoalMapper::GetInstance()); + +namespace OHOS { +bool DialModelStepgoalMapper::GetDialFloatData(DialDataType &type, float &out) { + (void)type; + out = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat( + DialBoxDataType::STEP_TARGET, stepgoalMapper_); + return true; +} + +void DialModelStepgoalMapper::UpdateStepgoalMapper(uint32_t steps) { + uint32_t step_ = static_cast(steps); + uint32_t goalMapper = goalMapperModel::GetInstance().getstepgoalMapperdata(); + if (goalMapper > 0) { + stepgoalMapper_ = (static_cast(step_) / goalMapper) * 100; + if (stepgoalMapper_ > 100) + stepgoalMapper_ = 100; + stepgoalMapper_ = DialBoxProgressView::GetInstance()->ConvertToRequiredFormat( + DialBoxDataType::STEP_TARGET, stepgoalMapper_); + } + if (onChangeListener_ != nullptr) { + onChangeListener_->OnDialFloatDataUpdate(DialDataType::DATA_TYPE_STEPS_goalMapper, + stepgoalMapper_); + } +} +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoalStr.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dial/DialModelStepgoalStr.cpp new file mode 100644 index 000000000..e69de29bb -- 2.17.1