增加更多训练列表;增加资源文件
authorCaisking <3449750381@qq.com>
Fri, 1 Dec 2023 10:11:06 +0000 (18:11 +0800)
committerCaisking <3449750381@qq.com>
Fri, 1 Dec 2023 10:11:06 +0000 (18:11 +0800)
18 files changed:
Resource/res/Training/Ball.bin [new file with mode: 0644]
Resource/res/Training/Dance.bin [new file with mode: 0644]
Resource/res/Training/Fitness.bin [new file with mode: 0644]
Resource/res/Training/Ice.bin [new file with mode: 0644]
Resource/res/Training/Limit.bin [new file with mode: 0644]
Resource/res/Training/Other.bin [new file with mode: 0644]
Resource/res/Training/Rest.bin [new file with mode: 0644]
Resource/res/Training/Swimming.bin [new file with mode: 0644]
Resource/res/Training/icon.bin [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/CMakeLists.txt
code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h
code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp
code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMorePresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMoreView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingPresenter.cpp

diff --git a/Resource/res/Training/Ball.bin b/Resource/res/Training/Ball.bin
new file mode 100644 (file)
index 0000000..df0db80
Binary files /dev/null and b/Resource/res/Training/Ball.bin differ
diff --git a/Resource/res/Training/Dance.bin b/Resource/res/Training/Dance.bin
new file mode 100644 (file)
index 0000000..c892b12
Binary files /dev/null and b/Resource/res/Training/Dance.bin differ
diff --git a/Resource/res/Training/Fitness.bin b/Resource/res/Training/Fitness.bin
new file mode 100644 (file)
index 0000000..30bda6a
Binary files /dev/null and b/Resource/res/Training/Fitness.bin differ
diff --git a/Resource/res/Training/Ice.bin b/Resource/res/Training/Ice.bin
new file mode 100644 (file)
index 0000000..993e7a6
Binary files /dev/null and b/Resource/res/Training/Ice.bin differ
diff --git a/Resource/res/Training/Limit.bin b/Resource/res/Training/Limit.bin
new file mode 100644 (file)
index 0000000..068f4fd
Binary files /dev/null and b/Resource/res/Training/Limit.bin differ
diff --git a/Resource/res/Training/Other.bin b/Resource/res/Training/Other.bin
new file mode 100644 (file)
index 0000000..8248dd3
Binary files /dev/null and b/Resource/res/Training/Other.bin differ
diff --git a/Resource/res/Training/Rest.bin b/Resource/res/Training/Rest.bin
new file mode 100644 (file)
index 0000000..2adb5b0
Binary files /dev/null and b/Resource/res/Training/Rest.bin differ
diff --git a/Resource/res/Training/Swimming.bin b/Resource/res/Training/Swimming.bin
new file mode 100644 (file)
index 0000000..b0dcf9c
Binary files /dev/null and b/Resource/res/Training/Swimming.bin differ
diff --git a/Resource/res/Training/icon.bin b/Resource/res/Training/icon.bin
new file mode 100644 (file)
index 0000000..1a68bf4
Binary files /dev/null and b/Resource/res/Training/icon.bin differ
index 0a6f6e6..0b2844f 100644 (file)
@@ -244,6 +244,8 @@ set(SOURCES
 
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingPresenter.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingMoreView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingMorePresenter.cpp
     #ָ����
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp
index 26c764a..fbf9faf 100644 (file)
@@ -77,6 +77,7 @@ typedef enum : uint16_t
     VIEW_HEARTRATEREMIND,                 // 心率提醒
 
     VIEW_TRAINING,                        // 训练
+    VIEW_TRAININGMORE,                    //更多训练
     VIEW_TRAINING_RECORD,                 // 训练记录
     
     VIEW_BLOODPRESSURE,                   // 昨日睡眠时间
index b1bc6a0..3735e6b 100644 (file)
@@ -63,6 +63,7 @@ public:
        void InitPhoneCallupSlice(void);
        void InitPhoneRingSlice(void);
     void InitTraingSlice(void);
+    void InitTraingMoreSlice(void);
     void InitUIDisplayBrightnessSlice(void);     
     void InitBlueToothSettingSlice(void);        
     void InitBrightnessControlSlice(void);      
index 4c6e8c8..854d18e 100644 (file)
 #include "heartrate/include/HeartRemindView.h"
 #include "traing/include/TraingPresenter.h"
 #include "traing/include/TraingView.h"
+#include "traing/include/TraingMorePresenter.h"
+#include "traing/include/TraingMoreView.h"
 #include "displaybrightness/include/DisplayBrightnessPresenter.h"
 #include "displaybrightness/include/DisplayBrightnessView.h"
 #include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h"
@@ -220,6 +222,7 @@ static const AppViewMapper SLICE_MAPPER[] = {
     {VIEW_HEARTRATEREMIND, &NativeLauncher::InitHeartRemindSlice}, 
 
     {VIEW_TRAINING, &NativeLauncher::InitTraingSlice},              //训练
+    {VIEW_TRAININGMORE, &NativeLauncher::InitTraingMoreSlice},              //训练
 
     {VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice},    //显示与亮度的实例化地址
     {VIEW_CONNECT_BLUETOOTH,&NativeLauncher::InitBlueToothSettingSlice},        //蓝牙设置的实例化地址
@@ -783,7 +786,11 @@ void NativeLauncher::InitTraingSlice(void)
     SliceProxy *traingview = new AbilitySliceProxy<TraingView, TraingPresenter>;
     NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAINING, traingview);
 }
-
+void NativeLauncher::InitTraingMoreSlice(void)
+{
+    SliceProxy *traingmoreview = new AbilitySliceProxy<TraingMoreView, TraingMorePresenter>;
+    NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGMORE, traingmoreview);
+}
 
 //DisplayBrightness的实例化
 void NativeLauncher::InitUIDisplayBrightnessSlice(void)
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMorePresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMorePresenter.h
new file mode 100644 (file)
index 0000000..8685e83
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _TraingMore_PRESENTER_H
+#define _TraingMore_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingMoreView.h"
+
+namespace OHOS
+{
+    class TraingMoreView;
+
+    class TraingMorePresenter : public Presenter<TraingMoreView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingMorePresenter();
+        virtual ~TraingMorePresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingMorePresenter *GetInstance();
+
+    private:
+        // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+    };
+} // namespace OHOS
+
+#endif // SLEEPDETAIL_PRESENTER_H
\ No newline at end of file
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMoreView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingMoreView.h
new file mode 100644 (file)
index 0000000..5e17f88
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef _TraingMore_VIEW_H
+#define _TraingMore_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 "TraingMorePresenter.h"
+namespace OHOS
+{
+#define BUTTON_FITNESS "button1"  // 健身
+#define BUTTON_DANCE "button2"    // 舞蹈
+#define BUTTON_REST "button3"     // 休闲运动
+#define BUTTON_BALL "button4"     // 球类
+#define BUTTON_SWIMMING "button5" // 水上运动
+#define BUTTON_ICE "button6"      // 冰上运动
+#define BUTTON_LIMIT "button7"    // 极限运动
+#define BUTTON_OTHER "button8"    // 其他
+
+    class TraingMorePresenter;
+    class TraingMoreView : public View<TraingMorePresenter>
+    {
+
+    public:
+        TraingMoreView();
+        virtual ~TraingMoreView();
+        static TraingMoreView *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);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingMoreView(TraingMoreView &&) = delete;
+        TraingMoreView &operator=(TraingMoreView &&) = delete;
+
+        UIViewGroup *container_ = nullptr;
+        UIScrollView *scrollView1_ = nullptr;
+        UILabel *label1_ = nullptr;
+        UIImageView *image1_ = nullptr;
+        UIImageView *image2_ = nullptr;
+        UIImageView *image3_ = nullptr;
+        UIImageView *image4_ = nullptr;
+        UIImageView *image5_ = nullptr;
+        UIImageView *image6_ = nullptr;
+        UIImageView *image7_ = nullptr;
+        UIImageView *image8_ = nullptr;
+        UIButton *button1_ = nullptr;
+        UIButton *button2_ = nullptr;
+        UIButton *button3_ = nullptr;
+        UIButton *button4_ = nullptr;
+        UIButton *button5_ = nullptr;
+        UIButton *button6_ = nullptr;
+        UIButton *button7_ = nullptr;
+        UIButton *button8_ = nullptr;
+        UIList *list1_ = nullptr;
+        IconAdapter *list1adapter_ = nullptr;
+        List<IconItemNode *> *list1data_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingMore_PRESENTER_H
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMorePresenter.cpp
new file mode 100644 (file)
index 0000000..c76fd4e
--- /dev/null
@@ -0,0 +1,84 @@
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/include/TraingMorePresenter.h"
+// #include "TraingMoreView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingMorePresenter *g_pTraingMorePresenter = nullptr;
+
+    TraingMorePresenter::TraingMorePresenter()
+    {
+
+        g_pTraingMorePresenter = this;
+    }
+
+    TraingMorePresenter::~TraingMorePresenter()
+    {
+
+        g_pTraingMorePresenter = nullptr;
+    }
+
+    TraingMorePresenter *TraingMorePresenter::GetInstance()
+    {
+
+        return g_pTraingMorePresenter;
+    }
+
+    void TraingMorePresenter::OnStart()
+    {
+
+        Presenter<TraingMoreView>::OnStart();
+    }
+
+    void TraingMorePresenter::OnPause(void)
+    {
+
+        Presenter<TraingMoreView>::OnPause();
+    }
+
+    void TraingMorePresenter::OnResume(void)
+    {
+
+        Presenter<TraingMoreView>::OnResume();
+    }
+
+    void TraingMorePresenter::OnStop(void)
+    {
+
+        Presenter<TraingMoreView>::OnStop();
+    }
+
+    bool TraingMorePresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING);
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingMorePresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), " ") == 0)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+        }
+        if (strcmp(view.GetViewId(), "Remind") == 0)
+        {
+            // 模拟心率监测,等待20秒
+            // std::this_thread::sleep_for(std::chrono::seconds(20));
+            // NativeAbility::GetInstance().ChangeSlice(VIEW_TraingMoreREMIND);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingMoreView.cpp
new file mode 100644 (file)
index 0000000..3d43e72
--- /dev/null
@@ -0,0 +1,411 @@
+
+#include "traing/include/TraingMoreView.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
+{
+    // 定义全局变量
+    char *imagePaths[] = {"/user/res/Training/Fitness.bin",
+                          "/user/res/Training/Dance.bin",
+                          "/user/res/Training/Rest.bin",
+                          "/user/res/Training/Ball.bin",
+                          "/user/res/Training/Swimming.bin",
+                          "/user/res/Training/Ice.bin",
+                          "/user/res/Training/Limit.bin",
+                          "/user/res/Training/Other.bin"};
+
+    char *text[] = {"健身类", "舞蹈类", "休闲运动", "球类", "水上运动", "冰上运动", "极限运动", "其他"};
+    const char *imagePath_iocn = "/user/res/Training/icon.bin";
+
+    static TraingMoreView *g_pTraingMoreView{nullptr};
+
+    TraingMoreView::TraingMoreView()
+    {
+        g_pTraingMoreView = this;
+    }
+
+    TraingMoreView::~TraingMoreView()
+    {
+        DeInit();
+        g_pTraingMoreView = nullptr;
+    }
+
+    TraingMoreView *TraingMoreView::GetInstance()
+    {
+
+        return g_pTraingMoreView;
+    }
+    /*
+    InitLabel:初始化标签
+    @param label 标签指针
+    @param left 标签左边位置
+    @param top 标签顶部位置
+    @param width 标签宽度
+    @param height 标签高度
+    @param viewId 标签的视图 ID
+    @param text 标签显示的文本
+    @param fontName 字体名称
+    @param fontSize 字体大小
+    */
+    void TraingMoreView::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 TraingMoreView::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);
+        // 设置按钮的点击事件监听器为 TraingMorePresenter 的实例
+        button->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingMorePresenter::GetInstance()));
+        // 设置按钮可见
+        button->SetVisible(true);
+    }
+
+    /*
+    InitImageView:初始化图片
+    @param imageView 图片指针
+    @param left 图片左边位置
+    @param top 图片顶部位置
+    @param width 图片宽度
+    @param height 图片高度
+    @param viewId 图片的视图 ID
+    @param imagePath 图片路径
+    */
+    void TraingMoreView::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);
+    }
+
+    /*  Traing:初始化list  */
+    void TraingMoreView::InitList()
+    {
+        // Add List to App
+        if (list1_ == nullptr)
+        {
+            list1_ = new UIList();
+        }
+        list1_->SetPosition(35, 110); // widget's left position and top position
+        list1_->Resize(300, 1100);    // widget's width and height
+        list1_->SetViewId("list1");   // Set style
+        list1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);
+        list1_->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+
+        // Set additional property
+        if (list1data_ == nullptr)
+        {
+            list1data_ = new List<IconItemNode *>();
+        }
+
+        // 使用全局变量来初始化列表项
+        for (int i = 0; i < 8; ++i)
+        {
+            IconItemNode *listData = new IconItemNode();
+            listData->imagePath = imagePaths[i];
+            listData->txt = text[i];
+            list1data_->PushBack(listData);
+        }
+
+        if (list1adapter_ == nullptr)
+        {
+            list1adapter_ = new IconAdapter();
+        }
+        list1adapter_->SetItemSize(250, 120);
+        list1adapter_->SetImageSize(130, 120);
+        list1adapter_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+        list1adapter_->SetData(list1data_);
+        list1_->SetAdapter(list1adapter_);
+
+        // Add to scrollView1
+        // scrollView1_->Add(list1_);
+        list1_->SetVisible(true);
+    }
+    /* InitView:初始化界面*/
+    void TraingMoreView ::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);
+        // Add to rootView
+        container_->Add(scrollView1_);
+        scrollView1_->SetVisible(true);
+
+        // 初始化Lable
+        InitLabel(label1_, 203, 52, 200, 60, "label1", "训练", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        scrollView1_->Add(label1_);
+        // 初始化Button
+        InitButton(button1_, 43, 120, 380, 100, BUTTON_FITNESS);
+        InitButton(button2_, 43, 240, 380, 100, BUTTON_DANCE);
+        InitButton(button1_, 43, 120, 380, 100, BUTTON_FITNESS);
+        InitButton(button2_, 43, 240, 380, 100, BUTTON_DANCE);
+        InitButton(button3_, 43, 360, 380, 100, BUTTON_REST);
+        InitButton(button4_, 43, 480, 380, 100, BUTTON_BALL);
+        InitButton(button5_, 43, 600, 380, 100, BUTTON_SWIMMING);
+        InitButton(button6_, 43, 720, 380, 100, BUTTON_ICE);
+        InitButton(button7_, 43, 840, 380, 100, BUTTON_LIMIT);
+        InitButton(button8_, 43, 960, 380, 100, BUTTON_OTHER);
+        scrollView1_->Add(button1_);
+        scrollView1_->Add(button2_);
+        scrollView1_->Add(button3_);
+        scrollView1_->Add(button4_);
+        scrollView1_->Add(button5_);
+        scrollView1_->Add(button6_);
+        scrollView1_->Add(button7_);
+        scrollView1_->Add(button8_);
+        // 初始化image
+        InitImageView(image1_, 360, 160, 100, 100, "image1", imagePath_iocn);
+        InitImageView(image2_, 360, 280, 100, 100, "image2", imagePath_iocn);
+        InitImageView(image3_, 360, 400, 100, 100, "image3", imagePath_iocn);
+        InitImageView(image4_, 360, 520, 100, 100, "image4", imagePath_iocn);
+        InitImageView(image5_, 360, 640, 100, 100, "image5", imagePath_iocn);
+        InitImageView(image6_, 360, 760, 100, 100, "image6", imagePath_iocn);
+        InitImageView(image7_, 360, 880, 100, 100, "image7", imagePath_iocn);
+        InitImageView(image8_, 360, 1000, 100, 100, "image8", imagePath_iocn);
+        scrollView1_->Add(image1_);
+        scrollView1_->Add(image2_);
+        scrollView1_->Add(image3_);
+        scrollView1_->Add(image4_);
+        scrollView1_->Add(image5_);
+        scrollView1_->Add(image6_);
+        scrollView1_->Add(image7_);
+        scrollView1_->Add(image8_);
+        // 初始化list
+        InitList();
+        scrollView1_->Add(list1_);
+    }
+    /* DeInit:删除组件*/
+    void TraingMoreView::DeInit()
+    {
+        if (label1_ != nullptr)
+        {
+            delete label1_;
+            label1_ = nullptr;
+        }
+        if (button1_ != nullptr)
+        {
+            delete button1_;
+            button1_ = nullptr;
+        }
+        if (button8_ != nullptr)
+        {
+            delete button8_;
+            button8_ = nullptr;
+        }
+        if (button7_ != nullptr)
+        {
+            delete button7_;
+            button7_ = nullptr;
+        }
+        if (button6_ != nullptr)
+        {
+            delete button6_;
+            button6_ = nullptr;
+        }
+        if (button5_ != nullptr)
+        {
+            delete button5_;
+            button5_ = nullptr;
+        }
+        if (button4_ != nullptr)
+        {
+            delete button4_;
+            button4_ = nullptr;
+        }
+        if (button3_ != nullptr)
+        {
+            delete button3_;
+            button3_ = nullptr;
+        }
+        if (button2_ != nullptr)
+        {
+            delete button2_;
+            button2_ = nullptr;
+        }
+        if (image1_ != nullptr)
+        {
+            delete image1_;
+            image1_ = nullptr;
+        }
+        if (image2_ != nullptr)
+        {
+            delete image2_;
+            image2_ = nullptr;
+        }
+        if (image3_ != nullptr)
+        {
+            delete image3_;
+            image3_ = nullptr;
+        }
+        if (image4_ != nullptr)
+        {
+            delete image4_;
+            image4_ = nullptr;
+        }
+        if (image5_ != nullptr)
+        {
+            delete image5_;
+            image5_ = nullptr;
+        }
+        if (image6_ != nullptr)
+        {
+            delete image6_;
+            image6_ = nullptr;
+        }
+        if (image7_ != nullptr)
+        {
+            delete image7_;
+            image7_ = nullptr;
+        }
+        if (image8_ != nullptr)
+        {
+            delete image8_;
+            image8_ = nullptr;
+        }
+        if (list1_ != nullptr)
+        {
+            delete list1_;
+            list1_ = nullptr;
+        }
+        if (list1adapter_ != nullptr)
+        {
+            delete list1adapter_;
+            list1adapter_ = nullptr;
+        }
+        if (list1data_ != nullptr)
+        {
+            list1data_->Clear();
+            delete list1data_;
+            list1data_ = nullptr;
+        }
+        if (scrollView1_ != nullptr)
+        {
+            delete scrollView1_;
+            scrollView1_ = nullptr;
+        }
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
+        }
+    }
+
+    void TraingMoreView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingMoreView::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 *>(TraingMorePresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        container_->SetOnDragListener(draglistener);
+
+        container_->SetTouchable(true);
+        container_->SetDraggable(true);
+
+        PreLoad();
+        RootView::GetInstance()->Add(container_);
+    }
+
+    void TraingMoreView::OnSetUpView()
+    {
+
+        View<TraingMorePresenter>::OnSetUpView();
+        Draw();
+    }
+
+    void TraingMoreView::OnTearDownView()
+    {
+
+        View<TraingMorePresenter>::OnTearDownView();
+        return;
+    }
+
+    void TraingMoreView::OnStop()
+    {
+        View<TraingMorePresenter>::OnStop();
+        RootView::GetInstance()->RemoveAll();
+        return;
+    }
+}
index 7a4bbc2..27334e7 100644 (file)
@@ -69,9 +69,9 @@ namespace OHOS
     bool TraingPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
         // 根据控件id查找是哪个控件触发了点击回调
-        if (strcmp(view.GetViewId(), BUTTON1) == 0)
+        if (strcmp(view.GetViewId(), BUTTONMORE) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGMORE);
         }
         if (strcmp(view.GetViewId(), "Remind") == 0)
         {