ECGslice界面添加
authorluozheng <1732036298@qq.com>
Fri, 20 Jun 2025 02:10:10 +0000 (10:10 +0800)
committerluozheng <1732036298@qq.com>
Fri, 20 Jun 2025 02:10:10 +0000 (10:10 +0800)
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgTestNeedAppOrNetworkView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/ecg/include/EcgView.h
code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgTestNeedAppOrNetworkView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/ecg/src/EcgView.cpp

index e3b1767..38baa36 100644 (file)
@@ -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 (file)
index 0000000..ada19e7
--- /dev/null
@@ -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
index 345632a..b37a97c 100644 (file)
 #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 (file)
index 0000000..eb926fa
--- /dev/null
@@ -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
index 345c940..87f586e 100644 (file)
@@ -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)