From 7379acd2ac1541371359549d05127682a46fcd8a Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Tue, 16 Apr 2024 11:02:17 +0800 Subject: [PATCH] =?utf8?q?=E8=AE=AD=E7=BB=83=E5=90=8C=E6=AD=A5=E9=83=A8?= =?utf8?q?=E5=88=86=E7=BB=93=E6=9D=9F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../traing/include/TraingEnddataView.h | 6 ++-- .../nativeui/traing/include/TraingModel.h | 2 +- .../nativeui/traing/src/TraingEnddataView.cpp | 33 ++++++++++++++++++- .../nativeui/traing/src/TraingWinView.cpp | 6 ++-- 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h index 40669e4aa..f8a12a24c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h @@ -1,4 +1,4 @@ -/*** +/*** * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-04-16 09:27:11 @@ -76,13 +76,13 @@ namespace OHOS UILabelExt *labelmile = nullptr; UILabelExt *labelheart = nullptr; UILabelExt *labelstrong = nullptr; - + UILabelExt *label16_ = nullptr; UILabelExt *label17_ = nullptr; UILabelExt *label18_ = nullptr; UILabelExt *label19_ = nullptr; - UIButton *buttonexit = nullptr; + UILabelButtonExt *buttonexit = nullptr; UIImageView *image1_ = nullptr; UIImageView *image2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index b50ef792c..282677b76 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -237,7 +237,7 @@ namespace OHOS Exercisetype sporttype_ = Exercisetype::FITNESS; // 训练类型 ExerciseState sportstate_ = ExerciseState::General; // 训练状态 int totalHeartRate = 0; - int countHeartRate = 0; + int countHeartRate = 1; /*std::unique_ptr sportdata;*/ // 使用 std::unique_ptr 管理 SportData 对象 }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp index 1d4394fb9..40e949ab9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -119,7 +119,7 @@ namespace OHOS scrollView_->Add(labelnote); // 初始化button - TraingModel::GetInstance()->InitButton(buttonexit, 42, 1319 - 338, 380, 100, BUTTONBACK); + TraingModel::GetInstance()->InitButtonExt(buttonexit, 42, 1319 - 338, 380, 100, BUTTONBACK, STR_OFF, 30); buttonexit->SetOnClickListener(static_cast(TraingEnddataPresenter::GetInstance())); scrollView_->Add(buttonexit); @@ -166,6 +166,36 @@ namespace OHOS void TraingEnddataView::InitData() { + SportData *enddata = TraingModel::GetInstance()->GetSportdata(); + + // 运动项目 + labelsport->SetTextId(enddata->sportId); + + // 运动开始结束时间 + std::string startTimeStr = TraingModel::GetInstance()->AnalysisTimestamp(enddata->starttime); + std::string endTimeStr = TraingModel::GetInstance()->AnalysisTimestamp(enddata->endtime); + std::string durationStr = startTimeStr + "-" + endTimeStr; + labelduration->SetText(durationStr.c_str()); + + // 运动目标 + labeltag->SetText("100%"); // 暂时设置为默认 + + // 运动时长 + uint32_t time = TraingModel::GetInstance()->GetTrainingTime(); + std::string timeStr = TraingModel::GetInstance()->AnalysisTimestamp(time); + labeltime->SetText(timeStr.c_str()); + + // 运动距离 + std::string mileStr = std::to_string(enddata->distance); + labelmile->SetText(mileStr.c_str()); + + // 平均心率 + int heart = TraingModel::GetInstance()->CalculateAverageHeartRate(155); // 设置一个测试值 + std::string heartStr = std::to_string(heart); + labelheart->SetText(heartStr.c_str()); + + // 训练强度 + labelstrong->SetText("中等强度"); } void TraingEnddataView::OnStart() @@ -191,6 +221,7 @@ namespace OHOS container_->SetDraggable(true); PreLoad(); + InitData(); RootView::GetInstance()->Add(container_); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp index 908a263ee..4297dc0a7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp @@ -124,10 +124,10 @@ namespace OHOS TraingModel::GetInstance()->InitLabel(label2_, 70, 215, 326, 97, "label2", "10,000", DEFAULT_VECTOR_FONT_FILENAME, 80); label2_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); container_->Add(label2_); - TraingModel::GetInstance()->InitLabel(label3_, 73, 307, 200, 35, "label3", "完成目标", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(label3_, 103, 307, 200, 35, "label3", "完成目标", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label3_); - TraingModel::GetInstance()->InitLabel(label4_, 193, 307, 160, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); - label4_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + TraingModel::GetInstance()->InitLabel(label4_, 233, 307, 160, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); + // label4_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); container_->Add(label4_); /* -- 2.17.1