+/***
+ * @Date: 2024-04-15 10:55:58
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-05-07 17:00:01
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/heartrate/include/HeartBandoffView.h
+ */
/***
* @Date: 2024-04-15 10:55:58
* @LastEditors: Caisking 3449750381@qq.com
#include "heartrate/include/HeartCheckView.h"
#include "heartrate/include/HeartRateView.h"
#include "language/font/ui_resource_string.h"
+#include "uicomponents/UIComponents.h"
namespace OHOS
{
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->SetText(TimeStr.c_str());
+ timeLabel->SetTextId(STR_CHECKTIME);
+ UpdateLabel(timeLabel, TimeStr);
}
else
{
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->SetText(TimeStr.c_str());
+ timeLabel->SetTextId(STR_CHECKTIME);
+ UpdateLabel(timeLabel, TimeStr);
}
else
{
{
InitLabel(label, x, y, width, height, viewId, text, fontName, fontSize);
}
+
+ /*更新label的数字*/
+ void UpdateLabel(UILabelExt *&label, int num)
+ {
+ std::string str = label->GetText();
+ std::string numStr = std::to_string(num);
+ printf("UpdateLabel:%s->%d\r\n", str.c_str(), num);
+
+ // 找到标志"XX"在字符串中的位置
+ size_t pos = str.find("XX");
+ if (pos != std::string::npos)
+ {
+ // 替换标志"XX"为数字字符串
+ str.replace(pos, 2, numStr); // 2 是标志"XX"的长度
+ }
+
+ label->SetText(str.c_str());
+ }
+
+ /*更新label的字符串*/
+ void UpdateLabel(UILabelExt *&label, const std::string updatestr)
+ {
+ std::string str = label->GetText();
+ printf("UpdateLabel:%s->%s\r\n", str.c_str(), updatestr.c_str());
+ // 找到标志"XX"在字符串中的位置
+ size_t pos = str.find("XX");
+ if (pos != std::string::npos)
+ {
+ // 替换标志"XX"为数字字符串
+ str.replace(pos, 2, updatestr); // 2 是标志"XX"的长度
+ }
+
+ label->SetText(str.c_str());
+ }
}
\ No newline at end of file
+/***
+ * @Date: 2024-04-25 10:56:15
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-05-06 18:24:03
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/uicomponents/UIComponents.h
+ */
/***
* @Date: 2024-04-23 16:04:31
* @LastEditors: Caisking 3449750381@qq.com
/*InitLabel[默认参数]*/
void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize = 30, const char *fontName = DEFAULT_VECTOR_FONT_FILENAME);
+ /*更新label的数字*/
+ void UpdateLabel(UILabelExt *&label, int num);
+ /*更新label的字符串*/
+ void UpdateLabel(UILabelExt *&label, const std::string updatestr);
+
}
#endif // UICOMPONENTS_H
\ No newline at end of file