修复历史记录逻辑
authorxue <2144439972@qq.com>
Wed, 10 Jun 2026 02:37:02 +0000 (10:37 +0800)
committerxue <2144439972@qq.com>
Wed, 10 Jun 2026 02:37:02 +0000 (10:37 +0800)
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPHistoryView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPMeasureResultView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPMeasuringView.h
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/include/BPViewClickIds.h
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPHistoryView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPInstructionView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPMainPresenter.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPMainView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPMeasureResultView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/bloodpressure/src/BPMeasuringView.cpp
code/sdk/files/n9/fs/user/res/bloodpressure/phone-white.bin [new file with mode: 0644]

index 163165f..e53d2b9 100644 (file)
@@ -21,6 +21,8 @@ public:
   static BPHistoryView *GetInstance();
   UIViewGroup *InitView();
   void RefreshView();
+  void ShowRecentPage();
+  void ShowHistoryScroll();
   void OnRecordPageChanged(uint16_t pageIndex);
   void HideArrowWhileDragging();
   void StartArrowAnimation();
@@ -28,18 +30,22 @@ public:
 
 private:
   UIViewGroup *CreateRecordPage(const struct BPRecord &record, size_t index);
+  UIViewGroup *CreateTipPage();
   void ClearRecordPages();
   void RebuildRecordPages();
+  void InitRecentPage();
   void InitEmptyPage();
   void InitPageIndicator();
   void InitPullDownAnimator();
   void UnloadPullDownAnimator();
+  void UpdateRecentPage();
   void UpdatePageVisibility();
   void UpdateArrowVisibility();
   static bool IsHighBloodPressure(uint8_t sbp, uint8_t dbp);
   static std::string FormatRecordTime(uint32_t timestamp);
 
   UIViewGroup *group_{nullptr};
+  UIViewGroup *recentPage_{nullptr};
   UISwipeView *recordSwipeView_{nullptr};
   UIViewGroup *emptyPage_{nullptr};
   std::vector<UIViewGroup *> recordPages_;
@@ -48,6 +54,19 @@ private:
   const ImageInfo **pullUpImageInfo_{nullptr};
   bool pullDownInited_{false};
 
+  UILabel *recentTitleLabel_{nullptr};
+  UILabel *recentTimeLabel_{nullptr};
+  UIImageView *recentHlineTop_{nullptr};
+  UIImageView *recentHlineBottom_{nullptr};
+  UIImageView *recentVlineMid_{nullptr};
+  UILabelExt *recentSbpTitle_{nullptr};
+  UILabelExt *recentDbpTitle_{nullptr};
+  UILabel *recentSbpValue_{nullptr};
+  UILabel *recentDbpValue_{nullptr};
+  UILabel *recentSbpUnit_{nullptr};
+  UILabel *recentDbpUnit_{nullptr};
+  UILabelButton *historyButton_{nullptr};
+
   UILabel *emptyTitleLabel_{nullptr};
   UIImageView *emptyImage_{nullptr};
   UILabel *emptyHintLabel_{nullptr};
@@ -56,6 +75,7 @@ private:
   UIView *dotHistory_{nullptr};
 
   size_t currentRecordIndex_{0};
+  bool showingHistoryScroll_{false};
 };
 
 } // namespace OHOS
index 0e4d9f2..955ca06 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "components/ui_image_view.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_view_group.h"
 
@@ -38,7 +38,7 @@ private:
   UILabel *dbpValue_{nullptr};
   UILabel *sbpUnit_{nullptr};
   UILabel *dbpUnit_{nullptr};
-  UILabelButton *confirmButton_{nullptr};
+  UILabelButtonExt *confirmButton_{nullptr};
 };
 
 } // namespace OHOS
index 13d2465..d648465 100644 (file)
@@ -15,7 +15,7 @@ public:
   UIViewGroup *InitView();
   void StartMeasuringAnimation();
   void StopMeasuringAnimation();
-  void UpdateProgressPercent(int percent);
+  // void UpdateProgressPercent(int percent);
 
 private:
   bool InitMeasuringAnimator();
index dc3f1be..cadb1c5 100644 (file)
@@ -2,6 +2,8 @@
 #define BP_VIEW_CLICK_IDS_H
 
 #define BP_CLICK_HISTORY "bp_click_history"
+#define BP_CLICK_VIEW_HISTORY "bp_click_view_history"
+#define BP_CLICK_HISTORY_TIP_OK "bp_click_history_tip_ok"
 #define BP_CLICK_INSTRUCTION "bp_click_instruction"
 #define BP_CLICK_MEASURE "bp_click_measure"
 #define BP_CLICK_RECALIBRATE "bp_click_recalibrate"
index bf87fa0..55bfdfe 100644 (file)
@@ -2,6 +2,8 @@
 #include "bloodpressure/include/BPMainPresenter.h"
 #include "bloodpressure/include/BPModel.h"
 #include "components/ui_button.h"
+#include "UiConfig.h"
+#include "color.h"
 #include "common/image_cache_manager.h"
 #include "common/screen.h"
 #include "uicomponents/UIComponents.h"
@@ -11,17 +13,22 @@ namespace OHOS {
 
 namespace {
 static constexpr uint32_t BP_COLOR_LINE = 0xff333333;
-static constexpr int16_t BP_RESULT_LEFT_X = 56;
-static constexpr int16_t BP_RESULT_RIGHT_X = 56+233;
+static constexpr int16_t BP_RESULT_LEFT_X = 26;
+static constexpr int16_t BP_RESULT_RIGHT_X = 26 + 233;
+static constexpr int16_t BP_HISTORY_MAX_ITEMS = 10;
 static constexpr int16_t BP_HISTORY_PULL_X = 213;
 static constexpr int16_t BP_HISTORY_PULL_Y = 360;
 static constexpr int16_t BP_HISTORY_PULL_W = 40;
 static constexpr int16_t BP_HISTORY_PULL_H = 40;
 static constexpr int16_t BP_HISTORY_PULL_NUM = 70;
 static constexpr int16_t BP_HISTORY_PULL_DELAY = 100;
-static constexpr int16_t BP_HISTORY_MAX_ITEMS = 10;
 static constexpr const char *BP_PULLUP_PATH = "/user/res/weather/PullUp/PullUp_";
+static constexpr int16_t BP_HISTORY_BTN_X = 93;
+static constexpr int16_t BP_HISTORY_BTN_Y = 330;
+static constexpr int16_t BP_HISTORY_BTN_W = 280;
+static constexpr int16_t BP_HISTORY_BTN_H = 90;
 static constexpr const char *BP_NO_RECORD_IMAGE = "/user/res/Training/modules/Norecord.bin";
+static constexpr const char *BP_PHONE_IMAGE = "/user/res/bloodpressure/phone-white.bin";
 } // namespace
 
 static BPHistoryView *g_pBPHistoryView = nullptr;
@@ -29,27 +36,38 @@ static BPHistoryView *g_pBPHistoryView = nullptr;
 BPHistoryView::BPHistoryView() { g_pBPHistoryView = this; }
 
 BPHistoryView::~BPHistoryView() {
-  StopArrowAnimation();
-  UnloadPullDownAnimator();
   ClearRecordPages();
   if (group_ != nullptr) {
     group_->RemoveAll();
     delete recordSwipeView_;
+    delete recentPage_;
     delete emptyPage_;
     delete dotEntry_;
     delete dotHistory_;
     delete group_;
     recordSwipeView_ = nullptr;
+    recentPage_ = nullptr;
     emptyPage_ = nullptr;
     dotEntry_ = nullptr;
     dotHistory_ = nullptr;
     group_ = nullptr;
   }
+  recentTitleLabel_ = nullptr;
+  recentTimeLabel_ = nullptr;
+  recentHlineTop_ = nullptr;
+  recentHlineBottom_ = nullptr;
+  recentVlineMid_ = nullptr;
+  recentSbpTitle_ = nullptr;
+  recentDbpTitle_ = nullptr;
+  recentSbpValue_ = nullptr;
+  recentDbpValue_ = nullptr;
+  recentSbpUnit_ = nullptr;
+  recentDbpUnit_ = nullptr;
+  historyButton_ = nullptr;
   emptyTitleLabel_ = nullptr;
   emptyImage_ = nullptr;
   emptyHintLabel_ = nullptr;
   startMeasureButton_ = nullptr;
-  pullDownAnimator_ = nullptr;
   g_pBPHistoryView = nullptr;
 }
 
@@ -145,18 +163,11 @@ void BPHistoryView::UnloadPullDownAnimator() {
 
 //开始箭头动画
 void BPHistoryView::StartArrowAnimation() {
-  const auto &records = BPModel::GetInstance()->GetHistoryRecords();
-  if (records.empty() || currentRecordIndex_ + 1 >= records.size()) {
+  if (!showingHistoryScroll_) {
     StopArrowAnimation();
     return;
   }
-  if (!pullDownInited_) {
-    InitPullDownAnimator();
-  }
-  if (pullDownAnimator_ != nullptr) {
-    pullDownAnimator_->SetVisible(true);
-    pullDownAnimator_->Start();
-  }
+  UpdateArrowVisibility();
 }
 
 //停止箭头动画
@@ -172,7 +183,137 @@ void BPHistoryView::HideArrowWhileDragging() {
     pullDownAnimator_->SetVisible(false);
   }
 }
-//创建记录页面
+
+void BPHistoryView::UpdateArrowVisibility() {
+  if (pullDownAnimator_ == nullptr) {
+    return;
+  }
+  if (!showingHistoryScroll_) {
+    pullDownAnimator_->SetVisible(false);
+    pullDownAnimator_->Stop();
+    return;
+  }
+  size_t totalPages = recordPages_.size();
+  bool hasNext = totalPages > 0 && currentRecordIndex_ + 1 < totalPages;
+  pullDownAnimator_->SetVisible(hasNext);
+  if (hasNext) {
+    pullDownAnimator_->Start();
+  } else {
+    pullDownAnimator_->Stop();
+  }
+}
+
+void BPHistoryView::InitRecentPage() {
+  recentPage_ = new UIViewGroup();
+  if (recentPage_ == nullptr) {
+    return;
+  }
+  recentPage_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+  recentPage_->SetDraggable(true);
+  recentPage_->SetTouchable(true);
+  recentPage_->SetOnDragListener(
+      static_cast<UIView::OnDragListener *>(BPMainPresenter::GetInstance()));
+
+  InitUILabel(recentTitleLabel_, 0, 50, 466, 35, "bp_recent_title", "最新记录",
+              DEFAULT_VECTOR_FONT_FILENAME, 30);
+  recentTitleLabel_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+  recentTitleLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+  InitUILabel(recentTimeLabel_, 0, 93, 466, 33, "bp_recent_time", "--",
+              DEFAULT_VECTOR_FONT_FILENAME, 28);
+  recentTimeLabel_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
+  recentTimeLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+  recentHlineTop_ = new UIImageView();
+  if (recentHlineTop_ != nullptr) {
+    recentHlineTop_->SetPosition(0, 158, 466, 2);
+    recentHlineTop_->SetStyle(STYLE_BACKGROUND_COLOR, BP_COLOR_LINE);
+    recentHlineTop_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+  }
+  recentHlineBottom_ = new UIImageView();
+  if (recentHlineBottom_ != nullptr) {
+    recentHlineBottom_->SetPosition(0, 308, 466, 2);
+    recentHlineBottom_->SetStyle(STYLE_BACKGROUND_COLOR, BP_COLOR_LINE);
+    recentHlineBottom_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+  }
+  recentVlineMid_ = new UIImageView();
+  if (recentVlineMid_ != nullptr) {
+    recentVlineMid_->SetPosition(233, 188, 2, 90);
+    recentVlineMid_->SetStyle(STYLE_BACKGROUND_COLOR, BP_COLOR_LINE);
+    recentVlineMid_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+  }
+
+  InitLabel(recentSbpTitle_, 0, 158 + 30 + 5, 233, 35, "bp_recent_sbp_title", "收缩压",
+            DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabel(recentDbpTitle_, 233, 158 + 30 + 5, 233, 35, "bp_recent_dbp_title", "舒张压",
+            DEFAULT_VECTOR_FONT_FILENAME, 30);
+  recentSbpTitle_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  recentDbpTitle_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  recentSbpTitle_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+  recentDbpTitle_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+
+  InitUILabel(recentSbpValue_, BP_RESULT_LEFT_X, 235, 88, 40, "bp_recent_sbp", "--",
+              DEFAULT_VECTOR_FONT_FILENAME, 40);
+  InitUILabel(recentDbpValue_, BP_RESULT_RIGHT_X, 235, 88, 40, "bp_recent_dbp", "--",
+              DEFAULT_VECTOR_FONT_FILENAME, 40);
+  recentSbpValue_->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
+  recentDbpValue_->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
+
+  InitUILabel(recentSbpUnit_, BP_RESULT_LEFT_X + 4 + 88, 253, 62, 25, "bp_recent_sbp_unit", "mmHg",
+              DEFAULT_VECTOR_FONT_FILENAME, 20);
+  InitUILabel(recentDbpUnit_, BP_RESULT_RIGHT_X + 4 + 88, 253, 62, 25, "bp_recent_dbp_unit", "mmHg",
+              DEFAULT_VECTOR_FONT_FILENAME, 20);
+  recentSbpUnit_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  recentDbpUnit_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  recentSbpUnit_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
+  recentDbpUnit_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
+
+  InitLabelButton(historyButton_, BP_HISTORY_BTN_X, BP_HISTORY_BTN_Y, BP_HISTORY_BTN_W, BP_HISTORY_BTN_H,
+                  BP_CLICK_VIEW_HISTORY, "查看历史", 30);
+  historyButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+  historyButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+  historyButton_->SetStyle(STYLE_BORDER_RADIUS, 45);
+  historyButton_->SetOnClickListener(
+      static_cast<UIView::OnClickListener *>(BPMainPresenter::GetInstance()));
+
+  recentPage_->Add(recentTitleLabel_);
+  recentPage_->Add(recentTimeLabel_);
+  if (recentHlineTop_ != nullptr) {
+    recentPage_->Add(recentHlineTop_);
+  }
+  if (recentVlineMid_ != nullptr) {
+    recentPage_->Add(recentVlineMid_);
+  }
+  recentPage_->Add(recentSbpTitle_);
+  recentPage_->Add(recentDbpTitle_);
+  recentPage_->Add(recentSbpValue_);
+  recentPage_->Add(recentDbpValue_);
+  recentPage_->Add(recentSbpUnit_);
+  recentPage_->Add(recentDbpUnit_);
+  if (recentHlineBottom_ != nullptr) {
+    recentPage_->Add(recentHlineBottom_);
+  }
+  recentPage_->Add(historyButton_);
+}
+
+void BPHistoryView::UpdateRecentPage() {
+  const auto &records = BPModel::GetInstance()->GetHistoryRecords();
+  if (records.empty() || recentTimeLabel_ == nullptr || recentSbpValue_ == nullptr ||
+      recentDbpValue_ == nullptr) {
+    return;
+  }
+  const BPRecord &record = records[0];
+  recentTimeLabel_->SetText(FormatRecordTime(record.timestamp).c_str());
+  recentSbpValue_->SetText(std::to_string(record.sbp).c_str());
+  recentDbpValue_->SetText(std::to_string(record.dbp).c_str());
+  recentSbpValue_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+  recentDbpValue_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+  if (IsHighBloodPressure(record.sbp, record.dbp)) {
+    recentSbpValue_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
+    recentDbpValue_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
+  }
+}
+
 UIViewGroup *BPHistoryView::CreateRecordPage(const BPRecord &record, size_t index) {
   UIViewGroup *page = new UIViewGroup();
   if (page == nullptr) {
@@ -226,9 +367,9 @@ UIViewGroup *BPHistoryView::CreateRecordPage(const BPRecord &record, size_t inde
     vlineMid->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
   }
 
-  InitLabel(sbpTitle, 0, 158+30+5, 233, 35, "bp_history_sbp_title", "收缩压",
+  InitLabel(sbpTitle, 0, 158 + 30 + 5, 233, 35, "bp_history_sbp_title", "收缩压",
             DEFAULT_VECTOR_FONT_FILENAME, 30);
-  InitLabel(dbpTitle, 233, 158+30+5, 233, 35, "bp_history_dbp_title", "舒张压",
+  InitLabel(dbpTitle, 233, 158 + 30 + 5, 233, 35, "bp_history_dbp_title", "舒张压",
             DEFAULT_VECTOR_FONT_FILENAME, 30);
   sbpTitle->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
   dbpTitle->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
@@ -237,21 +378,21 @@ UIViewGroup *BPHistoryView::CreateRecordPage(const BPRecord &record, size_t inde
 
   std::string sbpStr = std::to_string(record.sbp);
   std::string dbpStr = std::to_string(record.dbp);
-  InitUILabel(sbpValue, BP_RESULT_LEFT_X, 250, 58, 28, "bp_history_sbp", sbpStr.c_str(),
+  InitUILabel(sbpValue, BP_RESULT_LEFT_X, 235, 88, 40, "bp_history_sbp", sbpStr.c_str(),
               DEFAULT_VECTOR_FONT_FILENAME, 40);
-  InitUILabel(dbpValue, BP_RESULT_RIGHT_X, 250, 58, 28, "bp_history_dbp", dbpStr.c_str(),
+  InitUILabel(dbpValue, BP_RESULT_RIGHT_X, 235, 88, 40, "bp_history_dbp", dbpStr.c_str(),
               DEFAULT_VECTOR_FONT_FILENAME, 40);
-  sbpValue->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-  dbpValue->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+  sbpValue->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
+  dbpValue->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
 
   if (IsHighBloodPressure(record.sbp, record.dbp)) {
     sbpValue->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
     dbpValue->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
   }
 
-  InitUILabel(sbpUnit, BP_RESULT_LEFT_X+4, 264, 62, 14, "bp_history_sbp_unit", "mmHg",
+  InitUILabel(sbpUnit, BP_RESULT_LEFT_X + 4 + 88, 253, 62, 25, "bp_history_sbp_unit", "mmHg",
               DEFAULT_VECTOR_FONT_FILENAME, 20);
-  InitUILabel(dbpUnit, BP_RESULT_RIGHT_X+4, 264, 62, 14, "bp_history_dbp_unit", "mmHg",
+  InitUILabel(dbpUnit, BP_RESULT_RIGHT_X + 4 + 88, 253, 62, 25, "bp_history_dbp_unit", "mmHg",
               DEFAULT_VECTOR_FONT_FILENAME, 20);
   sbpUnit->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
   dbpUnit->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
@@ -278,7 +419,51 @@ UIViewGroup *BPHistoryView::CreateRecordPage(const BPRecord &record, size_t inde
   return page;
 }
 
-//重建记录页面
+UIViewGroup *BPHistoryView::CreateTipPage() {
+  UIViewGroup *page = new UIViewGroup();
+  if (page == nullptr) {
+    return nullptr;
+  }
+  page->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+
+  UILabel *titleLabel = nullptr;
+  UIImageView *phoneIcon = nullptr;
+  UILabel *hintLine1 = nullptr;
+  UILabel *hintLine2 = nullptr;
+  UILabelButton *tipOkButton = nullptr;
+
+  InitUILabel(titleLabel, 0, 50, 466, 35, "bp_history_tip_title", "提示",
+              DEFAULT_VECTOR_FONT_FILENAME, 30);
+  titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+  InitImageView(phoneIcon, 193, 120, 80, 80, "bp_history_tip_phone", BP_PHONE_IMAGE);
+
+  InitUILabel(hintLine1, 53, 240, 360, 35, "bp_history_tip_hint1", "在APP中查看完整血压记录",
+              DEFAULT_VECTOR_FONT_FILENAME, 28);
+  hintLine1->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+  InitUILabel(hintLine2, 53, 280, 360, 35, "bp_history_tip_hint2", "手表仅保留最近记录",
+              DEFAULT_VECTOR_FONT_FILENAME, 28);
+  hintLine2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+
+  InitLabelButton(tipOkButton, BP_HISTORY_BTN_X, BP_HISTORY_BTN_Y, BP_HISTORY_BTN_W, BP_HISTORY_BTN_H,
+                  BP_CLICK_HISTORY_TIP_OK, "知道了", 30);
+  tipOkButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+  tipOkButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED);
+  tipOkButton->SetStyle(STYLE_BORDER_RADIUS, 45);
+  tipOkButton->SetOnClickListener(
+      static_cast<UIView::OnClickListener *>(BPMainPresenter::GetInstance()));
+
+  page->Add(titleLabel);
+  if (phoneIcon != nullptr) {
+    page->Add(phoneIcon);
+  }
+  page->Add(hintLine1);
+  page->Add(hintLine2);
+  page->Add(tipOkButton);
+  return page;
+}
+
 void BPHistoryView::RebuildRecordPages() {
   if (recordSwipeView_ == nullptr) {
     return;
@@ -298,11 +483,16 @@ void BPHistoryView::RebuildRecordPages() {
     recordSwipeView_->Add(page);
     recordPages_.push_back(page);
   }
+  UIViewGroup *tipPage = CreateTipPage();
+  if (tipPage != nullptr) {
+    tipPage->SetViewIndex(static_cast<uint16_t>(count));
+    recordSwipeView_->Add(tipPage);
+    recordPages_.push_back(tipPage);
+  }
   recordSwipeView_->SetCurrentPage(0, false);
   currentRecordIndex_ = 0;
 }
 
-//初始化空页面
 void BPHistoryView::InitEmptyPage() {
   emptyPage_ = new UIViewGroup();
   if (emptyPage_ == nullptr) {
@@ -339,45 +529,50 @@ void BPHistoryView::InitEmptyPage() {
   emptyPage_->Add(startMeasureButton_);
 }
 
-//更新箭头可见性
-void BPHistoryView::UpdateArrowVisibility() {
-  if (pullDownAnimator_ == nullptr) {
-    return;
-  }
-  const auto &records = BPModel::GetInstance()->GetHistoryRecords();
-  size_t count = records.size();
-  if (count > BP_HISTORY_MAX_ITEMS) {
-    count = BP_HISTORY_MAX_ITEMS;
-  }
-  bool hasNext = count > 0 && currentRecordIndex_ + 1 < count;
-  pullDownAnimator_->SetVisible(hasNext);
-  if (hasNext) {
-    pullDownAnimator_->Start();
-  } else {
-    pullDownAnimator_->Stop();
-  }
-}
-
-//更新页面可见性
 void BPHistoryView::UpdatePageVisibility() {
   const auto &records = BPModel::GetInstance()->GetHistoryRecords();
   bool hasRecords = !records.empty();
-  if (recordSwipeView_ != nullptr) {
-    recordSwipeView_->SetVisible(hasRecords);
+  if (recentPage_ != nullptr) {
+    recentPage_->SetVisible(hasRecords && !showingHistoryScroll_);
   }
-  if (pullDownAnimator_ != nullptr) {
-    pullDownAnimator_->SetVisible(hasRecords);
+  if (recordSwipeView_ != nullptr) {
+    recordSwipeView_->SetVisible(hasRecords && showingHistoryScroll_);
+    recordSwipeView_->SetDraggable(hasRecords && showingHistoryScroll_);
   }
   if (emptyPage_ != nullptr) {
     emptyPage_->SetVisible(!hasRecords);
   }
   if (dotEntry_ != nullptr && dotHistory_ != nullptr) {
-    dotEntry_->SetVisible(!hasRecords);
-    dotHistory_->SetVisible(!hasRecords);
+    bool showDots = hasRecords && !showingHistoryScroll_;
+    dotEntry_->SetVisible(showDots);
+    dotHistory_->SetVisible(showDots);
+  }
+  UpdateArrowVisibility();
+}
+
+void BPHistoryView::ShowRecentPage() {
+  showingHistoryScroll_ = false;
+  UpdateRecentPage();
+  UpdatePageVisibility();
+  if (recordSwipeView_ != nullptr) {
+    recordSwipeView_->SetCurrentPage(0, false);
+  }
+  currentRecordIndex_ = 0;
+  if (group_ != nullptr) {
+    group_->Invalidate();
+  }
+}
+
+void BPHistoryView::ShowHistoryScroll() {
+  showingHistoryScroll_ = true;
+  RebuildRecordPages();
+  UpdatePageVisibility();
+  StartArrowAnimation();
+  if (group_ != nullptr) {
+    group_->Invalidate();
   }
 }
 
-//记录页面改变
 void BPHistoryView::OnRecordPageChanged(uint16_t pageIndex) {
   currentRecordIndex_ = pageIndex;
   UpdateArrowVisibility();
@@ -386,17 +581,16 @@ void BPHistoryView::OnRecordPageChanged(uint16_t pageIndex) {
   }
 }
 
-//刷新页面
 void BPHistoryView::RefreshView() {
+  showingHistoryScroll_ = false;
+  UpdateRecentPage();
   RebuildRecordPages();
   UpdatePageVisibility();
-  UpdateArrowVisibility();
   if (group_ != nullptr) {
     group_->Invalidate();
   }
 }
 
-//初始化页面
 UIViewGroup *BPHistoryView::InitView() {
   group_ = new UIViewGroup();
   if (group_ == nullptr) {
@@ -412,13 +606,15 @@ UIViewGroup *BPHistoryView::InitView() {
   recordSwipeView_->SetPosition(0, 0, Screen::GetInstance().GetWidth(),
                                 Screen::GetInstance().GetHeight());
   recordSwipeView_->SetAnimatorTime(50);
-  recordSwipeView_->SetDraggable(true);
+  recordSwipeView_->SetDraggable(false);
   recordSwipeView_->SetTouchable(true);
+  recordSwipeView_->SetVisible(false);
   auto *presenter = static_cast<BPMainPresenter *>(BPMainPresenter::GetInstance());
   recordSwipeView_->SetOnDragListener(presenter);
   recordSwipeView_->SetOnSwipeListener(presenter);
 
   InitPullDownAnimator();
+  InitRecentPage();
   InitEmptyPage();
   InitPageIndicator();
 
@@ -426,6 +622,9 @@ UIViewGroup *BPHistoryView::InitView() {
   if (pullDownAnimator_ != nullptr) {
     group_->Add(pullDownAnimator_);
   }
+  if (recentPage_ != nullptr) {
+    group_->Add(recentPage_);
+  }
   if (emptyPage_ != nullptr) {
     group_->Add(emptyPage_);
   }
index 2101df4..3dee2da 100644 (file)
@@ -52,6 +52,7 @@ void BPInstructionView::ApplyInstructionType(BPInstructionType type) {
       instructionLabel_->SetText("表带过松\n请调整松紧后重试");
       instructionLabel_->SetPosition(113, 230, 240, 70);
       measureButton_->SetText("重新测量");
+      measureButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffff5a36);
       break;
     case BP_INSTRUCTION_TYPE_FIRST:
       imageView_->SetSrc(BLOOD_PATH_FIRST);
@@ -87,6 +88,7 @@ UIViewGroup *BPInstructionView::InitView(BPInstructionType type) {
   instructionLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
   InitLabelButton(backButton_, 58, 320, 170, 90, BP_CLICK_INSTRUCTION_BACK, "取消", 26);
   InitLabelButton(measureButton_, 238, 320, 170, 90, BP_CLICK_MEASURE, "开始", 26);
+  measureButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff0176ff);
 
   ApplyInstructionType(type);
 
index 6904bbd..a6e81c1 100644 (file)
@@ -250,12 +250,7 @@ bool BPMainPresenter::PollPpgResult() {
 }
 
 void BPMainPresenter::UpdateProgressUi(int percent) {
-  if (progressMode_ == BPProgressMode::Measure) {
-    BPMeasuringView *view = BPMeasuringView::GetInstance();
-    if (view != nullptr) {
-      view->UpdateProgressPercent(percent);
-    }
-  } else if (progressMode_ == BPProgressMode::Calibrate) {
+ if (progressMode_ == BPProgressMode::Calibrate) {
     BPCalibratingView *view = BPCalibratingView::GetInstance();
     if (view != nullptr) {
       view->UpdateProgress(percent);
@@ -446,6 +441,20 @@ bool BPMainPresenter::OnClick(UIView &view, const ClickEvent &event) {
     mainView->ChangeView(BP_HISTORY_VIEW, BP_ENTRY_VIEW);
     return true;
   }
+  if (viewId == BP_CLICK_VIEW_HISTORY) {
+    BPHistoryView *historyView = BPHistoryView::GetInstance();
+    if (historyView != nullptr) {
+      historyView->ShowHistoryScroll();
+    }
+    return true;
+  }
+  if (viewId == BP_CLICK_HISTORY_TIP_OK) {
+    BPHistoryView *historyView = BPHistoryView::GetInstance();
+    if (historyView != nullptr) {
+      historyView->ShowRecentPage();
+    }
+    return true;
+  }
   if (viewId == BP_CLICK_INSTRUCTION_BACK) {
     mainView->ChangeView(BP_INSTRUCTION_VIEW, BP_ENTRY_VIEW);
     return true;
index 208ba4b..8e7ada6 100644 (file)
@@ -369,7 +369,7 @@ void BPMainView::ChangeView(int16_t hideView, int16_t showView, int16_t type) {
   currentViewId_ = showView;
   if (showView == BP_MEASURING_VIEW && measuringView_ != nullptr) {
     measuringView_->StartMeasuringAnimation();
-    measuringView_->UpdateProgressPercent(0);
+    // measuringView_->UpdateProgressPercent(0);
   }
   if (showView == BP_HISTORY_VIEW && historyView_ != nullptr) {
     historyView_->RefreshView();
index 93a8253..15cb2ab 100644 (file)
@@ -2,6 +2,8 @@
 #include "bloodpressure/include/BPMainPresenter.h"
 #include "bloodpressure/include/BPModel.h"
 #include "bloodpressure/include/BPViewClickIds.h"
+#include "UiConfig.h"
+#include "color.h"
 #include "securec.h"
 #include "uicomponents/UIComponents.h"
 #include <ctime>
@@ -10,9 +12,8 @@ namespace OHOS {
 
 namespace {
 static constexpr uint32_t BP_COLOR_LINE = 0xff333333;
-static constexpr int16_t BP_RESULT_COL_W = 170;
-static constexpr int16_t BP_RESULT_LEFT_X = 58;
-static constexpr int16_t BP_RESULT_RIGHT_X = 238;
+static constexpr int16_t BP_RESULT_LEFT_X = 26;
+static constexpr int16_t BP_RESULT_RIGHT_X = 26 + 233;
 } // namespace
 
 static BPMeasureResultView *g_instance = nullptr;
@@ -186,40 +187,48 @@ UIViewGroup *BPMeasureResultView::InitView() {
 
   InitDividerLines();
 
-  InitLabel(sbpTitle_, BP_RESULT_LEFT_X, 140, BP_RESULT_COL_W, 30, "bp_result_sbp_title", "收缩压",
-            DEFAULT_VECTOR_FONT_FILENAME, 22);
-  InitLabel(dbpTitle_, BP_RESULT_RIGHT_X, 140, BP_RESULT_COL_W, 30, "bp_result_dbp_title", "舒张压",
-            DEFAULT_VECTOR_FONT_FILENAME, 22);
+  InitLabel(sbpTitle_, 0, 158 + 30 + 5, 233, 35, "bp_result_sbp_title", "收缩压",
+            DEFAULT_VECTOR_FONT_FILENAME, 30);
+  InitLabel(dbpTitle_, 233, 158 + 30 + 5, 233, 35, "bp_result_dbp_title", "舒张压",
+            DEFAULT_VECTOR_FONT_FILENAME, 30);
   sbpTitle_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
   dbpTitle_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
   sbpTitle_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
   dbpTitle_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
 
-  InitUILabel(sbpValue_, BP_RESULT_LEFT_X, 178, BP_RESULT_COL_W, 64, "bp_result_sbp", "--",
-              DEFAULT_VECTOR_FONT_FILENAME, 56);
-  InitUILabel(dbpValue_, BP_RESULT_RIGHT_X, 178, BP_RESULT_COL_W, 64, "bp_result_dbp", "--",
-              DEFAULT_VECTOR_FONT_FILENAME, 56);
-  sbpValue_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-  dbpValue_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-
-  InitUILabel(sbpUnit_, BP_RESULT_LEFT_X, 248, BP_RESULT_COL_W, 28, "bp_result_sbp_unit", "mmHg",
-              DEFAULT_VECTOR_FONT_FILENAME, 22);
-  InitUILabel(dbpUnit_, BP_RESULT_RIGHT_X, 248, BP_RESULT_COL_W, 28, "bp_result_dbp_unit", "mmHg",
-              DEFAULT_VECTOR_FONT_FILENAME, 22);
+  InitUILabel(sbpValue_, BP_RESULT_LEFT_X, 235, 88, 40, "bp_result_sbp", "--",
+              DEFAULT_VECTOR_FONT_FILENAME, 40);
+  InitUILabel(dbpValue_, BP_RESULT_RIGHT_X, 235, 88, 40, "bp_result_dbp", "--",
+              DEFAULT_VECTOR_FONT_FILENAME, 40);
+  sbpValue_->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
+  dbpValue_->SetAlign(TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_CENTER);
+
+  InitUILabel(sbpUnit_, BP_RESULT_LEFT_X + 4 + 88, 253, 62, 25, "bp_result_sbp_unit", "mmHg",
+              DEFAULT_VECTOR_FONT_FILENAME, 20);
+  InitUILabel(dbpUnit_, BP_RESULT_RIGHT_X + 4 + 88, 253, 62, 25, "bp_result_dbp_unit", "mmHg",
+              DEFAULT_VECTOR_FONT_FILENAME, 20);
   sbpUnit_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
   dbpUnit_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
   sbpUnit_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
   dbpUnit_->SetTextColor(Color::GetColorFromRGBA(0x99, 0x99, 0x99, 0xff));
 
-  InitLabel(statusLabel_, 0, 292, 466, 35, "bp_result_status", "血压处于正常范围",
-            DEFAULT_VECTOR_FONT_FILENAME, 26);
+  InitLabel(statusLabel_, 0, 322, 466, 35, "bp_result_status", "血压处于正常范围",
+            DEFAULT_VECTOR_FONT_FILENAME, 30);
   statusLabel_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
 
-  InitLabelButton(confirmButton_, 93, 330, 280, 90, BP_CLICK_CONFIRM, "确定", 30);
-  confirmButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
-  confirmButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED);
-  confirmButton_->SetStyle(STYLE_BORDER_RADIUS, 45);
-  confirmButton_->SetOnClickListener(static_cast<UIView::OnClickListener *>(BPMainPresenter::GetInstance()));
+  confirmButton_ = new UILabelButtonExt();
+  if (confirmButton_ != nullptr) {
+    confirmButton_->SetPosition(0, 366, 466, 100);
+    confirmButton_->SetViewId(BP_CLICK_CONFIRM);
+    confirmButton_->SetText("确定");
+    confirmButton_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+    confirmButton_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff));
+    confirmButton_->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
+    confirmButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0x00, UIButton::PRESSED);
+    confirmButton_->SetAlign(TEXT_ALIGNMENT_CENTER);
+    confirmButton_->SetOnClickListener(
+        static_cast<UIView::OnClickListener *>(BPMainPresenter::GetInstance()));
+  }
 
   group_->Add(titleLabel_);
   group_->Add(timeLabel_);
@@ -239,7 +248,9 @@ UIViewGroup *BPMeasureResultView::InitView() {
     group_->Add(hlineBottom_);
   }
   group_->Add(statusLabel_);
-  group_->Add(confirmButton_);
+  if (confirmButton_ != nullptr) {
+    group_->Add(confirmButton_);
+  }
 
   UpdateText();
   return group_;
index 5c6cbd5..5e141fe 100644 (file)
@@ -145,21 +145,21 @@ UIViewGroup *BPMeasuringView::InitView() {
   return group_;
 }
 
-void BPMeasuringView::UpdateProgressPercent(int percent) {
-  if (noteLabel_ == nullptr) {
-    return;
-  }
-  if (percent < 0) {
-    percent = 0;
-  } else if (percent > 100) {
-    percent = 100;
-  }
-  char buf[32] = {0};
-  if (sprintf_s(buf, sizeof(buf), "请保持静止 %d%%", percent) < 0) {
-    noteLabel_->SetText("请保持静止");
-    return;
-  }
-  noteLabel_->SetText(buf);
-}
+// void BPMeasuringView::UpdateProgressPercent(int percent) {
+//   if (noteLabel_ == nullptr) {
+//     return;
+//   }
+//   if (percent < 0) {
+//     percent = 0;
+//   } else if (percent > 100) {
+//     percent = 100;
+//   }
+//   char buf[32] = {0};
+//   if (sprintf_s(buf, sizeof(buf), "请保持静止 %d%%", percent) < 0) {
+//     noteLabel_->SetText("请保持静止");
+//     return;
+//   }
+//   noteLabel_->SetText(buf);
+// }
 
 } // namespace OHOS
diff --git a/code/sdk/files/n9/fs/user/res/bloodpressure/phone-white.bin b/code/sdk/files/n9/fs/user/res/bloodpressure/phone-white.bin
new file mode 100644 (file)
index 0000000..1a7379a
Binary files /dev/null and b/code/sdk/files/n9/fs/user/res/bloodpressure/phone-white.bin differ