--- /dev/null
+
+#include "traing/include/TraingView.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 TraingView *g_pTraingView{nullptr};
+
+ TraingView::TraingView()
+ {
+
+ g_pTraingView = this;
+ }
+
+ TraingView::~TraingView()
+ {
+ DeInit();
+ g_pTraingView = nullptr;
+ }
+
+ TraingView *TraingView::GetInstance()
+ {
+
+ return g_pTraingView;
+ }
+
+ void TraingView::Init()
+ {
+ if (container_ == nullptr)
+ {
+ container_ = new UIViewGroup();
+ container_->SetPosition(0, 0, 466, 466);
+ container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
+ }
+
+ // Add Label to App
+ if (label1_ == nullptr)
+ {
+ label1_ = new UILabel();
+ }
+ label1_->SetPosition(173, 52); // widget's left position and top position
+ label1_->Resize(200, 60); // widget's width and height
+ label1_->SetViewId("label1"); // Set style
+ label1_->SetStyle(STYLE_TEXT_FONT, 30);
+
+ // Set additional property
+ label1_->SetText("快速训练");
+ label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label1_->SetRollSpeed(0);
+ label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+
+ // Add to rootView
+ container_->Add(label1_);
+ label1_->SetVisible(true);
+
+ // Add Button to App
+ if (button3_ == nullptr)
+ {
+ button3_ = new UIButton();
+ }
+ button3_->SetPosition(236, 268); // widget's left position and top position
+ button3_->Resize(140, 140); // widget's width and height
+ button3_->SetViewId(BUTTONMORE); // Set style
+ button3_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button3_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+#ifdef _WIN32
+ char *button3defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/More.bin";
+#else
+ const char *button3defaultImgSrc = PNG_TRAING_BOUTTONMORE_IMAGE;
+#endif
+ char *button3triggeredImgSrc = nullptr;
+ button3_->SetImageSrc(button3defaultImgSrc, button3triggeredImgSrc);
+ button3_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);
+ button3_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ button3_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnClickListener *button3Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());
+ button3_->SetOnClickListener(button3Click);
+ // Add to rootView
+ container_->Add(button3_);
+ button3_->SetVisible(true);
+
+ // Add Button to App
+ if (button4_ == nullptr)
+ {
+ button4_ = new UIButton();
+ }
+ button4_->SetPosition(86, 118); // widget's left position and top position
+ button4_->Resize(140, 140); // widget's width and height
+ button4_->SetViewId(BUTTON2); // Set style
+ button4_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button4_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+#ifdef _WIN32
+ char *button4defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Buttonground2.bin";
+#else
+ const char *button4defaultImgSrc = PNG_TRAING_BUTTONGRONG2_IMAGE;
+#endif
+ char *button4triggeredImgSrc = nullptr;
+ button4_->SetImageSrc(button4defaultImgSrc, button4triggeredImgSrc);
+ button4_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);
+ button4_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ button4_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnClickListener *button4Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());
+ button4_->SetOnClickListener(button4Click);
+ // Add to rootView
+ container_->Add(button4_);
+ button4_->SetVisible(true);
+
+ // Add Button to App
+ if (button1_ == nullptr)
+ {
+ button1_ = new UIButton();
+ }
+ button1_->SetPosition(86, 268); // widget's left position and top position
+ button1_->Resize(140, 140); // widget's width and height
+ button1_->SetViewId(BUTTON3); // Set style
+ button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+#ifdef _WIN32
+ char *button1defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Bouttonground.bin";
+#else
+ const char *button1defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE;
+#endif
+ char *button1triggeredImgSrc = nullptr;
+ button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
+ button1_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);
+ button1_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ button1_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnClickListener *button1Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());
+ button1_->SetOnClickListener(button1Click);
+ // Add to rootView
+ container_->Add(button1_);
+ button1_->SetVisible(true);
+
+ // Add Button to App
+ if (button2_ == nullptr)
+ {
+ button2_ = new UIButton();
+ }
+ button2_->SetPosition(236, 118); // widget's left position and top position
+ button2_->Resize(140, 140); // widget's width and height
+ button2_->SetViewId(BUTTON1); // Set style
+ button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+ button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+ // Set additional property
+#ifdef _WIN32
+ char *button2defaultImgSrc = "c:/Users/caiking/project/image_converter_tool/output/Training/Bouttonground.bin";
+#else
+ const char *button2defaultImgSrc = PNG_TRAING_BUTTONGRONG_IMAGE;
+#endif
+ char *button2triggeredImgSrc = nullptr;
+ button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc);
+ button2_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff33df1c, UIButton::PRESSED);
+ button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+ button2_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);
+
+ // Add the CallBack about events
+ UIView::OnClickListener *button2Click = static_cast<UIView::OnClickListener *>(TraingPresenter::GetInstance());
+ button2_->SetOnClickListener(button2Click);
+ // Add to rootView
+ container_->Add(button2_);
+ button2_->SetVisible(true);
+
+ // Add ImageView to App
+ if (image1_ == nullptr)
+ {
+ image1_ = new UIImageView();
+ }
+ image1_->SetPosition(276, 148); // widget's left position and top position
+ image1_->Resize(100, 100); // widget's width and height
+ image1_->SetViewId("image2"); // Set style
+
+ // Set additional property
+#ifdef _WIN32
+ char *image1imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/riding-big2.bin";
+#else
+ const char *image1imagesPath = PNG_TRAING_RIDINGBIG_IMAGE;
+#endif
+ image1_->SetSrc(image1imagesPath);
+
+ // Add to rootView
+ container_->Add(image1_);
+ image1_->SetVisible(true);
+
+ // Add Label to App
+ if (label2_ == nullptr)
+ {
+ label2_ = new UILabel();
+ }
+ label2_->SetPosition(286, 210); // widget's left position and top position
+ label2_->Resize(200, 60); // widget's width and height
+ label2_->SetViewId("label2"); // Set style
+ label2_->SetStyle(STYLE_TEXT_FONT, 20);
+
+ // Set additional property
+ label2_->SetText("骑行");
+ label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label2_->SetRollSpeed(0);
+ label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
+
+ // Add to rootView
+ container_->Add(label2_);
+ label2_->SetVisible(true);
+
+ // Add ImageView to App
+ if (image3_ == nullptr)
+ {
+ image3_ = new UIImageView();
+ }
+ image3_->SetPosition(126, 298); // widget's left position and top position
+ image3_->Resize(100, 100); // widget's width and height
+ image3_->SetViewId("image3"); // Set style
+
+ // Set additional property
+#ifdef _WIN32
+ char *image3imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/running-big.bin";
+#else
+ const char *image3imagesPath = PNG_TRAING_RUNNINGBIG_IMAGE;
+#endif
+ image3_->SetSrc(image3imagesPath);
+
+ // Add to rootView
+ container_->Add(image3_);
+ image3_->SetVisible(true);
+
+ // Add Label to App
+ if (label3_ == nullptr)
+ {
+ label3_ = new UILabel();
+ }
+ label3_->SetPosition(135, 210); // widget's left position and top position
+ label3_->Resize(200, 60); // widget's width and height
+ label3_->SetViewId("label3"); // Set style
+ label3_->SetStyle(STYLE_TEXT_FONT, 20);
+
+ // Set additional property
+ label3_->SetText("健走");
+ label3_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ label3_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label3_->SetRollSpeed(0);
+ label3_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
+
+ // Add to rootView
+ container_->Add(label3_);
+ label3_->SetVisible(true);
+
+ // Add ImageView to App
+ if (image5_ == nullptr)
+ {
+ image5_ = new UIImageView();
+ }
+ image5_->SetPosition(126, 148); // widget's left position and top position
+ image5_->Resize(100, 100); // widget's width and height
+ image5_->SetViewId("image1"); // Set style
+
+ // Set additional property
+#ifdef _WIN32
+ char *image5imagesPath = "c:/Users/caiking/project/image_converter_tool/output/Training/walking-big.bin";
+#else
+ const char *image5imagesPath = PNG_TRAING_WALKINGBIG_IMAGE;
+#endif
+ image5_->SetSrc(image5imagesPath);
+
+ // Add to rootView
+ container_->Add(image5_);
+ image5_->SetVisible(true);
+
+ // Add Label to App
+ if (label4_ == nullptr)
+ {
+ label4_ = new UILabel();
+ }
+ label4_->SetPosition(131, 365); // widget's left position and top position
+ label4_->Resize(200, 60); // widget's width and height
+ label4_->SetViewId("label4"); // Set style
+ label4_->SetStyle(STYLE_TEXT_FONT, 20);
+
+ // Set additional property
+ label4_->SetText("跑步");
+ label4_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+ label4_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+ label4_->SetRollSpeed(0);
+ label4_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
+
+ // Add to rootView
+ container_->Add(label4_);
+ label4_->SetVisible(true);
+ }
+
+ void TraingView::DeInit()
+ {
+ if (container_ != nullptr)
+ {
+ container_->RemoveAll();
+ delete container_;
+ container_ = nullptr;
+ }
+ if (label1_ != nullptr)
+ {
+ delete label1_;
+ label1_ = nullptr;
+ }
+ if (button3_ != nullptr)
+ {
+ delete button3_;
+ button3_ = nullptr;
+ }
+ if (button4_ != nullptr)
+ {
+ delete button4_;
+ button4_ = nullptr;
+ }
+ if (button1_ != nullptr)
+ {
+ delete button1_;
+ button1_ = nullptr;
+ }
+ if (button2_ != nullptr)
+ {
+ delete button2_;
+ button2_ = nullptr;
+ }
+ if (image1_ != nullptr)
+ {
+ delete image1_;
+ image1_ = nullptr;
+ }
+ if (label2_ != nullptr)
+ {
+ delete label2_;
+ label2_ = nullptr;
+ }
+ if (image3_ != nullptr)
+ {
+ delete image3_;
+ image3_ = nullptr;
+ }
+ if (label3_ != nullptr)
+ {
+ delete label3_;
+ label3_ = nullptr;
+ }
+ if (image5_ != nullptr)
+ {
+ delete image5_;
+ image5_ = nullptr;
+ }
+ if (label4_ != nullptr)
+ {
+ delete label4_;
+ label4_ = nullptr;
+ }
+ }
+
+ UIView *TraingView::GetView()
+ {
+ Init();
+ return container_;
+ }
+
+ void TraingView::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 *>(TraingPresenter::GetInstance());
+ if (draglistener == nullptr)
+ {
+ return;
+ }
+ container_->SetOnDragListener(draglistener);
+
+ container_->SetTouchable(true);
+ container_->SetDraggable(true);
+
+ GetView();
+ RootView::GetInstance()->Add(container_);
+ }
+
+ void TraingView::OnSetUpView()
+ {
+
+ View<TraingPresenter>::OnSetUpView();
+ Draw();
+ }
+
+ void TraingView::OnTearDownView()
+ {
+
+ View<TraingPresenter>::OnTearDownView();
+ return;
+ }
+
+ void TraingView::OnStop()
+ {
+ View<TraingPresenter>::OnStop();
+ RootView::GetInstance()->RemoveAll();
+ return;
+ }
+}