-/***
+/***
* @Date: 2024-04-15 10:55:58
* @LastEditors: Caisking 3449750381@qq.com
* @LastEditTime: 2024-04-18 10:23:54
#include "bloodoxygen/include/BloodBandoffView.h"
#include "bloodoxygen/include/BloodCheckView.h"
#include "bloodoxygen/include/BloodResultView.h"
+#include "components/ui_label_button_ext.h"
#include "power_display_service.h"
namespace OHOS
void OnTearDownView() override;
void OnStart() override;
static BloodOxygenView *GetInstance(void);
-
+
bool ChangeBloodView(int16_t thisview); // 主视图
bool ChangeBandoffView(int16_t thisview);
bool ChangeCheckView(int16_t thisview);
void ChangeView(int16_t hideView, int16_t showView);
UIScrollView *GetBloodScrollView(int ViewId);
void UpBloodText();
+
private:
// 增加图片
bool InitImageDisplay(void);
// 初始化标签
bool InitLabel(void);
// 添加label按键
- UILabelButton *CreateAndSetUIButton(const char *title);
+ UILabelButtonExt *CreateAndSetUIButton(const char *title);
// 初始化界面
bool InitBloodView(void);
bool SetOnDragListener(void);
UIScrollView *BloodScrollView[4]{nullptr};
UIViewGroup *group;
- UIImageView *imageViewMain; // 背景图片
- UILabel *percent; // 心率值
- UILabel *timeLabel; // 检测时间
- UILabel *titleLabel; // 页面title
- UILabelButton *testButton; // 检测按键
+ UIImageView *imageViewMain; // 背景图片
+ UILabelExt *percent; // 心率值
+ UILabelExt *timeLabel; // 检测时间
+ UILabelExt *titleLabel; // 页面title
+ UILabelButtonExt *testButton; // 检测按键
const power_display_svr_api_t *display_api = power_display_svr_get_api();
uint32_t display_time;
+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-05-07 18:22:47
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenView.cpp
+ */
/*
* Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
* Description: bloodOxygen view
#include "bloodoxygen/include/BloodOxygenPresenter.h"
#include "displaybrightness/include/DisplayBrightnessModel.h"
#include "power_display_service.h"
+#include "uicomponents/UIComponents.h"
namespace OHOS
{
// 按钮设置
void BloodOxygenView::UpBloodText()
{
// 更新血氧数据
- uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data();
- if (spo2_ != 0) // 判断是否为默认数据
+ uint16_t spo2 = BloodOxygenModel::GetInstance()->GetSPO2data();
+ if (spo2 != 0) // 判断是否为默认数据
{
// 更新数据
- std::string bloodoxygenStr = std::to_string(spo2_);
+ std::string bloodoxygenStr = std::to_string(spo2);
percent->SetText(bloodoxygenStr.c_str());
- // 更新时间
+
+ // 获取时间差
uint32_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime();
uint32_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime();
- std::string TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测";
- timeLabel->SetText(TimeStr.c_str());
+ int time_diff = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time);
+
+ if (time_diff == 0)
+ {
+ timeLabel->SetTextId(STR_CHECKNEW);
+ }
+ else if (time_diff <= 60)
+ {
+ UpdateLabel(timeLabel, time_diff);
+ }
+ else
+ {
+ timeLabel->SetTextId(STR_CHECKLONG);
+ }
}
else
{
percent->SetText("--");
- timeLabel->SetText("暂无检测结果");
+ timeLabel->SetTextId(STR_CHECKNO);
}
}
std::string bloodoxygenStr;
std::string TimeStr;
- percent = new UILabel();
+ percent = new UILabelExt();
if (percent == nullptr)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new percent fail");
percent->Resize(200, 200); // widget's width and height
percent->SetViewId("label2"); // Set style
percent->SetStyle(STYLE_TEXT_FONT, PERCENT_FONT_SIZE);
- uint16_t spo2_ = BloodOxygenModel::GetInstance()->GetSPO2data();
- if (spo2_ != 0)
- {
- bloodoxygenStr = std::to_string(spo2_);
- // 更新时间
- uint64_t time = BloodOxygenPresenter::GetInstance()->GetCurrentTime();
- uint64_t check_time = BloodOxygenModel::GetInstance()->GetCheckTime();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time:%lld check_time:%lld", time, check_time);
- TimeStr = BloodOxygenPresenter::GetInstance()->GetTDOA(time, check_time) + "检测";
- }
- else
- {
- percent->SetText("--");
- TimeStr = "暂无测量数据";
- }
percent->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
percent->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
percent->SetRollSpeed(0);
percent->SetFont(DEFAULT_VECTOR_FONT_FILENAME, PERCENT_FONT_SIZE);
- percent->SetText(bloodoxygenStr.c_str());
/* -------------------------------------------------------------------------- */
- timeLabel = new UILabel();
+ timeLabel = new UILabelExt();
if (timeLabel == nullptr)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new timeLabel fail");
timeLabel->Resize(280, 100); // widget's width and height
timeLabel->SetViewId("label1"); // Set style
timeLabel->SetStyle(STYLE_TEXT_FONT, TIMELABEL_FONT_SIZE);
- /* -------------------------------------------------------------------------- */
- timeLabel->SetText(TimeStr.c_str());
- /* -------------------------------------------------------------------------- */
timeLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS);
timeLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
timeLabel->SetRollSpeed(0);
timeLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TIMELABEL_FONT_SIZE);
- /* -------------------------------------------------------------------------- */
- titleLabel = new UILabel();
+
+ UpBloodText();
+
+ titleLabel = new UILabelExt();
if (titleLabel == nullptr)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new titleLabel fail");
titleLabel->Resize(200, 90); // widget's width and height
titleLabel->SetViewId("label3"); // Set style
titleLabel->SetStyle(STYLE_TEXT_FONT, TITLE_FONT_SIZE);
- titleLabel->SetText("血氧饱和度");
+ titleLabel->SetTextId(STR_BLOOD);
titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
titleLabel->SetRollSpeed(0);
return true;
}
// 创建标签按键
- UILabelButton *BloodOxygenView::CreateAndSetUIButton(const char *title)
+ UILabelButtonExt *BloodOxygenView::CreateAndSetUIButton(const char *title)
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::CreateAndSetUIButton");
- UILabelButton *btn = new UILabelButton();
+ UILabelButtonExt *btn = new UILabelButtonExt();
if (btn == nullptr)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenView::new UILabelButton fail");
}
btn->SetPosition(TESTBUTTON_X, TESTBUTTON_Y, BUTTON_WIDHT2, BUTTON_HEIGHT2);
btn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffcd492c);
- btn->SetText(title);
+ btn->SetTextId(STR_CHECK);
// btn->SetTextColor(Color::Red());
btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
btn->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
}
void HeartView::UpHeartText()
{
- // 更新血氧数据
- uint64_t heart_ = HeartModel::GetInstance()->GetHeartdata();
- std::string heartStr;
- std::string TimeStr;
- if (heart_ != 0) // 判断是否为默认数据
+ // 更新心率数据
+ uint8_t heart = HeartModel::GetInstance()->GetHeartdata();
+ if (heart != 0) // 判断是否为默认数据
{
- heartStr = std::to_string(heart_);
- // 更新时间
- uint64_t time = HeartPresenter::GetInstance()->GetCurrentTime();
- uint64_t check_time = HeartModel::GetInstance()->GetCheckTime();
- TimeStr = HeartPresenter::GetInstance()->GetTDOA(time, check_time) + "检测";
- // timeLabel->SetText(TimeStr.c_str());
- timeLabel->SetTextId(STR_CHECKTIME);
- UpdateLabel(timeLabel, TimeStr);
+ // 更新心率数据
+ std::string heartStr = std::to_string(heart);
+ percent->SetText(heartStr.c_str());
+
+ // 获取时间差
+ uint32_t time = HeartPresenter::GetInstance()->GetCurrentTime();
+ uint32_t check_time = HeartModel::GetInstance()->GetCheckTime();
+ int time_diff = HeartPresenter::GetInstance()->GetTDOA(time, check_time);
+
+ // 更新时间标签
+ if (time_diff == 0)
+ {
+ timeLabel->SetTextId(STR_CHECKNEW);
+ }
+ else if (time_diff <= 60)
+ {
+ UpdateLabel(timeLabel, time_diff);
+ }
+ else
+ {
+ timeLabel->SetTextId(STR_CHECKLONG);
+ }
}
else
{
- heartStr = "--";
- // TimeStr = "暂无检测记录";
+ percent->SetText("--");
timeLabel->SetTextId(STR_CHECKNO);
}
- percent->SetText(heartStr.c_str());
}
// 初始化标签
titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
titleLabel->SetRollSpeed(0);
titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, TITLE_FONT_SIZE);
- /* -------------------------------------------------------------------------- */
- uint64_t heart_ = HeartModel::GetInstance()->GetHeartdata();
- std::string heartStr;
- std::string TimeStr;
- if (heart_ != 0) // 判断是否为默认数据
- {
- heartStr = std::to_string(heart_);
- // 更新时间
- uint64_t time = HeartPresenter::GetInstance()->GetCurrentTime();
- uint64_t check_time = HeartModel::GetInstance()->GetCheckTime();
- TimeStr = HeartPresenter::GetInstance()->GetTDOA(time, check_time) + "检测";
- // timeLabel->SetText(TimeStr.c_str());
- timeLabel->SetTextId(STR_CHECKTIME);
- UpdateLabel(timeLabel, TimeStr);
- }
- else
- {
- heartStr = "--";
- // TimeStr = "暂无检测记录";
- timeLabel->SetTextId(STR_CHECKNO);
- }
- percent->SetText(heartStr.c_str());
+
+ UpHeartText();
/* -------------------------------------------------------------------------- */
return true;
}