From d27fde416b81f9b548ade9178c3b63f1809a8057 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 20 Jun 2025 10:10:10 +0800 Subject: [PATCH] =?utf8?q?ECGslice=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 | 1 + .../ecg/include/EcgTestNeedAppOrNetworkView.h | 26 +++++++ .../fd230app/nativeui/ecg/include/EcgView.h | 20 +++-- .../ecg/src/EcgTestNeedAppOrNetworkView.cpp | 74 +++++++++++++++++++ .../fd230app/nativeui/ecg/src/EcgView.cpp | 22 ++++++ 5 files changed, 135 insertions(+), 8 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestNeedAppOrNetworkView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestNeedAppOrNetworkView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index e3b176746..38baa360f 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -260,6 +260,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestAnalysisView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgResetTestOfSuccView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestResultView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/ecg/src/EcgTestNeedAppOrNetworkView.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/ecg/include/EcgTestNeedAppOrNetworkView.h b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestNeedAppOrNetworkView.h new file mode 100644 index 000000000..ada19e79f --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestNeedAppOrNetworkView.h @@ -0,0 +1,26 @@ +#ifndef ECG_TESTNEEDAPPORNETWORK_VIEW_H_ +#define ECG_TESTNEEDAPPORNETWORK_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" +#include "components/ui_scroll_view.h" +namespace OHOS +{ + class EcgTestNeedAppOrNetworkView + { + public: + EcgTestNeedAppOrNetworkView(); + ~EcgTestNeedAppOrNetworkView(); + static EcgTestNeedAppOrNetworkView *GetInstance(void); + UIViewGroup *EcgTestNeedAppOrNetworkInit(); + + private: + void ClearAll(void); + UIViewGroup *group{nullptr}; + UILabelExt *reminderLabel{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 345632ae6..b37a97c9a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h @@ -12,19 +12,21 @@ #include "ecg/include/EcgTestAnalysisView.h" #include "ecg/include/EcgResetTestOfSuccView.h" #include "ecg/include/EcgTestResultView.h" +#include "ecg/include/EcgTestNeedAppOrNetworkView.h" namespace OHOS { typedef enum : uint8_t { - ECGSTARTTESTVIEW = 0, // 开始测量界面 - ECGTESTREMINDERVIEW, // 测量提醒界面 - ECGTESTINGVIEW, // 测量中界面 - ECGTESTFAILNOVALUE, // 测量失败无值 - ECGTESTFAILNOWEARING, // 测量失败未佩戴 - ECGTESTANALYSISVIEW, // 测量分析界面 - ECGRESETTESTOFSUCCVIEW, // 测量成功重新测量界面 - ECGTESTRESULTVIEW, // 测量结果界面 + ECGSTARTTESTVIEW = 0, // 开始测量界面 + ECGTESTREMINDERVIEW, // 测量提醒界面 + ECGTESTINGVIEW, // 测量中界面 + ECGTESTFAILNOVALUE, // 测量失败无值 + ECGTESTFAILNOWEARING, // 测量失败未佩戴 + ECGTESTANALYSISVIEW, // 测量分析界面 + ECGRESETTESTOFSUCCVIEW, // 测量成功重新测量界面 + ECGTESTRESULTVIEW, // 测量结果界面 + ECGTESTNEEDAPPORNETWORKVIEW, // 测量需要app或网络界面 MAX_ECGVIEW, } EcgViewID; @@ -44,6 +46,7 @@ namespace OHOS bool ChangeEcgTestAnalysisView(int16_t thisView); bool ChangeEcgResetTestOfSuccView(int16_t thisView); bool ChangeEcgTestResultView(int16_t thisView); + bool ChangeEcgTestNeedAppOrNetworkView(int16_t thisView); bool ClickFunc(int16_t interface); void ChangeView(int16_t hideView, int16_t showView); @@ -61,6 +64,7 @@ namespace OHOS EcgTestAnalysisView *p_EcgTestAnalysisView{nullptr}; EcgResetTestOfSuccView *p_EcgResetTestOfSuccView{nullptr}; EcgTestResultView *p_EcgTestResultView{nullptr}; + EcgTestNeedAppOrNetworkView *p_EcgTestNeedAppOrNetworkView{nullptr}; private: void CreateEcgView(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestNeedAppOrNetworkView.cpp b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestNeedAppOrNetworkView.cpp new file mode 100644 index 000000000..eb926fa87 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestNeedAppOrNetworkView.cpp @@ -0,0 +1,74 @@ +#include "ecg/include/EcgTestNeedAppOrNetworkView.h" +#include "ecg/include/EcgPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static EcgTestNeedAppOrNetworkView *g_pEcgTestNeedAppOrNetworkView = nullptr; + EcgTestNeedAppOrNetworkView::EcgTestNeedAppOrNetworkView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestNeedAppOrNetworkView::EcgTestNeedAppOrNetworkView"); + g_pEcgTestNeedAppOrNetworkView = this; + } + + EcgTestNeedAppOrNetworkView::~EcgTestNeedAppOrNetworkView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "EcgTestNeedAppOrNetworkView::~EcgTestNeedAppOrNetworkView"); + ClearAll(); + g_pEcgTestNeedAppOrNetworkView = nullptr; + } + + EcgTestNeedAppOrNetworkView *EcgTestNeedAppOrNetworkView::GetInstance(void) + { + return g_pEcgTestNeedAppOrNetworkView; + } + + void EcgTestNeedAppOrNetworkView::ClearAll(void) + { + if (group) + { + group->RemoveAll(); + delete group; + group = nullptr; + delete reminderLabel; + reminderLabel = nullptr; + } + } + + UIViewGroup *EcgTestNeedAppOrNetworkView::EcgTestNeedAppOrNetworkInit() + { + 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 (reminderLabel == nullptr) + { + reminderLabel = new UILabelExt(); + if (reminderLabel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "reminderLabel null!"); + return nullptr; + } + } + reminderLabel->SetPosition((HORIZONTAL_RESOLUTION - 400) / 2, 201, 400, 77); + reminderLabel->SetStyle(STYLE_TEXT_FONT, 36); + reminderLabel->SetStyle(STYLE_LINE_HEIGHT, 77); + reminderLabel->SetText("请连接APP或开启4G网络"); + reminderLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + reminderLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + reminderLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 36); + group->Add(reminderLabel); + 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 345c940a2..87f586ed1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp @@ -67,6 +67,11 @@ namespace OHOS delete p_EcgTestResultView; p_EcgTestResultView = nullptr; } + if(p_EcgTestNeedAppOrNetworkView) + { + delete p_EcgTestNeedAppOrNetworkView; + p_EcgTestNeedAppOrNetworkView = nullptr; + } for (int i = 0; i < MAX_ECGVIEW; i++) { group[i] = nullptr; @@ -237,6 +242,22 @@ namespace OHOS } return true; } + bool EcgView::ChangeEcgTestNeedAppOrNetworkView(int16_t thisView) + { + if (group[thisView] == nullptr) + { + p_EcgTestNeedAppOrNetworkView = new EcgTestNeedAppOrNetworkView(); + if (p_EcgTestNeedAppOrNetworkView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "new scrollView[%d] fail", thisView); + return false; + } + // 初始化视图并添加到视图组 + group[thisView] = p_EcgTestNeedAppOrNetworkView->EcgTestNeedAppOrNetworkInit(); + container_->Add(group[thisView]); + } + return true; + } struct EcgViewMapper { @@ -253,6 +274,7 @@ namespace OHOS {ECGTESTANALYSISVIEW, &EcgView::ChangeEcgTestAnalysisView}, {ECGRESETTESTOFSUCCVIEW, &EcgView::ChangeEcgResetTestOfSuccView}, {ECGTESTRESULTVIEW, &EcgView::ChangeEcgTestResultView}, + {ECGTESTNEEDAPPORNETWORKVIEW, &EcgView::ChangeEcgTestNeedAppOrNetworkView}, }; bool EcgView::ClickFunc(int16_t interface) -- 2.17.1