增加GPS训练目标选择;增加距离目标滚动条;步数目标滚动条
authorCaisking <3449750381@qq.com>
Wed, 13 Dec 2023 11:04:28 +0000 (19:04 +0800)
committerCaisking <3449750381@qq.com>
Wed, 13 Dec 2023 11:04:28 +0000 (19:04 +0800)
22 files changed:
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/TraingGPSsetPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSsetView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetDistPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetDistView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetSeptPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetSeptView.h [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlackPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnotePresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSsetPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSsetView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetCaluliPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetDistPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetDistView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetPresenter.cpp
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetSeptPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetSeptView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetTimePresenter.cpp

index cf7b694..5e088c4 100755 (executable)
@@ -252,6 +252,12 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingNomalPresenter.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetView.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetPresenter.cpp\r
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSsetView.cpp\r
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSsetPresenter.cpp\r
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetDistView.cpp\r
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetDistPresenter.cpp\r
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetSeptView.cpp\r
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetSeptPresenter.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetTimeView.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetTimePresenter.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetCaluliView.cpp\r
@@ -274,6 +280,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSlackPresenter.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSnoteView.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSnotePresenter.cpp\r
+\r
     #ָ����\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp\r
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassCalibrationView.cpp\r
index c1b85fd..dffae12 100755 (executable)
@@ -81,8 +81,11 @@ typedef enum : uint16_t
     VIEW_TRAININGLIMIT,                   // 极限运动子列表\r
     VIEW_TRAININGNOMAL,                   // 正常训练开始界面(除骑行,健走,跑步外)\r
     VIEW_TRAININGSET,                     // 训练目标(时长,卡路里)\r
+    VIEW_TRAININGGPSSET,                  // GPS训练目标(时长,距离,卡路里,步数)\r
     VIEW_TRAININGSETTIME,                 // 设置训练时长\r
     VIEW_TRAININGSETCALULI,               // 设置训练卡路里\r
+    VIEW_TRAININGSETDIST,                 // 设置训练路程\r
+    VIEW_TRAININGSETSTEP,                 // 设置训练步数\r
     VIEW_TRAININGCRAD,                    // 训练卡片\r
     VIEW_TRAININGCONTROL,                 // 训练控制(包括结束,暂停,继续训练)\r
     VIEW_TRAININGDATA,                    // 训练数据\r
index 3684c83..a256f1e 100755 (executable)
@@ -67,8 +67,11 @@ public:
     void InitTraingLimitSlice(void);\r
     void InitTraingNomalSlice(void);\r
     void InitTraingSetSlice(void);\r
+    void InitTraingGPSSetSlice(void);\r
     void InitTraingSetTimeSlice(void);\r
     void InitTraingSetCaluliSlice(void);\r
+    void InitTraingSetDistSlice(void);\r
+    void InitTraingSetStepSlice(void);\r
     void InitTraingControlSlice(void);\r
     void InitTraingCardSlice(void);\r
     void InitTraingDataSlice(void);\r
index d211d99..5423a84 100755 (executable)
 #include "traing/include/TraingNomalView.h"\r
 #include "traing/include/TraingSetPresenter.h"\r
 #include "traing/include/TraingSetView.h"\r
+#include "traing/include/TraingGPSsetPresenter.h"\r
+#include "traing/include/TraingGPSsetView.h"\r
 #include "traing/include/TraingSetTimePresenter.h"\r
 #include "traing/include/TraingSetTimeView.h"\r
 #include "traing/include/TraingSetCaluliPresenter.h"\r
 #include "traing/include/TraingSetCaluliView.h"\r
+#include "traing/include/TraingSetDistPresenter.h"\r
+#include "traing/include/TraingSetDistView.h"\r
+#include "traing/include/TraingSetSeptPresenter.h"\r
+#include "traing/include/TraingSetSeptView.h"\r
 #include "traing/include/TraingControlPresenter.h"\r
 #include "traing/include/TraingControlView.h"\r
 #include "traing/include/TraingCardPresenter.h"\r
@@ -281,8 +287,11 @@ static const AppViewMapper SLICE_MAPPER[] = {
     {VIEW_TRAININGLIMIT, &NativeLauncher::InitTraingLimitSlice},                //极限训练\r
     {VIEW_TRAININGNOMAL, &NativeLauncher::InitTraingNomalSlice},                //正常训练初始界面\r
     {VIEW_TRAININGSET, &NativeLauncher::InitTraingSetSlice},                    //训练目标设置界面\r
+    {VIEW_TRAININGGPSSET, &NativeLauncher::InitTraingGPSSetSlice},              //训练GPS目标设置界面\r
     {VIEW_TRAININGSETTIME, &NativeLauncher::InitTraingSetTimeSlice},            //设置目标时长\r
     {VIEW_TRAININGSETCALULI, &NativeLauncher::InitTraingSetCaluliSlice},        //设置目标卡路里\r
+    {VIEW_TRAININGSETDIST, &NativeLauncher::InitTraingSetDistSlice},            //设置目标距离    \r
+    {VIEW_TRAININGSETSTEP, &NativeLauncher::InitTraingSetStepSlice},            //设置目标步数\r
     {VIEW_TRAININGCONTROL, &NativeLauncher::InitTraingControlSlice},            //训练控制\r
     {VIEW_TRAININGCRAD, &NativeLauncher::InitTraingCardSlice},                  //训练卡片\r
     {VIEW_TRAININGDATA, &NativeLauncher::InitTraingDataSlice},                  //训练数据 \r
@@ -290,8 +299,9 @@ static const AppViewMapper SLICE_MAPPER[] = {
     {VIEW_TRAININGENDNOTE, &NativeLauncher::InitTraingEndnoteSlice},            //训练结束提醒\r
     {VIEW_TRAININGENDDATA, &NativeLauncher::InitTraingEnddataSlice},            //训练结束详细数据 \r
     {VIEW_TRAININGGPS, &NativeLauncher::InitTraingGPSSlice},                    //GPS训练\r
-    {VIEW_TRAININGGPSLACK, &NativeLauncher::InitTraingGPSlackSlice},                    //GPS训练\r
-    {VIEW_TRAININGGPSNOTE, &NativeLauncher::InitTraingGPSnoteSlice},                    //GPS训练\r
+    {VIEW_TRAININGGPSLACK, &NativeLauncher::InitTraingGPSlackSlice},            //GPS缺少\r
+    {VIEW_TRAININGGPSNOTE, &NativeLauncher::InitTraingGPSnoteSlice},            //提醒连接GPS\r
+\r
 \r
     {VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice},    //显示与亮度的实例化地址\r
     {VIEW_CONNECT_BLUETOOTH,&NativeLauncher::InitBlueToothSettingSlice},        //蓝牙设置的实例化地址\r
@@ -898,6 +908,11 @@ void NativeLauncher::InitTraingSetSlice(void)
     SliceProxy *traingsetview = new AbilitySliceProxy<TraingSetView, TraingSetPresenter>;\r
     NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGSET, traingsetview);\r
 }\r
+void NativeLauncher::InitTraingGPSSetSlice(void)\r
+{\r
+    SliceProxy *traingGPSsetview = new AbilitySliceProxy<TraingGPSsetView, TraingGPSsetPresenter>;\r
+    NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGGPSSET, traingGPSsetview);\r
+}\r
 void NativeLauncher::InitTraingSetTimeSlice(void)\r
 {\r
     SliceProxy *traingsettimeview = new AbilitySliceProxy<TraingSetTimeView, TraingSetTimePresenter>;\r
@@ -908,6 +923,16 @@ void NativeLauncher::InitTraingSetCaluliSlice(void)
     SliceProxy *traingsetcaluliview = new AbilitySliceProxy<TraingSetCaluliView, TraingSetCaluliPresenter>;\r
     NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGSETCALULI, traingsetcaluliview);\r
 }\r
+void NativeLauncher::InitTraingSetDistSlice(void)\r
+{\r
+    SliceProxy *traingsetdistview = new AbilitySliceProxy<TraingSetDistView, TraingSetDistPresenter>;\r
+    NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGSETDIST, traingsetdistview);\r
+}\r
+void NativeLauncher::InitTraingSetStepSlice(void)\r
+{\r
+    SliceProxy *traingsetstepview = new AbilitySliceProxy<TraingSetSeptView, TraingSetSeptPresenter>;\r
+    NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGSETSTEP, traingsetstepview);\r
+}\r
 void NativeLauncher::InitTraingControlSlice(void)\r
 {\r
     SliceProxy *traingcontrolview = new AbilitySliceProxy<TraingControlView, TraingControlPresenter>;\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSsetPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSsetPresenter.h
new file mode 100644 (file)
index 0000000..99e9c48
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _TraingGPSset_PRESENTER_H
+#define _TraingGPSset_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingGPSsetView.h"
+
+namespace OHOS
+{
+    class TraingGPSsetView;
+
+    class TraingGPSsetPresenter : public Presenter<TraingGPSsetView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingGPSsetPresenter();
+        virtual ~TraingGPSsetPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingGPSsetPresenter *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/TraingGPSsetView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSsetView.h
new file mode 100644 (file)
index 0000000..5503398
--- /dev/null
@@ -0,0 +1,79 @@
+#ifndef _TraingGPSset_VIEW_H
+#define _TraingGPSset_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 "TraingGPSsetPresenter.h"
+namespace OHOS
+{
+#define BUTTONTIME "button1"
+#define BUTTONMIL "button2"
+#define BUTTONCALULI "button3"
+#define BUTTONWALK "button4"
+
+    class TraingGPSsetPresenter;
+    class TraingGPSsetView : public View<TraingGPSsetPresenter>
+    {
+
+    public:
+        TraingGPSsetView();
+        virtual ~TraingGPSsetView();
+        static TraingGPSsetView *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};
+        TraingGPSsetView(TraingGPSsetView &&) = delete;
+        TraingGPSsetView &operator=(TraingGPSsetView &&) = delete;
+
+        UIViewGroup *container_ = nullptr;
+        UIScrollView *scrollView1_ = nullptr;
+
+        UILabel *label1_ = nullptr;
+        UILabel *label2_ = nullptr;
+        UILabel *label3_ = nullptr;
+        UILabel *label4_ = nullptr;
+        UILabel *label5_ = nullptr;
+
+        UIButton *button1_ = nullptr;
+        UIButton *button2_ = nullptr;
+        UIButton *button3_ = nullptr;
+        UIButton *button4_ = nullptr;
+
+        UIImageView *image1_ = nullptr;
+        UIImageView *image2_ = nullptr;
+        UIImageView *image3_ = nullptr;
+        UIImageView *image4_ = nullptr;
+
+        UIList *list1_ = nullptr;
+        IconAdapter *list1adapter_ = nullptr;
+        List<IconItemNode *> *list1data_ = nullptr;
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingGPSset_PRESENTER_H
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetDistPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetDistPresenter.h
new file mode 100644 (file)
index 0000000..23af5de
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _TraingSetDist_PRESENTER_H
+#define _TraingSetDist_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingSetDistView.h"
+
+namespace OHOS
+{
+    class TraingSetDistView;
+
+    class TraingSetDistPresenter : public Presenter<TraingSetDistView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingSetDistPresenter();
+        virtual ~TraingSetDistPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingSetDistPresenter *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/TraingSetDistView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetDistView.h
new file mode 100644 (file)
index 0000000..93807d2
--- /dev/null
@@ -0,0 +1,63 @@
+
+#ifndef _TraingSetDist_VIEW_H
+#define _TraingSetDist_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 "components/ui_picker.h"
+
+#include "TraingSetDistPresenter.h"
+namespace OHOS
+{
+#define BUTTONOK "button1"
+
+
+    class TraingSetDistPresenter;
+    class TraingSetDistView : public View<TraingSetDistPresenter>
+    {
+
+    public:
+        TraingSetDistView();
+        virtual ~TraingSetDistView();
+        static TraingSetDistView *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 InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId);
+        void InitList();
+        void PreLoad(void);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingSetDistView(TraingSetDistView &&) = delete;
+        TraingSetDistView &operator=(TraingSetDistView &&) = delete;
+
+        UIViewGroup *container_ = nullptr;
+        UILabel *label1_ = nullptr;
+        UIButton *button1_ = nullptr;
+        UIPicker *uiPicker1_ = nullptr;
+
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingSetDist_PRESENTER_H
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetSeptPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetSeptPresenter.h
new file mode 100644 (file)
index 0000000..74034c0
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _TraingSetSept_PRESENTER_H
+#define _TraingSetSept_PRESENTER_H
+
+#include "Presenter.h"
+#include "TraingSetSeptView.h"
+
+namespace OHOS
+{
+    class TraingSetSeptView;
+
+    class TraingSetSeptPresenter : public Presenter<TraingSetSeptView>,
+                                 public UIView::OnClickListener,
+                                 public UIView::OnDragListener
+    {
+    public:
+        TraingSetSeptPresenter();
+        virtual ~TraingSetSeptPresenter();
+
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+
+        static TraingSetSeptPresenter *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/TraingSetSeptView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingSetSeptView.h
new file mode 100644 (file)
index 0000000..a57c92d
--- /dev/null
@@ -0,0 +1,63 @@
+
+#ifndef _TraingSetSept_VIEW_H
+#define _TraingSetSept_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 "components/ui_picker.h"
+
+#include "TraingSetSeptPresenter.h"
+namespace OHOS
+{
+#define BUTTONOK "button1"
+
+
+    class TraingSetSeptPresenter;
+    class TraingSetSeptView : public View<TraingSetSeptPresenter>
+    {
+
+    public:
+        TraingSetSeptView();
+        virtual ~TraingSetSeptView();
+        static TraingSetSeptView *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 InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId);
+        void InitList();
+        void PreLoad(void);
+
+    private:
+        UIView::OnDragListener *draglistener{nullptr};
+        TraingSetSeptView(TraingSetSeptView &&) = delete;
+        TraingSetSeptView &operator=(TraingSetSeptView &&) = delete;
+
+        UIViewGroup *container_ = nullptr;
+        UILabel *label1_ = nullptr;
+        UIButton *button1_ = nullptr;
+        UIPicker *uiPicker1_ = nullptr;
+
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // TraingSetSept_PRESENTER_H
index 589c892..c436678 100755 (executable)
@@ -62,7 +62,7 @@ namespace OHOS
             (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
         {
             uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
-                       NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+                       NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING);
         }
         UNUSED(view);
         return true;
@@ -73,7 +73,7 @@ namespace OHOS
         // 根据控件id查找是哪个控件触发了点击回调
         if (strcmp(view.GetViewId(), BUTTONSET) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSET);
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSSET);
         }
         if (strcmp(view.GetViewId(), BUTTONGO) == 0)
         {
index 8cf922c..64f8625 100755 (executable)
@@ -62,7 +62,7 @@ namespace OHOS
             (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
         {
             uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+           NativeAbility::GetInstance().ChangeSlice(preSlice);
         }
         UNUSED(view);
         return true;
index 3c125e3..26d705b 100755 (executable)
@@ -62,7 +62,7 @@ namespace OHOS
             (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
         {
             uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+            NativeAbility::GetInstance().ChangeSlice(preSlice);
         }
         UNUSED(view);
         return true;
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSsetPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSsetPresenter.cpp
new file mode 100644 (file)
index 0000000..706a124
--- /dev/null
@@ -0,0 +1,92 @@
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/include/TraingGPSsetPresenter.h"
+// #include "TraingGPSsetView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingGPSsetPresenter *g_pTraingGPSsetPresenter = nullptr;
+
+    TraingGPSsetPresenter::TraingGPSsetPresenter()
+    {
+
+        g_pTraingGPSsetPresenter = this;
+    }
+
+    TraingGPSsetPresenter::~TraingGPSsetPresenter()
+    {
+
+        g_pTraingGPSsetPresenter = nullptr;
+    }
+
+    TraingGPSsetPresenter *TraingGPSsetPresenter::GetInstance()
+    {
+
+        return g_pTraingGPSsetPresenter;
+    }
+
+    void TraingGPSsetPresenter::OnStart()
+    {
+
+        Presenter<TraingGPSsetView>::OnStart();
+    }
+
+    void TraingGPSsetPresenter::OnPause(void)
+    {
+
+        Presenter<TraingGPSsetView>::OnPause();
+    }
+
+    void TraingGPSsetPresenter::OnResume(void)
+    {
+
+        Presenter<TraingGPSsetView>::OnResume();
+    }
+
+    void TraingGPSsetPresenter::OnStop(void)
+    {
+
+        Presenter<TraingGPSsetView>::OnStop();
+    }
+
+    bool TraingGPSsetPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+            (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
+        {
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPS);
+        }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingGPSsetPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONTIME) == 0)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETTIME);
+        }
+        if (strcmp(view.GetViewId(), BUTTONMIL) == 0)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETDIST);
+        }
+        if (strcmp(view.GetViewId(), BUTTONCALULI) == 0)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETCALULI);
+        }
+        if (strcmp(view.GetViewId(), BUTTONWALK) == 0)
+        {
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSETSTEP);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSsetView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSsetView.cpp
new file mode 100644 (file)
index 0000000..bd19af4
--- /dev/null
@@ -0,0 +1,301 @@
+
+#include "traing/include/TraingGPSsetView.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 char *imagePaths[] = {"/user/res/Training/time.bin",
+                                 "/user/res/Training/mileage.bin",
+                                 "/user/res/Training/calories.bin",
+                                 "/user/res/Training/walking.bin"};
+
+    static char *text[] = {"时长", "距离", "卡路里", "步数"};
+    static const char *imagePath_iocn = "/user/res/Training/icon.bin";
+    static TraingGPSsetView *g_pTraingGPSsetView{nullptr};
+
+    TraingGPSsetView::TraingGPSsetView()
+    {
+        g_pTraingGPSsetView = this;
+    }
+
+    TraingGPSsetView::~TraingGPSsetView()
+    {
+        DeInit();
+        g_pTraingGPSsetView = nullptr;
+    }
+
+    TraingGPSsetView *TraingGPSsetView::GetInstance()
+    {
+
+        return g_pTraingGPSsetView;
+    }
+    /*
+    InitLabel:初始化标签
+    @param label 标签指针
+    @param left 标签左边位置
+    @param top 标签顶部位置
+    @param width 标签宽度
+    @param height 标签高度
+    @param viewId 标签的视图 ID
+    @param text 标签显示的文本
+    @param fontName 字体名称
+    @param fontSize 字体大小
+    */
+    void TraingGPSsetView::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 TraingGPSsetView::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);
+        // 设置按钮的点击事件监听器为 TraingGPSsetPresenter 的实例
+        button->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingGPSsetPresenter::GetInstance()));
+        // 设置按钮可见
+        button->SetVisible(true);
+    }
+    /*
+   InitImageView:初始化图片
+   @param imageView 图片指针
+   @param left 图片左边位置
+   @param top 图片顶部位置
+   @param width 图片宽度
+   @param height 图片高度
+   @param viewId 图片的视图 ID
+   @param imagePath 图片路径
+   */
+    void TraingGPSsetView::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 TraingGPSsetView::InitList()
+    {
+        // Add List to App
+        if (list1_ == nullptr)
+        {
+            list1_ = new UIList();
+        }
+        list1_->SetPosition(60, 110); // widget's left position and top position
+        list1_->Resize(300, 530);     // 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 < 4; ++i)
+        {
+            IconItemNode *listData = new IconItemNode();
+            listData->imagePath = imagePaths[i];
+            listData->txt = text[i];
+            list1data_->PushBack(listData);
+        }
+
+        if (list1adapter_ == nullptr)
+        {
+            list1adapter_ = new IconAdapter();
+        }
+        list1adapter_->SetItemSize(190, 120);
+        list1adapter_->SetImageSize(70, 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 TraingGPSsetView ::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);
+        // Add to rootView
+        container_->Add(scrollView1_);
+        scrollView1_->SetVisible(true);
+
+        //  初始化Button
+        InitButton(button1_, 43, 120, 380, 100, BUTTONTIME);
+        InitButton(button2_, 43, 240, 380, 100, BUTTONMIL);
+        InitButton(button3_, 43, 360, 380, 100, BUTTONCALULI);
+        InitButton(button4_, 43, 480, 380, 100, BUTTONWALK);
+        scrollView1_->Add(button1_);
+        scrollView1_->Add(button2_);
+        scrollView1_->Add(button3_);
+        scrollView1_->Add(button4_);
+
+        // 初始化Image
+        InitImageView(image1_, 380, 160, 100, 100, "image1", imagePath_iocn);
+        InitImageView(image2_, 380, 280, 100, 100, "image2", imagePath_iocn);
+        InitImageView(image3_, 380, 400, 100, 100, "image3", imagePath_iocn);
+        InitImageView(image4_, 380, 520, 100, 100, "image4", imagePath_iocn);
+        scrollView1_->Add(image1_);
+        scrollView1_->Add(image2_);
+        scrollView1_->Add(image3_);
+        scrollView1_->Add(image4_);
+
+        // 初始化Lable
+        InitLabel(label1_, 203, 52, 120, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabel(label2_, 300, 160, 60, 35, "label2", "30 分钟", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        InitLabel(label3_, 300, 280, 69, 23, "label3", "5 公里", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        InitLabel(label4_, 300, 400, 60, 35, "label4", "500 千卡", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        InitLabel(label5_, 300, 520, 60, 35, "label5", "2000 步", DEFAULT_VECTOR_FONT_FILENAME, 20);
+        scrollView1_->Add(label1_);
+        scrollView1_->Add(label2_);
+        scrollView1_->Add(label3_);
+        scrollView1_->Add(label4_);
+        scrollView1_->Add(label5_);
+
+        // 初始化list
+        InitList();
+        scrollView1_->Add(list1_);
+    }
+    /* DeInit:删除组件 */
+    void TraingGPSsetView::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 TraingGPSsetView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingGPSsetView::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 *>(TraingGPSsetPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        container_->SetOnDragListener(draglistener);
+
+        container_->SetTouchable(true);
+        container_->SetDraggable(true);
+
+        PreLoad();
+        RootView::GetInstance()->Add(container_);
+    }
+
+    void TraingGPSsetView::OnSetUpView()
+    {
+
+        View<TraingGPSsetPresenter>::OnSetUpView();
+        Draw();
+    }
+
+    void TraingGPSsetView::OnTearDownView()
+    {
+
+        View<TraingGPSsetPresenter>::OnTearDownView();
+        return;
+    }
+
+    void TraingGPSsetView::OnStop()
+    {
+        View<TraingGPSsetPresenter>::OnStop();
+        RootView::GetInstance()->RemoveAll();
+        return;
+    }
+}
index 0898371..1d41ef5 100755 (executable)
@@ -72,7 +72,8 @@ namespace OHOS
         // 根据控件id查找是哪个控件触发了点击回调\r
         if (strcmp(view.GetViewId(), BUTTONOK) == 0)\r
         {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSET);\r
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();\r
+            NativeAbility::GetInstance().ChangeSlice(preSlice);\r
         }\r
         return true;\r
     }\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetDistPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetDistPresenter.cpp
new file mode 100644 (file)
index 0000000..0fb5cf8
--- /dev/null
@@ -0,0 +1,80 @@
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/include/TraingSetDistPresenter.h"
+// #include "TraingSetDistView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingSetDistPresenter *g_pTraingSetDistPresenter = nullptr;
+
+    TraingSetDistPresenter::TraingSetDistPresenter()
+    {
+
+        g_pTraingSetDistPresenter = this;
+    }
+
+    TraingSetDistPresenter::~TraingSetDistPresenter()
+    {
+
+        g_pTraingSetDistPresenter = nullptr;
+    }
+
+    TraingSetDistPresenter *TraingSetDistPresenter::GetInstance()
+    {
+
+        return g_pTraingSetDistPresenter;
+    }
+
+    void TraingSetDistPresenter::OnStart()
+    {
+
+        Presenter<TraingSetDistView>::OnStart();
+    }
+
+    void TraingSetDistPresenter::OnPause(void)
+    {
+
+        Presenter<TraingSetDistView>::OnPause();
+    }
+
+    void TraingSetDistPresenter::OnResume(void)
+    {
+
+        Presenter<TraingSetDistView>::OnResume();
+    }
+
+    void TraingSetDistPresenter::OnStop(void)
+    {
+
+        Presenter<TraingSetDistView>::OnStop();
+    }
+
+    bool TraingSetDistPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+
+        // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+        //     (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
+        // {
+        //     NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSET);
+        // }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingSetDistPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONOK) == 0)
+        {
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSSET);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetDistView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetDistView.cpp
new file mode 100644 (file)
index 0000000..634ea19
--- /dev/null
@@ -0,0 +1,280 @@
+
+#include "traing/include/TraingSetDistView.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"
+#include "common/screen.h"
+#include <sstream>
+#include <string>
+#include <vector>
+
+namespace OHOS
+{
+
+    /***************************************************************************************/
+    // 动态生成包含指定公里区间内所有公里的字符串数组
+    std::vector<std::string> GenerateDistValues(int minDist, int maxDist, int interval)
+    {
+        std::vector<std::string> values;
+        for (int i = minDist; i <= maxDist; i += interval)
+        {
+            values.push_back(std::to_string(i) + " 公里");
+        }
+        return values;
+    }
+    /***************************************************************************************/
+    static TraingSetDistView *g_pTraingSetDistView{nullptr};
+
+    TraingSetDistView::TraingSetDistView()
+    {
+        g_pTraingSetDistView = this;
+    }
+
+    TraingSetDistView::~TraingSetDistView()
+    {
+        DeInit();
+        g_pTraingSetDistView = nullptr;
+    }
+
+    TraingSetDistView *TraingSetDistView::GetInstance()
+    {
+
+        return g_pTraingSetDistView;
+    }
+    /*
+    InitLabel:初始化标签
+    @param label 标签指针
+    @param left 标签左边位置
+    @param top 标签顶部位置
+    @param width 标签宽度
+    @param height 标签高度
+    @param viewId 标签的视图 ID
+    @param text 标签显示的文本
+    @param fontName 字体名称
+    @param fontSize 字体大小
+    */
+    void TraingSetDistView::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 TraingSetDistView::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);
+        // 设置按钮的点击事件监听器为 TraingSetDistPresenter 的实例
+        button->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetDistPresenter::GetInstance()));
+        // 设置按钮可见
+        button->SetVisible(true);
+    }
+    /*
+    InitUIPicker: 初始化UIPicker组件
+    @param picker: 指向UIPicker的指针
+    @param x: UIPicker的左边位置
+    @param y: UIPicker的顶部位置
+    @param width: UIPicker的宽度
+    @param height: UIPicker的高度
+    @param viewId: UIPicker的视图 ID
+    @param values: 选项数组
+    @param count: 选项数量
+    @param backgroundFontSize: 普通文本大小
+    @highlightFontSize: 高光文本大小
+    */
+    void TraingSetDistView::InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId)
+    {
+        // 文本大小
+        constexpr uint8_t BACKGROUND_FONT = 40;
+        constexpr uint8_t HIGHTLIGHT_FONT = 60;
+        // 获取value数组
+        int minDist = 1;
+        int maxDist = 20;
+        int interval = 1;
+        std::vector<std::string> DistValues = GenerateDistValues(minDist, maxDist, interval);
+
+        const char **values = new const char *[DistValues.size()];
+        for (size_t i = 0; i < DistValues.size(); i++)
+        {
+            values[i] = DistValues[i].c_str();
+        }
+        // 创建 UIPicker
+        if (picker == nullptr)
+        {
+            picker = new UIPicker();
+        }
+
+        // 设置 UIPicker 的位置和大小
+        picker->SetPosition(x, y);
+        picker->Resize(width, height);
+        // 设置 UIPicker 的 ViewId
+        picker->SetViewId(viewId);
+        // 设置 UIPicker 的属性
+        picker->SetItemHeight(70);
+        picker->SetLoopState(true);
+        picker->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff), Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+        picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); // 设置普通文本大小
+        picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT);  // 设置高光文本大小
+        picker->SetValues(values, DistValues.size());
+        // 将 UIPicker 设置为显示
+        picker->SetVisible(true);
+    }
+
+    /* InitView:初始化界面*/
+    void TraingSetDistView ::InitView()
+    {
+        if (container_ == nullptr)
+        {
+            container_ = new UIViewGroup();
+            container_->SetPosition(0, 0, 466, 466);
+            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
+        }
+        // 初始化Lable
+        InitLabel(label1_, 173, 52, 120, 35, "label1", "步数设定", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        container_->Add(label1_);
+
+        // 初始化UIPicker
+        InitUIPicker(uiPicker1_, 43, 106, 380, 240, "uiPicker1");
+        container_->Add(uiPicker1_);
+        //  初始化Button
+        InitButton(button1_, 0, 366, 466, 100, BUTTONOK);
+        // Set additional property
+        char *button1defaultImgSrc = "/user/res/Training/buttonok.bin";
+        char *button1triggeredImgSrc = nullptr;
+        button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
+        container_->Add(button1_);
+    }
+    /* DeInit:删除组件 */
+    void TraingSetDistView::DeInit()
+    {
+        // 删除Label
+        if (label1_ != nullptr)
+        {
+            container_->Remove(label1_);
+            delete label1_;
+            label1_ = nullptr;
+        }
+        // 删除Button
+        if (button1_ != nullptr)
+        {
+            container_->Remove(button1_);
+            delete button1_;
+            button1_ = nullptr;
+        }
+
+        // 删除Image
+
+        // 删除滚动选择器
+        if (uiPicker1_ != nullptr)
+        {
+            container_->Remove(uiPicker1_);
+            delete uiPicker1_;
+            uiPicker1_ = nullptr;
+        }
+
+        // 删除容器
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll(); // 移除容器中的所有组件
+            delete container_;
+            container_ = nullptr;
+        }
+    }
+
+    void TraingSetDistView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            //printf("init TraingSetDistview\n");
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingSetDistView::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 *>(TraingSetDistPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        container_->SetOnDragListener(draglistener);
+
+        container_->SetTouchable(true);
+        container_->SetDraggable(true);
+
+        PreLoad();
+        RootView::GetInstance()->Add(container_);
+    }
+
+    void TraingSetDistView::OnSetUpView()
+    {
+
+        View<TraingSetDistPresenter>::OnSetUpView();
+        Draw();
+    }
+
+    void TraingSetDistView::OnTearDownView()
+    {
+
+        View<TraingSetDistPresenter>::OnTearDownView();
+        return;
+    }
+
+    void TraingSetDistView::OnStop()
+    {
+        View<TraingSetDistPresenter>::OnStop();
+        RootView::GetInstance()->RemoveAll();
+        return;
+    }
+}
index fcb3da5..11be7f9 100755 (executable)
@@ -62,7 +62,7 @@ namespace OHOS
             (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))\r
         {\r
             uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);\r
+            NativeAbility::GetInstance().ChangeSlice(preSlice);\r
         }\r
         UNUSED(view);\r
         return true;\r
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetSeptPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetSeptPresenter.cpp
new file mode 100644 (file)
index 0000000..5841d3d
--- /dev/null
@@ -0,0 +1,80 @@
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+
+#include <iostream>
+#include <chrono>
+#include <thread>
+#include "traing/include/TraingSetSeptPresenter.h"
+// #include "TraingSetSeptView.h"
+
+namespace OHOS
+{
+
+    // 当前Presenter属性实例化的内存指针
+    static TraingSetSeptPresenter *g_pTraingSetSeptPresenter = nullptr;
+
+    TraingSetSeptPresenter::TraingSetSeptPresenter()
+    {
+
+        g_pTraingSetSeptPresenter = this;
+    }
+
+    TraingSetSeptPresenter::~TraingSetSeptPresenter()
+    {
+
+        g_pTraingSetSeptPresenter = nullptr;
+    }
+
+    TraingSetSeptPresenter *TraingSetSeptPresenter::GetInstance()
+    {
+
+        return g_pTraingSetSeptPresenter;
+    }
+
+    void TraingSetSeptPresenter::OnStart()
+    {
+
+        Presenter<TraingSetSeptView>::OnStart();
+    }
+
+    void TraingSetSeptPresenter::OnPause(void)
+    {
+
+        Presenter<TraingSetSeptView>::OnPause();
+    }
+
+    void TraingSetSeptPresenter::OnResume(void)
+    {
+
+        Presenter<TraingSetSeptView>::OnResume();
+    }
+
+    void TraingSetSeptPresenter::OnStop(void)
+    {
+
+        Presenter<TraingSetSeptView>::OnStop();
+    }
+
+    bool TraingSetSeptPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+
+        // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT &&
+        //     (event.GetDeltaX() > 20) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY()))))
+        // {
+        //     NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSET);
+        // }
+        UNUSED(view);
+        return true;
+    }
+
+    bool TraingSetSeptPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // 根据控件id查找是哪个控件触发了点击回调
+        if (strcmp(view.GetViewId(), BUTTONOK) == 0)
+        {
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSSET);
+        }
+        return true;
+    }
+}
diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetSeptView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingSetSeptView.cpp
new file mode 100644 (file)
index 0000000..8bd73c1
--- /dev/null
@@ -0,0 +1,280 @@
+
+#include "traing/include/TraingSetSeptView.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"
+#include "common/screen.h"
+#include <sstream>
+#include <string>
+#include <vector>
+
+namespace OHOS
+{
+
+    /***************************************************************************************/
+    // 动态生成包含指定步数区间内所有步数的字符串数组
+    std::vector<std::string> GenerateSeptValues(int minSept, int maxSept, int interval)
+    {
+        std::vector<std::string> values;
+        for (int i = minSept; i <= maxSept; i += interval)
+        {
+            values.push_back(std::to_string(i) + " 步");
+        }
+        return values;
+    }
+    /***************************************************************************************/
+    static TraingSetSeptView *g_pTraingSetSeptView{nullptr};
+
+    TraingSetSeptView::TraingSetSeptView()
+    {
+        g_pTraingSetSeptView = this;
+    }
+
+    TraingSetSeptView::~TraingSetSeptView()
+    {
+        DeInit();
+        g_pTraingSetSeptView = nullptr;
+    }
+
+    TraingSetSeptView *TraingSetSeptView::GetInstance()
+    {
+
+        return g_pTraingSetSeptView;
+    }
+    /*
+    InitLabel:初始化标签
+    @param label 标签指针
+    @param left 标签左边位置
+    @param top 标签顶部位置
+    @param width 标签宽度
+    @param height 标签高度
+    @param viewId 标签的视图 ID
+    @param text 标签显示的文本
+    @param fontName 字体名称
+    @param fontSize 字体大小
+    */
+    void TraingSetSeptView::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 TraingSetSeptView::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);
+        // 设置按钮的点击事件监听器为 TraingSetSeptPresenter 的实例
+        button->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingSetSeptPresenter::GetInstance()));
+        // 设置按钮可见
+        button->SetVisible(true);
+    }
+    /*
+    InitUIPicker: 初始化UIPicker组件
+    @param picker: 指向UIPicker的指针
+    @param x: UIPicker的左边位置
+    @param y: UIPicker的顶部位置
+    @param width: UIPicker的宽度
+    @param height: UIPicker的高度
+    @param viewId: UIPicker的视图 ID
+    @param values: 选项数组
+    @param count: 选项数量
+    @param backgroundFontSize: 普通文本大小
+    @highlightFontSize: 高光文本大小
+    */
+    void TraingSetSeptView::InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId)
+    {
+        // 文本大小
+        constexpr uint8_t BACKGROUND_FONT = 40;
+        constexpr uint8_t HIGHTLIGHT_FONT = 60;
+        // 获取value数组
+        int minSept = 500;
+        int maxSept = 50000;
+        int interval = 500;
+        std::vector<std::string> SeptValues = GenerateSeptValues(minSept, maxSept, interval);
+
+        const char **values = new const char *[SeptValues.size()];
+        for (size_t i = 0; i < SeptValues.size(); i++)
+        {
+            values[i] = SeptValues[i].c_str();
+        }
+        // 创建 UIPicker
+        if (picker == nullptr)
+        {
+            picker = new UIPicker();
+        }
+
+        // 设置 UIPicker 的位置和大小
+        picker->SetPosition(x, y);
+        picker->Resize(width, height);
+        // 设置 UIPicker 的 ViewId
+        picker->SetViewId(viewId);
+        // 设置 UIPicker 的属性
+        picker->SetItemHeight(70);
+        picker->SetLoopState(true);
+        picker->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff), Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff));
+        picker->SetBackgroundFont(DEFAULT_VECTOR_FONT_FILENAME, BACKGROUND_FONT); // 设置普通文本大小
+        picker->SetHighlightFont(DEFAULT_VECTOR_FONT_FILENAME, HIGHTLIGHT_FONT);  // 设置高光文本大小
+        picker->SetValues(values, SeptValues.size());
+        // 将 UIPicker 设置为显示
+        picker->SetVisible(true);
+    }
+
+    /* InitView:初始化界面*/
+    void TraingSetSeptView ::InitView()
+    {
+        if (container_ == nullptr)
+        {
+            container_ = new UIViewGroup();
+            container_->SetPosition(0, 0, 466, 466);
+            container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
+        }
+        // 初始化Lable
+        InitLabel(label1_, 173, 52, 120, 35, "label1", "步数设定", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        container_->Add(label1_);
+
+        // 初始化UIPicker
+        InitUIPicker(uiPicker1_, 43, 106, 380, 240, "uiPicker1");
+        container_->Add(uiPicker1_);
+        //  初始化Button
+        InitButton(button1_, 0, 366, 466, 100, BUTTONOK);
+        // Set additional property
+        char *button1defaultImgSrc = "/user/res/Training/buttonok.bin";
+        char *button1triggeredImgSrc = nullptr;
+        button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc);
+        container_->Add(button1_);
+    }
+    /* DeInit:删除组件 */
+    void TraingSetSeptView::DeInit()
+    {
+        // 删除Label
+        if (label1_ != nullptr)
+        {
+            container_->Remove(label1_);
+            delete label1_;
+            label1_ = nullptr;
+        }
+        // 删除Button
+        if (button1_ != nullptr)
+        {
+            container_->Remove(button1_);
+            delete button1_;
+            button1_ = nullptr;
+        }
+
+        // 删除Image
+
+        // 删除滚动选择器
+        if (uiPicker1_ != nullptr)
+        {
+            container_->Remove(uiPicker1_);
+            delete uiPicker1_;
+            uiPicker1_ = nullptr;
+        }
+
+        // 删除容器
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll(); // 移除容器中的所有组件
+            delete container_;
+            container_ = nullptr;
+        }
+    }
+
+    void TraingSetSeptView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            //printf("init TraingSetSeptview\n");
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void TraingSetSeptView::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 *>(TraingSetSeptPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        container_->SetOnDragListener(draglistener);
+
+        container_->SetTouchable(true);
+        container_->SetDraggable(true);
+
+        PreLoad();
+        RootView::GetInstance()->Add(container_);
+    }
+
+    void TraingSetSeptView::OnSetUpView()
+    {
+
+        View<TraingSetSeptPresenter>::OnSetUpView();
+        Draw();
+    }
+
+    void TraingSetSeptView::OnTearDownView()
+    {
+
+        View<TraingSetSeptPresenter>::OnTearDownView();
+        return;
+    }
+
+    void TraingSetSeptView::OnStop()
+    {
+        View<TraingSetSeptPresenter>::OnStop();
+        RootView::GetInstance()->RemoveAll();
+        return;
+    }
+}
index f28506d..124473c 100755 (executable)
@@ -72,7 +72,8 @@ namespace OHOS
         // 根据控件id查找是哪个控件触发了点击回调\r
         if (strcmp(view.GetViewId(), BUTTONOK) == 0)\r
         {\r
-            NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGSET);\r
+            uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();\r
+            NativeAbility::GetInstance().ChangeSlice(preSlice);\r
         }\r
         if (strcmp(view.GetViewId(), "Remind") == 0)\r
         {\r