--- /dev/null
+#ifndef _TraingStrong_VIEW_H
+#define _TraingStrong_VIEW_H
+
+#include "BaseView.h"
+#include "View.h"
+#include <ui_scroll_view.h>
+#include "components/ui_view_group.h"
+#include "components/ui_label.h"
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_image_animator.h"
+#include "components/ui_label_button_ext.h"
+#include "components/ui_chart.h"
+#include "components/ui_list.h"
+#include "components/icon_adapter.h"
+#include "wearable_log.h"
+#include "ohos_types.h"
+#include "components/ui_card_page.h"
+
+#include "TraingStrongPresenter.h"
+namespace OHOS
+{
+#define BUTTONNO "button1"
+#define BUTTONYES "button2"
+
+ class TraingStrongPresenter;
+ class TraingStrongView : public View<TraingStrongPresenter>
+ {
+
+ public:
+ TraingStrongView();
+ virtual ~TraingStrongView();
+ static TraingStrongView *GetInstance(void);
+
+ void OnStart() override;
+ void OnSetUpView() override;
+ void OnTearDownView() override;
+ void OnStop() override;
+ void InitView();
+ void DeInit();
+ void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
+ void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId);
+ void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath);
+ void InitList();
+ void PreLoad(void);
+
+ // 通过函数改变
+ void SetLabel();
+ void SetButton();
+
+ private:
+ UIView::OnDragListener *draglistener{nullptr};
+ TraingStrongView(TraingStrongView &&) = delete;
+ TraingStrongView &operator=(TraingStrongView &&) = delete;
+
+ UIViewGroup *container_ = nullptr;
+ UIScrollView *scrollView1_ = nullptr;
+
+ UILabel *label1_ = nullptr;
+ UILabel *label2_ = nullptr;
+ UILabel *label3_ = nullptr;
+ UILabel *label4_ = nullptr;
+ UILabel *label5_ = nullptr;
+ UILabel *label6_ = nullptr;
+
+ UIImageView *image1_ = nullptr;
+ UIImageView *image2_ = nullptr;
+ UIImageView *image3_ = nullptr;
+ UIImageView *image4_ = nullptr;
+ UIImageView *image5_ = nullptr;
+ bool viewiInitStatus{false};
+ };
+} // namespace OHOS
+#endif // TraingStrong_PRESENTER_H
--- /dev/null
+
+#include "traing/include/TraingStrongView.h"
+
+#include "common/image_cache_manager.h"
+#include "UiConfig.h"
+#include "ui_resource_image.h"
+#include <ui_scroll_view.h>
+#include "components/ui_button.h"
+namespace OHOS
+{
+ static const char *imagePath_blue = "/user/res/Training/bule.bin";
+ static const char *imagePath_yellow = "/user/res/Training/yellow.bin";
+ static const char *imagePath_orange = "/user/res/Training/orange.bin";
+ static const char *imagePath_green = "/user/res/Training/green.bin";
+
+ static TraingStrongView *g_pTraingStrongView{nullptr};
+
+ TraingStrongView::TraingStrongView()
+ {
+ g_pTraingStrongView = this;
+ }
+
+ TraingStrongView::~TraingStrongView()
+ {
+ DeInit();
+ g_pTraingStrongView = nullptr;
+ }
+
+ TraingStrongView *TraingStrongView::GetInstance()
+ {
+
+ return g_pTraingStrongView;
+ }
+ /*
+ InitLabel:初始化标签
+ @param label 标签指针
+ @param left 标签左边位置
+ @param top 标签顶部位置
+ @param width 标签宽度
+ @param height 标签高度
+ @param viewId 标签的视图 ID
+ @param text 标签显示的文本
+ @param fontName 字体名称
+ @param fontSize 字体大小
+ */
+ void TraingStrongView::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(top, left);
+ label->Resize(width, height);
+ // 设置标签的视图 ID
+ label->SetViewId(viewId);
+ // 设置标签的样式
+ label->SetStyle(STYLE_LINE_HEIGHT, 40);
+ 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 TraingStrongView::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);
+ // 设置按钮的点击事件监听器为 TraingStrongPresenter 的实例
+ button->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingStrongPresenter::GetInstance()));
+ // 设置按钮可见
+ button->SetVisible(true);
+ }
+ /*
+ InitImageView:初始化图片
+ @param imageView 图片指针
+ @param left 图片左边位置
+ @param top 图片顶部位置
+ @param width 图片宽度
+ @param height 图片高度
+ @param viewId 图片的视图 ID
+ @param imagePath 图片路径
+ */
+ void TraingStrongView::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(top, left);
+ imageView->Resize(width, height);
+ imageView->SetViewId(viewId);
+ imageView->SetSrc(imagePath);
+ imageView->SetVisible(true);
+ }
+ /* InitView:初始化界面*/
+ void TraingStrongView ::InitView()
+ {
+ if (container_ == nullptr)
+ {
+ container_ = new UIViewGroup();
+ container_->SetPosition(0, 0, 466, 466);
+ container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ }
+ // Add ScrollView to App
+ if (scrollView1_ == nullptr)
+ {
+ scrollView1_ = new UIScrollView();
+ }
+ scrollView1_->SetPosition(0, 0); // widget's left position and top position
+ scrollView1_->Resize(466, 466); // widget's width and height
+ scrollView1_->SetViewId("scrollView1"); // Set style
+ scrollView1_->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+ scrollView1_->SetReboundSize(100);
+ scrollView1_->SetScrollBlankSize(52);
+ scrollView1_->SetHorizontalScrollState(false);
+ // Set additional property
+ // Add to rootView
+ container_->Add(scrollView1_);
+ scrollView1_->SetVisible(true);
+
+ // 初始化Lable
+ InitLabel(label1_, 52, 173, 120, 35, "label1", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 30);
+ InitLabel(label2_, 133, 33, 60, 35, "label2", "训练强度用于判断是否训练不足或\n者训练太过,到底使心率增加多少\n的运动强度才是最合适的。", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ InitLabel(label3_, 305, 33, 69, 23, "label3", "该强度区间是对应靶心率(由个人\n基本资料计算得出)强弱的实时状\n态显示,有助于提高训练质量。", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ InitLabel(label4_, 465, 33, 60, 35, "label4", "训练状态代表的意义:", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ InitLabel(label5_, 505, 97, 60, 35, "label5", "较低强度-热身运动\n中等强度-燃脂区\n高等强度-提升心肺机能\n超高强度-专业运动员", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ InitLabel(label6_, 740, 51, 60, 35, "label5", "注:该训练强度并非专业运动评\n估,数据仅供参考。", DEFAULT_VECTOR_FONT_FILENAME, 26);
+ label6_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff));
+ scrollView1_->Add(label1_);
+ scrollView1_->Add(label2_);
+ scrollView1_->Add(label3_);
+ scrollView1_->Add(label4_);
+ scrollView1_->Add(label5_);
+ scrollView1_->Add(label6_);
+
+ // 初始化Image
+ InitImageView(image1_, 510, 60, 100, 100, "image1", imagePath_blue);
+ InitImageView(image2_, 550, 60, 100, 100, "image2", imagePath_green);
+ InitImageView(image3_, 590, 60, 100, 100, "image3", imagePath_orange);
+ InitImageView(image4_, 630, 60, 100, 100, "image4", imagePath_yellow);
+ scrollView1_->Add(image1_);
+ scrollView1_->Add(image2_);
+ scrollView1_->Add(image3_);
+ scrollView1_->Add(image4_);
+
+ // Add ImageView to App
+ if (image5_ == nullptr)
+ {
+ image5_ = new UIImageView();
+ }
+ image5_->SetPosition(183, 813); // widget's left position and top position
+ image5_->Resize(100, 100); // widget's width and height
+ image5_->SetViewId("image3"); // Set style
+ // Set additional property
+ // Add to scrollView2
+ scrollView1_->Add(image5_);
+ image5_->SetVisible(true);
+ }
+ /* DeInit:删除组件 */
+ void TraingStrongView::DeInit()
+ {
+ UIView *view = static_cast<UIViewGroup *>(container_)->GetChildrenHead();
+ while (view != nullptr)
+ {
+ UIView *tempView = view;
+ view = view->GetNextSibling();
+ if (tempView->GetParent())
+ {
+ static_cast<UIViewGroup *>(tempView->GetParent())->Remove(tempView);
+ }
+ delete tempView;
+ }
+ delete container_;
+ container_ = nullptr;
+ }
+
+ void TraingStrongView::PreLoad(void)
+ {
+ if (!viewiInitStatus)
+ {
+ InitView();
+ viewiInitStatus = true;
+ }
+ }
+ void TraingStrongView::OnStart()
+ {
+ container_ = new UIViewGroup();
+ if (container_ == nullptr)
+ {
+ return;
+ }
+ container_->SetPosition(0, 0);
+ container_->SetWidth(Screen::GetInstance().GetWidth());
+ container_->SetHeight(Screen::GetInstance().GetHeight());
+
+ // 创建 draglistener 实例并设置为拖动监听器
+ UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingStrongPresenter::GetInstance());
+ if (draglistener == nullptr)
+ {
+ return;
+ }
+ container_->SetOnDragListener(draglistener);
+
+ container_->SetTouchable(true);
+ container_->SetDraggable(true);
+
+ PreLoad();
+ RootView::GetInstance()->Add(container_);
+ }
+
+ void TraingStrongView::OnSetUpView()
+ {
+
+ View<TraingStrongPresenter>::OnSetUpView();
+ Draw();
+ }
+
+ void TraingStrongView::OnTearDownView()
+ {
+
+ View<TraingStrongPresenter>::OnTearDownView();
+ return;
+ }
+
+ void TraingStrongView::OnStop()
+ {
+ View<TraingStrongPresenter>::OnStop();
+ RootView::GetInstance()->RemoveAll();
+ return;
+ }
+}