增加血压结果展示UI
authorCaisking <Casiking@zhihuishixun.com>
Tue, 17 Jun 2025 06:59:58 +0000 (14:59 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Tue, 17 Jun 2025 06:59:58 +0000 (14:59 +0800)
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectEndView.h
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPDetectionView.h
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectEndView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectionView.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp

index 1c4cf4c..fe5f787 100644 (file)
@@ -236,7 +236,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPDetectFirstView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPDetectSOSView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPDetectBeginView.cpp
-
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bloodpressure/src/BPDetectEndView.cpp
 
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceCaseListAdapter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/bluetooth/src/BluetoothDeviceListView.cpp
index e69de29..7103442 100644 (file)
@@ -0,0 +1,49 @@
+
+#ifndef BP_DetectEnd_VIEW_H
+#define BP_DetectEnd_VIEW_H
+
+#include "components/ui_button.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_view_group.h"
+namespace OHOS {
+
+class BPDetectEndView {
+public:
+  BPDetectEndView();
+  ~BPDetectEndView();
+  static BPDetectEndView *GetInstance();
+  UIViewGroup *BPDetectEndInit();
+  void UpdateText(); //更新文本数据
+
+private:
+  UILabelExt *DBPTitleLabel{nullptr};
+  UILabelExt *SBPTitleText{nullptr};
+  UILabelExt *NomalText{nullptr};//正常
+  UILabelExt *HighText{nullptr};//偏高
+  UILabelExt *AlertText{nullptr};//预警
+
+
+  UILabel *DBPText{nullptr};
+  UILabel *SBPText{nullptr};
+  UILabel *timeLabel{nullptr};
+
+
+  UIImageView *BPImageView{nullptr};
+  UIImageView *BgWImageView{nullptr};
+  UIImageView *BgUImageView{nullptr};
+  UIImageView *IconImageView{nullptr};
+
+  UILabelButtonExt *ReCheckButton{nullptr};
+
+  UIViewGroup *group{nullptr};
+
+  uint16_t m_dbp_{0};
+  uint16_t m_sbp_{0};
+};
+} // namespace OHOS
+
+#endif // 血压主界面
\ No newline at end of file
index 99a6a72..e182fd6 100644 (file)
 #include "bloodpressure/include/BPDetectFirstView.h"
 #include "bloodpressure/include/BPDetectSOSView.h"
 #include "bloodpressure/include/BPDetectBeginView.h"
+#include "bloodpressure/include/BPDetectEndView.h"
 
 #define CLICK_BLOOD_PRESSURE "click_bloodpressure"
+#define RE_CLICK_BLOOD_PRESSURE "re_click_bloodpressure"
+
 namespace OHOS {
 
 typedef enum : uint8_t {
@@ -74,12 +77,16 @@ public:
   bool ChangeBPDetectFirstView(int16_t thisView);
   bool ChangeBPDetectSOSView(int16_t thisView);
   bool ChangeBPDetectBeginView(int16_t thisView);
+  bool ChangeBPDetectEndView(int16_t thisView);
 
 private:
   UIViewGroup *group[MAX_BPDECETVIEW]{nullptr};
   BPDetectFirstView *g_pBPDetectFirstView = nullptr;
   BPDetectSOSView *g_pBPDetectSOSView = nullptr;
   BPDetectBeginView *g_pBPDetectBeginView = nullptr;
+  BPDetectEndView *g_pBPDetectEndView = nullptr;
+
+
 };
 } // namespace OHOS
 
diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectEndView.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPDetectEndView.cpp
new file mode 100644 (file)
index 0000000..0b72e6d
--- /dev/null
@@ -0,0 +1,184 @@
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-07-31 14:36:25
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/bloodpressure/src/BPDetectEndView.cpp
+ */
+
+#include "ui_resource_image.h"
+#include "UiConfig.h"
+#include "wearable_log.h"
+#include "uicomponents/UIComponents.h"
+#include "bloodpressure/include/BPDetectionPresenter.h"
+#include "bloodpressure/include/BPDetectionView.h"
+#include "bloodpressure/include/BPDetectEndView.h"
+#include "bloodpressure/include/BPModel.h"
+
+namespace OHOS
+{
+    static BPDetectEndView *g_pBPDetectEndView{nullptr};
+    static const char* image_bp = "/user/res/BPCalibration/measuring.bin";
+    static const char* image_bg_w = "/user/res/BPCalibration/W.bin";
+    static const char* image_bg_u = "/user/res/BPCalibration/U.bin";
+    static const char* image_icon = "/user/res/BPCalibration/R2.bin";
+   
+
+    BPDetectEndView::BPDetectEndView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectEndView::BPDetectEndView");
+        g_pBPDetectEndView = this;
+    }
+    BPDetectEndView::~BPDetectEndView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectEndView::~BPDetectEndView");
+        if(group)
+        {
+            group->RemoveAll(); 
+            if(DBPTitleLabel)
+            {
+                delete DBPTitleLabel;
+                DBPTitleLabel = nullptr;
+            }
+            if(SBPTitleText)
+            {
+                delete SBPTitleText;
+                SBPTitleText = nullptr;
+            }
+            if(NomalText)
+            {
+                delete NomalText;
+                NomalText = nullptr;
+            }
+            if(HighText)
+            {
+                delete HighText;
+                HighText = nullptr;
+            }
+            if(AlertText)
+            {
+                delete AlertText;
+                AlertText = nullptr;
+            }
+            if(DBPText)
+            {
+                delete DBPText;
+                DBPText = nullptr;
+            }
+            if(SBPText)
+            {
+                delete SBPText;
+                SBPText = nullptr;
+            }
+            if(timeLabel)
+            {
+                delete timeLabel;
+                timeLabel = nullptr;
+            }
+            if(BPImageView)
+            {
+                delete BPImageView;
+                BPImageView = nullptr;
+            }
+            if(BgWImageView)
+            {
+                delete BgWImageView;
+                BgWImageView = nullptr;
+            }
+            if(BgUImageView)
+            {
+                delete BgUImageView;
+                BgUImageView = nullptr;
+            }
+            if(IconImageView)
+            {
+                delete IconImageView;
+                IconImageView = nullptr;
+            }
+            if(ReCheckButton)
+            {
+                delete ReCheckButton;
+                ReCheckButton = nullptr;
+            }
+        }
+        delete group;
+        group = nullptr;
+        g_pBPDetectEndView = nullptr;
+    }
+
+    BPDetectEndView *BPDetectEndView::GetInstance()
+    {
+        return g_pBPDetectEndView;
+    }
+
+    void BPDetectEndView::UpdateText()
+    {
+        if(DBPText == nullptr || SBPText == nullptr || timeLabel == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DBPText or SBPText or timeLabel is null");
+            return;
+        }
+        //获取时间更新时间
+        std::string timeStr = BPModel::GetInstance()->GetCurrentTimeStr();
+        timeLabel->SetText(timeStr.c_str());
+        //获取上一次检测数据 ? 待定
+        
+    }
+   
+    /***
+     * @description:
+     * @return 是否初始化成功
+     */
+    UIViewGroup *BPDetectEndView::BPDetectEndInit()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bool BPDetectEndView::InitView()");
+        group = new UIViewGroup();
+        group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BPDetectEndInit is begin");
+        /*初始化label*/
+        InitLabel(DBPTitleLabel, 20, 66, 200, 60, "calibration", "收缩压", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabel(SBPTitleText, 240, 66, 200, 60, "calibration", "舒张压", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabel(NomalText, 0, 295, 200, 60, "calibration", "正常", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabel(HighText, 133, 295, 200, 60, "calibration", "偏高", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabel(AlertText, 266, 295, 200, 60, "calibration", "预警", DEFAULT_VECTOR_FONT_FILENAME, 30);
+
+        InitUILabel(DBPText, 20, 120, 200, 60, "calibration", "---", DEFAULT_VECTOR_FONT_FILENAME, 50);
+        InitUILabel(SBPText, 240, 120, 200, 60, "calibration", "---", DEFAULT_VECTOR_FONT_FILENAME, 50);
+        InitUILabel(timeLabel, 133, 115, 200, 60, "calibration", "----/--/-- \n --:--", DEFAULT_VECTOR_FONT_FILENAME, 20);
+      
+        InitImageView(BPImageView, 208, 10, 100, 100, "image_bp", image_bp);
+        InitImageView(BgWImageView, 0, -75, 100, 100, "image_bg_w", image_bg_w);
+        InitImageView(BgUImageView, 22, 220, 100, 100, "image_bg_u", image_bg_u);
+        InitImageView(IconImageView, 29, 249, 100, 100, "image_icon", image_icon);
+
+        InitButtonExt(ReCheckButton, 118, 360, 230, 80, RE_CLICK_BLOOD_PRESSURE,STR_RECHECK, 30);
+        ReCheckButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36); // 设置按键颜色
+        UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::BPDetectionPresenter::GetInstance();
+        ReCheckButton->SetOnClickListener(clickListener);//设置按键监听
+
+        DBPText->SetTextColor(Color::GetColorFromRGBA(0xFF, 0x35, 0x00, 0xFF));
+        SBPText->SetTextColor(Color::GetColorFromRGBA(0xFF, 0x35, 0x00, 0xFF));
+
+        group->Add(DBPTitleLabel);
+        group->Add(SBPTitleText);
+        group->Add(NomalText);
+        group->Add(HighText);
+        group->Add(AlertText);
+
+        group->Add(DBPText);
+        group->Add(SBPText);
+        group->Add(timeLabel);
+
+        group->Add(BPImageView);
+        group->Add(BgWImageView);
+        group->Add(BgUImageView);
+        group->Add(ReCheckButton);
+
+        UpdateText();
+
+        return group;
+    }
+
+
+    
+}
index 71081e8..11027d5 100644 (file)
@@ -78,6 +78,7 @@ namespace OHOS
 
     bool BPDetectionPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
+        //界面开始检测->进入校准界面
         if (strcmp(view.GetViewId(), CLICK_BLOOD_PRESSURE) == 0)
         {
             // NavigateBack();
@@ -86,6 +87,15 @@ namespace OHOS
             BPDetectionView::GetInstance()->ChangeView(MAIN_BPVIEW,CALIBRATION_BPVIEW);
             BPModel::GetInstance()->BP_StartTimer();//开始计时器,计时结束后自动切换到主界面
         }
+        //界面结果->重新检测
+        else if (strcmp(view.GetViewId(), RE_CLICK_BLOOD_PRESSURE) == 0)
+        {
+            //设置状态为检测状态
+            BPModel::GetInstance()->BP_Control(BPState::BP_DETECTING);
+            BPDetectionView::GetInstance()->ChangeView(RESULT_BPVIEW,CALIBRATION_BPVIEW);
+            BPModel::GetInstance()->BP_StartTimer();//开始计时器,计时结束后自动切换到主界面
+        }
+
         return true;
     }
 
index 36343f1..c1dd0bb 100644 (file)
@@ -51,6 +51,13 @@ namespace OHOS
             g_pBPDetectBeginView = nullptr;
          }
 
+         if(g_pBPDetectEndView)
+         {
+            delete g_pBPDetectEndView;
+            g_pBPDetectEndView = nullptr;
+         }
+         
+
          
         for(int i = 0; i < MAX_BPDECETVIEW; ++i)
         {
@@ -181,6 +188,27 @@ namespace OHOS
         return true;
     }
 
+    bool BPDetectionView::ChangeBPDetectEndView(int16_t thisView)
+    {
+        // 检查视图是否已初始化,避免重复创建
+        if (group[thisView] == nullptr)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodPressureView::ChangeBPDetectEndView");
+            // 创建首次校准视图实例
+            g_pBPDetectEndView = new BPDetectEndView();
+            if (g_pBPDetectEndView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                "BloodPressureView::ChangeBPDetectEndView new BPDetectEndView fail");
+                return false;
+            }
+            // 初始化视图并添加到视图组
+            group[thisView] = g_pBPDetectEndView->BPDetectEndInit();
+            container_->Add(group[thisView]);
+        }
+        return true;
+    }
+
 
     /**
      * 视图映射结构体 - 将视图ID映射到对应的视图切换函数
@@ -195,6 +223,7 @@ namespace OHOS
         {MAIN_BPVIEW, &BPDetectionView::ChangeBPDetectFirstView},
         {SOS_BPVIEW, &BPDetectionView::ChangeBPDetectSOSView},
         {CALIBRATION_BPVIEW, &BPDetectionView::ChangeBPDetectBeginView},
+        {RESULT_BPVIEW, &BPDetectionView::ChangeBPDetectEndView},
     };
 
     bool BPDetectionView::ClickFunc(int16_t interface)
index 731f4d3..f7541d4 100644 (file)
@@ -102,6 +102,7 @@ void BPModel::BP_Control(BPState state)
     */
     BP_StopTimer();
     ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);
+    Time = BP_CHECK_TIME_MAX;
     break;
   }
   case BPState::BP_DETECTING:
@@ -122,6 +123,7 @@ void BPModel::BP_Control(BPState state)
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BP_Control: Invalid state");
     BP_SetState(BPState::BP_NORMAL);
     BP_StopTimer();
+    Time = BP_CHECK_TIME_MAX;
     return;
   }
   //更新状态
@@ -137,6 +139,7 @@ static void BP_TimerCallbackProc(int data) {
   if (Time < 0) 
   {
     BPModel::GetInstance()->BP_StopTimer();
+    BPModel::GetInstance()->BP_SetState(BPState::BP_NORMAL);
     BPMainView* mainView = BPMainView::GetInstance();
     if (mainView) 
     {
@@ -144,7 +147,8 @@ static void BP_TimerCallbackProc(int data) {
     } 
     else if (BPDetectionView::GetInstance()) 
     {
-      BPDetectionView::GetInstance()->ChangeView(CALIBRATION_BPVIEW, MAIN_BPVIEW);
+      //到达结果界面
+      BPDetectionView::GetInstance()->ChangeView(CALIBRATION_BPVIEW, RESULT_BPVIEW);
     }
     return;
   }
@@ -157,6 +161,7 @@ static void BP_TimerCallbackProc(int data) {
   switch (current_state_time) {
     case BPState::BP_NORMAL:
       BPModel::GetInstance()->BP_StopTimer();
+      BPModel::GetInstance()->BP_SetState(BPState::BP_NORMAL);
       return;  
 
     case BPState::BP_DETECTING: {
@@ -185,7 +190,7 @@ static void BP_TimerCallbackProc(int data) {
  * @brief 回调函数
  */
 static void BP_TimerCallback(int data) {
-  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BP_TimerCallback %d", data);
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BP_TimerCallback %d", data);
   GraphicService::GetInstance()->PostGraphicEvent(
       std::bind(BP_TimerCallbackProc, data));
 }
@@ -247,7 +252,6 @@ void BPModel::BP_StopTimer(void) {
                     "osTimerDelete failed, ret = %lx!!", ret);
     }
     g_timer = nullptr;
-    Time = BP_CHECK_TIME_MAX;
   }
 
 }