From: Caisking <3449750381@qq.com> Date: Mon, 22 Apr 2024 08:28:19 +0000 (+0800) Subject: 训练结果增加步数 X-Git-Tag: release_V1.2.70_20241020_135402~1152 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=9259f23214e7c176e598c73ef8efe0e5dfb20598;p=mirrors%2FFD230.git 训练结果增加步数 --- 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 0e30b4b0e..9051d072d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h @@ -70,12 +70,14 @@ namespace OHOS UILabelExt *labelustrong = nullptr; UILabelExt *labelnote = nullptr; UILabelExt *labelduration = nullptr; + UILabelExt *labelusteps = nullptr; UILabelExt *labeltag = nullptr; UILabelExt *labeltime = nullptr; UILabelExt *labelmile = nullptr; UILabelExt *labelheart = nullptr; UILabelExt *labelstrong = nullptr; + UILabelExt *labelsteps = nullptr; UILabelButtonExt *buttonexit = nullptr; @@ -86,7 +88,7 @@ namespace OHOS UIImageView *imageLine5 = nullptr; UIImageView *imageLine6 = nullptr; UIImageView *imageLine7 = nullptr; - + UIImageView *imageLine8 = nullptr; bool viewiInitStatus{false}; }; 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 c26c62d01..b66925f7c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -65,11 +65,13 @@ namespace OHOS TraingModel::GetInstance()->InitImageView(imageLine4, 97, 474, 80, 20, "image9", LINE_IMAGE); TraingModel::GetInstance()->InitImageView(imageLine5, 97, 604, 80, 20, "image10", LINE_IMAGE); TraingModel::GetInstance()->InitImageView(imageLine6, 97, 734, 80, 20, "image11", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(imageLine7, 97, 864, 80, 20, "image12", LINE_IMAGE); scrollView_->Add(imageLine2); scrollView_->Add(imageLine3); scrollView_->Add(imageLine4); scrollView_->Add(imageLine5); scrollView_->Add(imageLine6); + scrollView_->Add(imageLine7); scrollView_->Add(imageIcon); // 初始化Lable @@ -81,8 +83,9 @@ namespace OHOS TraingModel::GetInstance()->InitLabel(labelutime, 146, 382, 240, 40, "label9", "训练时长", DEFAULT_VECTOR_FONT_FILENAME, 30); TraingModel::GetInstance()->InitLabel(labelumile, 146, 512, 240, 40, "label10", "距离(ç±³)", DEFAULT_VECTOR_FONT_FILENAME, 30); TraingModel::GetInstance()->InitLabel(labeluheart, 146, 642, 240, 40, "label11", "平均心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 30); - TraingModel::GetInstance()->InitLabel(labelustrong, 146, 772, 240, 40, "label2", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 30); - TraingModel::GetInstance()->InitLabel(labelnote, 80, 894, 300, 40, "label8", "更多数据请前往手机APP查看", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelusteps, 146, 772, 240, 40, "label12", "步数", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelustrong, 146, 902, 240, 40, "label2", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelnote, 80, 1024, 300, 40, "label8", "更多请前往手机APP查看", DEFAULT_VECTOR_FONT_FILENAME, 30); // 设置文本颜色 labelduration->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); @@ -101,7 +104,9 @@ namespace OHOS labelmile->SetTextColor(Color::GetColorFromRGBA(0x36, 0x4a, 0xff, 0xff)); TraingModel::GetInstance()->InitLabel(labelheart, 146, 678, 240, 60, "label16", "144", DEFAULT_VECTOR_FONT_FILENAME, 40); labelheart->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); - TraingModel::GetInstance()->InitLabel(labelstrong, 146, 808, 240, 60, "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabel(labelsteps, 146, 808, 240, 60, "label16", "5000", DEFAULT_VECTOR_FONT_FILENAME, 40); + labelsteps->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + TraingModel::GetInstance()->InitLabel(labelstrong, 146, 938, 240, 60, "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 30); labelstrong->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); scrollView_->Add(labeltype); @@ -112,12 +117,15 @@ namespace OHOS scrollView_->Add(labelumile); scrollView_->Add(labeluheart); scrollView_->Add(labelustrong); + scrollView_->Add(labelusteps); + scrollView_->Add(labeltag); scrollView_->Add(labelduration); scrollView_->Add(labelmile); scrollView_->Add(labelheart); scrollView_->Add(labelstrong); scrollView_->Add(labelnote); + scrollView_->Add(labelsteps); // 初始化button TraingModel::GetInstance()->InitButtonExt(buttonexit, 42, 1319 - 338, 380, 100, BUTTONBACK, STR_OFF, 30); @@ -150,6 +158,11 @@ namespace OHOS delete labelutag; labelutag = nullptr; } + if (labelusteps != nullptr) + { + delete labelusteps; + labelusteps = nullptr; + } if (labelumile != nullptr) { @@ -201,6 +214,11 @@ namespace OHOS delete labelstrong; labelstrong = nullptr; } + if (labelsteps != nullptr) + { + delete labelsteps; + labelsteps = nullptr; + } /*按键*/ if (buttonexit != nullptr) { @@ -262,7 +280,7 @@ namespace OHOS // 训练图标Icon std::string imageStr = TraingModel::GetInstance()->GetSportType(); imageIcon->SetSrc(imageStr.c_str()); - + // 运动项目 labelsport->SetTextId(enddata->sportId); @@ -277,9 +295,9 @@ namespace OHOS { // labeltag->SetText("100%"); // 暂时设置为默认 int currentdata = TraingModel::GetInstance()->GetSportTypeData(); - float completeness = (currentdata / enddata->tag) * 100; - completeness = round(completeness); // 四舍五入? - std::string tagStr = std::to_string(completeness) + "%"; + float completeness = (static_cast(currentdata) / enddata->tag) * 100; + completeness = round(completeness); // 四舍五入 + std::string tagStr = std::to_string(static_cast(completeness)) + "%"; labeltag->SetText(tagStr.c_str()); } // 运动时长 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp index 8f0474e54..9375a7c8d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp @@ -27,94 +27,7 @@ namespace OHOS return g_pTraingRecordView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingRecordView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingRecordView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingRecordPresenter 的实例 - button->SetOnClickListener(static_cast(TraingRecordPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingRecordView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingRecordView ::InitView() {