From: Caisking <3449750381@qq.com> Date: Tue, 30 Jul 2024 11:51:09 +0000 (+0800) Subject: 优化主界面血氧卡片 X-Git-Tag: release_V1.2.70_20241020_135402~730^2~6 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=6419d8f3f5a6c657372be445b5b156b9f3d7fca9;p=mirrors%2FFD230.git 优化主界面血氧卡片 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp index 371aa602a..8959d10a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.cpp @@ -9,9 +9,13 @@ #include "components/ui_view_group.h" #include "DialModelSPO2.h" #include "DialModelHeartRate.h" -#include "BloodOxygenModel.h" -#include "BloodOxygenPresenter.h" + #include "UiConfig.h" +#include "uicomponents/UIComponents.h" +#include "MainPresenterSample.h" + +#include "bloodoxygen/include/BloodResultPresenter.h" +#include "bloodoxygen/include/BloodOxygenModel.h" namespace OHOS { static BloodCardView *g_pBloodCardView{nullptr}; @@ -43,13 +47,13 @@ namespace OHOS if (spo2 != 0) // 判断是否为默认数据 { // 更新数据 - std::string bloodoxygenStr = std::to_string(spo2); + std::string bloodoxygenStr = std::to_string(spo2) + "%"; bloodLabel->SetText(bloodoxygenStr.c_str()); // 获取时间差 - uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime(); + uint32_t time = BloodResultPresenter::GetInstance()->GetCurrentTime(); uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime(); - int time_diff = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time); + int time_diff = BloodResultPresenter::GetInstance()->GetTDOA(time, check_time); if (time_diff == 0) { @@ -78,6 +82,13 @@ namespace OHOS */ bool BloodCardView::AddButton() { + InitButtonExt(checkButton, 118, 336, 230, 80, MAIN_CLICK_BLOOD, STR_CHECK, 30); + checkButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF5A36); // 设置按键颜色 + // 设置按键监听 + UIView::OnClickListener *clickListener = (UIView::OnClickListener *)OHOS::MainPresenterSample::GetInstance(); + checkButton->SetOnClickListener(clickListener); + + Add(checkButton); return true; } /*** @@ -86,75 +97,22 @@ namespace OHOS */ bool BloodCardView::InitLable() { - // Add Label to App - if (bloodLabel == nullptr) - { - bloodLabel = new UILabel(); - } - bloodLabel->SetPosition(83, 108); // widget's left position and top position - bloodLabel->Resize(300, 250); // widget's width and height - bloodLabel->SetViewId("label2"); // Set style - bloodLabel->SetStyle(STYLE_TEXT_FONT, 150); + /*初始化title*/ + InitLabelExt(titleLabel, 83, 50, 300, 35, "title", STR_BLOOD, DEFAULT_VECTOR_FONT_FILENAME, 30); + /*初始化血氧值label*/ + InitUILabel(bloodLabel, 83, 22, 300, 300, "bloodtext", "--", DEFAULT_VECTOR_FONT_FILENAME, 120); + /*初始化检测时间*/ + InitLabelExt(timeLabel, 53, 260, 360, 35, "time", STR_CHECKNO, DEFAULT_VECTOR_FONT_FILENAME, 30); + // 设置来回滚动属性 + timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + timeLabel->SetRollSpeed(70); - // Set additional property - bloodoxygen = BloodOxygenModel::GetInstance()->GetSPO2data(); - if (bloodoxygen != 0) - { - std::string bloodoxygenStr = std::to_string(bloodoxygen); - bloodLabel->SetText(bloodoxygenStr.c_str()); - } - else - { - bloodLabel->SetText("--"); - } - bloodLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - bloodLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - bloodLabel->SetRollSpeed(0); - bloodLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 150); + UpSPO2Text(); - // Add to rootView + Add(titleLabel); Add(bloodLabel); - - /* -------------------------------------------------------------------------- */ - timeLabel = new UILabelExt(); - if (timeLabel == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new timeLabel fail"); - return false; - } - timeLabel->SetPosition(90, 300); // widget's left position and top position - timeLabel->Resize(280, 100); // widget's width and height - timeLabel->SetViewId("label1"); // Set style - timeLabel->SetStyle(STYLE_TEXT_FONT, 30); - timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - timeLabel->SetRollSpeed(0); - timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to rootView Add(timeLabel); - UpSPO2Text(); - - // Add Label to App - if (titleLabel == nullptr) - { - titleLabel = new UILabel(); - } - titleLabel->SetPosition(158, 70); // widget's left position and top position - titleLabel->Resize(200, 90); // widget's width and height - titleLabel->SetViewId("label3"); // Set style - titleLabel->SetStyle(STYLE_TEXT_FONT, 28); - - // Set additional property - titleLabel->SetText("血氧饱和度"); - titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - titleLabel->SetRollSpeed(0); - titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 28); - - // Add to rootView - Add(titleLabel); return true; } /*** @@ -163,16 +121,13 @@ namespace OHOS */ bool BloodCardView::Initbackground() { - // Add ImageView to App - if (background == nullptr) - { - background = new UIImageView(); - } + + background = new UIImageView(); + background->SetPosition(0, 0); // widget's left position and top position background->Resize(466, 466); // widget's width and height background->SetViewId("image1"); // Set style - // Add to rootView Add(background); return true; } @@ -211,16 +166,6 @@ namespace OHOS delete background; background = nullptr; } - if (warnButton != nullptr) - { - delete warnButton; - warnButton = nullptr; - } - if (monitorButton != nullptr) - { - delete monitorButton; - monitorButton = nullptr; - } if (bloodLabel != nullptr) { delete bloodLabel; @@ -254,7 +199,7 @@ namespace OHOS resLoadStatus = true; } } - + /*卸载血氧图片资源*/ void BloodCardView::UnLoadBloodImageRes(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h index 66bb6a66b..8678423ce 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h @@ -1,4 +1,10 @@ -/*** +/*** + * @Date: 2024-06-28 16:08:09 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-29 11:48:50 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/heart_blood/BloodCardView.h + */ +/*** * @Date: 2024-06-26 16:13:19 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-06-26 16:52:01 @@ -19,12 +25,12 @@ #include "components/ui_image_animator.h" #include "components/ui_label_button_ext.h" #include "components/ui_card_page.h" +#include "components/ui_label_button_ext.h" namespace OHOS { -#define WARNING "button1" -#define CHECK "button2" +#define CHECK "buttoncheck" class BloodCardView : public UICardPage { @@ -49,6 +55,7 @@ namespace OHOS private: void PreLoadBloodImageRes(void); void UnLoadBloodImageRes(void); + private: UIView::OnDragListener *draglistener{nullptr}; BloodCardView(BloodCardView &&) = delete; @@ -57,9 +64,11 @@ namespace OHOS UIImageView *background = nullptr; UIButton *warnButton = nullptr; UILabelButton *monitorButton = nullptr; - UILabel *titleLabel = nullptr; - UILabel *bloodLabel = nullptr; + UILabelExt *titleLabel = nullptr; UILabelExt *timeLabel = nullptr; + UILabel *bloodLabel = nullptr; + + UILabelButtonExt *checkButton; bool viewiInitStatus{false}; bool resLoadStatus{false};