From f5bd0fa97dd082465c3f43318876920d02924c08 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 18 Jun 2025 16:34:21 +0800 Subject: [PATCH] =?utf8?q?ECGslice=E5=BC=80=E5=A7=8B=E6=B5=8B=E9=87=8F?= =?utf8?q?=E7=95=8C=E9=9D=A2=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 3 +- .../nativeui/applist/src/ApplistModel.cpp | 1 + .../nativeui/ecg/include/EcgStartTestView.h | 29 +++++ .../fd230app/nativeui/ecg/include/EcgView.h | 18 ++- .../nativeui/ecg/src/EcgPresenter.cpp | 7 +- .../nativeui/ecg/src/EcgStartTestView.cpp | 112 ++++++++++++++++++ .../fd230app/nativeui/ecg/src/EcgView.cpp | 75 +++++++++++- 7 files changed, 239 insertions(+), 6 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgStartTestView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgStartTestView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 797f3ff07..ccd967f21 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -251,7 +251,8 @@ set(SOURCES # ECG ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgPresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgStartTestView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceListView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp index f787403dc..f034b3b0d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp @@ -63,6 +63,7 @@ namespace OHOS #if defined(BOARD_W9) || defined(BOARD_N9) /*W9与N9的Slice写宏里面*/ {VIEW_BLOOD_PRESSURE_CHECK, PNG_APPLIST_BP_MESSURE_IMAGE_BIG, PNG_APPLIST_BP_MESSURE_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血压测量", STR_BP_CHECK, nullptr}, + {VIEW_ECG, PNG_APPLIST_ECG_IMAGE_BIG, PNG_APPLIST_ECG_IMAGE, PNG_APPLIST_DEFAULT_IMG, "ECG", STR_BP_CHECK, nullptr}, #endif {VIEW_SLEEP, PNG_APPLIST_SLEEP_IMAGE_BIG, PNG_APPLIST_SLEEP_IMAGE, PNG_APPLIST_DEFAULT_IMG, "睡眠", STR_SLEEP, nullptr}, {VIEW_TRAINING, PNG_APPLIST_TRAINING_IMAGE_BIG, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_DEFAULT_IMG, "运动", STR_TRAINING, nullptr}, diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgStartTestView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgStartTestView.h new file mode 100644 index 000000000..c3cc6ba91 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgStartTestView.h @@ -0,0 +1,29 @@ +#ifndef ECG_START_TEST_VIEW_H +#define ECG_START_TEST_VIEW_H + +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "components/ui_image_view.h" +namespace OHOS +{ + static const char *STARTECGTESTBUTTON = "startEcgTestButton";//开始ecg测量 + class EcgStartTestView + { + public: + EcgStartTestView(); + ~EcgStartTestView(); + static EcgStartTestView *GetInstance(void); + UIViewGroup* EcgStartTestInit(); + private: + void ClearAll(void); + UIViewGroup* group{nullptr}; + UILabelExt *titleLabel{nullptr}; + UIImageView *image{nullptr}; + UILabelButtonExt *startEcgTestButton{nullptr}; + }; + + +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h index 39114c7c5..57c6f38f8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h @@ -3,27 +3,39 @@ #include "BaseView.h" #include "View.h" - +#include "components/ui_view_group.h" +#include "ecg/include/EcgStartTestView.h" namespace OHOS { + typedef enum : uint8_t + { + ECGSTARTTESTVIEW = 0, // 开始测量界面 + MAX_ECGVIEW, + } EcgViewID; + class EcgPresenter; class EcgView : public View { - public: EcgView(); ~EcgView(); static EcgView *GetInstance(void); + bool ChangeEcgStartTestView(int16_t thisView); + bool ClickFunc(int16_t interface); + void ChangeView(int16_t hideView, int16_t showView); + void OnStart() override; void OnSetUpView() override; void OnTearDownView() override; void OnStop() override; + private: + EcgStartTestView *p_EcgStartTestView{nullptr}; private: void CreateEcgView(void); void ClearAll(void); - + UIViewGroup *group[MAX_ECGVIEW]{nullptr}; bool viewInitStatus{false}; }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp index 04585d873..e53da214e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgPresenter.cpp @@ -64,7 +64,12 @@ namespace OHOS bool EcgPresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnClick"); + std::string viewId = view.GetViewId(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgPresenter::OnClick,viewId = %s",viewId.c_str()); + if(viewId == STARTECGTESTBUTTON) + { + + } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgStartTestView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgStartTestView.cpp new file mode 100644 index 000000000..9ae1ad13a --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgStartTestView.cpp @@ -0,0 +1,112 @@ +#include "ecg/include/EcgStartTestView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static EcgStartTestView *g_pEcgStartTestView{nullptr}; + EcgStartTestView::EcgStartTestView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgStartTestView::EcgStartTestView"); + g_pEcgStartTestView = this; + } + EcgStartTestView::~EcgStartTestView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgStartTestView::~EcgStartTestView"); + ClearAll(); + g_pEcgStartTestView = nullptr; + } + EcgStartTestView *EcgStartTestView::GetInstance(void) + { + return g_pEcgStartTestView; + } + + void EcgStartTestView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete titleLabel; + titleLabel = nullptr; + delete image; + image = nullptr; + delete startEcgTestButton; + startEcgTestButton = nullptr; + delete group; + group = nullptr; + } + } + + UIViewGroup *EcgStartTestView::EcgStartTestInit() + { + if (group == nullptr) + { + group = new UIViewGroup(); + if (group == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group null!"); + return nullptr; + } + } + group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + group->SetTouchable(true); + group->SetDraggable(true); + UIView::OnDragListener *dragListener = (UIView::OnDragListener *)OHOS::EcgPresenter::GetInstance(); + group->SetOnDragListener(dragListener); + if (titleLabel == nullptr) + { + titleLabel = new UILabelExt(); + if (titleLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "titleLabel null!"); + return nullptr; + } + } + titleLabel->SetPosition((HORIZONTAL_RESOLUTION - 300) / 2, 50, 300, 35); + titleLabel->SetStyle(STYLE_TEXT_FONT, 30); + titleLabel->SetStyle(STYLE_LINE_HEIGHT, 35); + titleLabel->SetText("ECG"); + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + titleLabel->SetRollSpeed(23); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + group->Add(titleLabel); + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "image null!"); + return nullptr; + } + } + image->SetPosition((HORIZONTAL_RESOLUTION - 466) / 2, 150, 466, 300); + image->SetSrc("/user/res/BPCalibration/D.bin"); + group->Add(image); + /* -------------------------------------------------------------------------- */ + if (startEcgTestButton == nullptr) + { + startEcgTestButton = new UILabelButtonExt(); + if (startEcgTestButton == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startEcgTestButton null!"); + return nullptr; + } + } + startEcgTestButton->SetPosition((HORIZONTAL_RESOLUTION - 220) / 2, 360, 220, 70); + startEcgTestButton->SetStyle(STYLE_TEXT_FONT, 30); + startEcgTestButton->SetStyle(STYLE_LINE_HEIGHT, 35); + startEcgTestButton->SetAlign(TEXT_ALIGNMENT_CENTER); + startEcgTestButton->SetText("开始测量"); + startEcgTestButton->SetViewId(STARTECGTESTBUTTON); + startEcgTestButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36); + startEcgTestButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + startEcgTestButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + startEcgTestButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::EcgPresenter::GetInstance(); + startEcgTestButton->SetOnClickListener(clickListener); + group->Add(startEcgTestButton); + return group; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp index 25c4a370e..3dc93f481 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp @@ -27,11 +27,17 @@ namespace OHOS void EcgView::ClearAll(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::ClearAll"); + if (p_EcgStartTestView) + { + delete p_EcgStartTestView; + p_EcgStartTestView = nullptr; + } } void EcgView::CreateEcgView(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::CreateEcgView"); + ChangeView(MAX_ECGVIEW, ECGSTARTTESTVIEW); } void EcgView::OnStart() @@ -45,7 +51,6 @@ namespace OHOS return; } container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - container_->SetOnDragListener(presenter_); container_->SetTouchable(true); container_->SetDraggable(true); @@ -58,6 +63,74 @@ namespace OHOS RootView::GetInstance()->SetOnKeyActListener(presenter_); return; } + + bool EcgView::ChangeEcgStartTestView(int16_t thisView) + { + // 检查视图是否已初始化 + if (group[thisView] == nullptr) + { + p_EcgStartTestView = new EcgStartTestView(); + if (p_EcgStartTestView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgStartTestView->EcgStartTestInit(); + container_->Add(group[thisView]); + } + return true; + } + struct EcgViewMapper + { + const int16_t viewId; // 视图ID + bool (EcgView::*func)(int16_t); // 对应的视图切换函数指针 + }; + + static const EcgViewMapper ViewMapper[] = { + {ECGSTARTTESTVIEW, &EcgView::ChangeEcgStartTestView}, + }; + + bool EcgView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + void EcgView::ChangeView(int16_t hideView, int16_t showView) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::ChangeView"); + if (hideView > MAX_ECGVIEW) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgView:: SystemViewId Overstep ones bounds"); + return; + } + if (hideView != MAX_ECGVIEW) + { + if (group[hideView] == nullptr) + { + return; + } + group[hideView]->SetVisible(false); + } + ClickFunc(showView); + group[showView]->SetVisible(true); + container_->Invalidate(); + } + void EcgView::OnSetUpView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EcgView::OnSetUpView"); -- 2.17.1