移植gps提醒界面
authorCaisking <Casiking@zhihuishixun.com>
Tue, 26 Aug 2025 10:11:20 +0000 (18:11 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Tue, 26 Aug 2025 10:11:20 +0000 (18:11 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/include/TraingGPSnoteView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnotePresenter.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/traing/training_GPS/src/TraingGPSnoteView.cpp

index 86d7591..3082cb7 100644 (file)
@@ -100,6 +100,7 @@ typedef enum : uint16_t
   VIEW_TRAININGCRAD,    // 训练控制卡片
   VIEW_TRAININGENDDATA, // 训练结束详细数据
   VIEW_TRAINING_RECORD, // 训练记录
+  VIEW_TRAINING_GPSNOTE,// 训练GPS提醒
   /* ---------------------------------- 训练列表 ---------------------------------- */
   VIEW_TRAININGMORE,    // 更多训练
   VIEW_TRAININGLIMIT,   // 极限运动列表
index d6f390d..c24c902 100644 (file)
@@ -4,66 +4,63 @@
 
 
 #include "View.h"
-#include <ui_scroll_view.h>
-#include "components/ui_view_group.h"
-#include "components/ui_label.h"
-#include "components/ui_label_ext.h"
-#include "components/ui_image_view.h"
+#include "components/icon_adapter.h"
 #include "components/ui_button.h"
+#include "components/ui_card_page.h"
+#include "components/ui_chart.h"
 #include "components/ui_image_animator.h"
+#include "components/ui_image_view.h"
+#include "components/ui_label.h"
+#include "components/ui_label_button.h"
 #include "components/ui_label_button_ext.h"
-#include "components/ui_chart.h"
+#include "components/ui_label_ext.h"
 #include "components/ui_list.h"
-#include "components/icon_adapter.h"
-#include "wearable_log.h"
+#include "components/ui_view_group.h"
 #include "ohos_types.h"
-#include "components/ui_card_page.h"
+#include "traing/Training_UiConfig.h"
 #include "traing/include/TraingModel.h"
 #include "uicomponents/UIComponents.h"
-#include "traing/Training_UiConfig.h"
+#include "wearable_log.h"
+#include <ui_scroll_view.h>
 
 #include "TraingGPSnotePresenter.h"
-namespace OHOS
-{
+namespace OHOS {
 #define BUTTONBACK "button1"
 #define BUTTONGO "button2"
 
-    class TraingGPSnotePresenter;
-    class TraingGPSnoteView : public View<TraingGPSnotePresenter>
-    {
+class TraingGPSnotePresenter;
+class TraingGPSnoteView : public View<TraingGPSnotePresenter> {
+
+public:
+  TraingGPSnoteView();
+  virtual ~TraingGPSnoteView();
+  static TraingGPSnoteView *GetInstance(void);
+
+  void OnStart() override;
 
-    public:
-        TraingGPSnoteView();
-        virtual ~TraingGPSnoteView();
-        static TraingGPSnoteView *GetInstance(void);
+  void InitView();
+  void DeInit();
 
-        void OnStart() override;
-      
-        void InitView();
-        void DeInit();
-       
-        void InitList();
-        void PreLoad(void);
+  void InitList();
+  void PreLoad(void);
 
-    private:
-        UIView::OnDragListener *draglistener{nullptr};
-        TraingGPSnoteView(TraingGPSnoteView &&) = delete;
-        TraingGPSnoteView &operator=(TraingGPSnoteView &&) = delete;
+private:
+  UIView::OnDragListener *draglistener{nullptr};
+  TraingGPSnoteView(TraingGPSnoteView &&) = delete;
+  TraingGPSnoteView &operator=(TraingGPSnoteView &&) = delete;
 
+  UIScrollView *scrollView1_ = nullptr;
 
-        UIScrollView *scrollView1_ = nullptr;
+  UILabelExt *label1_ = nullptr;
+  UILabelExt *label2_ = nullptr;
 
-        UILabelExt *label1_ = nullptr;
-        UILabelExt *label2_ = nullptr;
-        UILabelExt *label3_ = nullptr;
-        UILabelExt *label4_ = nullptr;
 
-        UIButton *button1_ = nullptr;
-        UIButton *button2_ = nullptr;
+  UILabelButtonExt *button_wait = nullptr;
+  UILabelButtonExt *button_go = nullptr;
 
-        UIImageView *image1_ = nullptr;
-        UIImageView *image2_ = nullptr;
-        bool viewiInitStatus{false};
-    };
+  UIImageView *image1_ = nullptr;
+  UIImageView *image2_ = nullptr;
+  bool viewiInitStatus{false};
+};
 } // namespace OHOS
 #endif // TraingGPSnote_PRESENTER_H
index c93bc17..250bddf 100644 (file)
 #include "traing/training_GPS/include/TraingGPSnotePresenter.h"
 // #include "TraingGPSnoteView.h"
 
+#include "NativeRegisterManager.h"
 namespace OHOS
 {
+    REGIST_SLICE(VIEW_TRAINING_GPSNOTE, TraingGPSnoteView, TraingGPSnotePresenter);
 
     // 当前Presenter属性实例化的内存指针
     static TraingGPSnotePresenter *g_pTraingGPSnotePresenter = nullptr;
index 0e7dea7..8583e09 100644 (file)
@@ -11,7 +11,7 @@
 #include "traing/include/TraingModel.h"
 #include "uicomponents/UIComponents.h"
 #include "traing/Training_UiConfig.h"
-
+#include "ui_resource_image.h"
 namespace OHOS
 {
 
@@ -56,27 +56,29 @@ namespace OHOS
         scrollView1_->SetVisible(true);
 
         // 初始化Image
-       InitImageView(image1_, 193, 111, 80, 80, "image1", WARNING_IMAGE);
+        InitImageView(image1_, 193, 111, 80, 80, "image1", WARNING_IMAGE);
         scrollView1_->Add(image1_);
 
         // 初始化button
-       InitButton(button1_, 118, 334, 230, 80, BUTTONBACK);
-        button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c);
-        scrollView1_->Add(button1_);
+        InitButtonExt(button_wait, 118, 334, 230, 80, BUTTONBACK, STR_SET_TARGET, 30);
+        button_wait->SetText("继续等待");
+        button_wait->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c);
+        scrollView1_->Add(button_wait);
+        button_wait->SetOnClickListener(presenter_);
 
-       InitButton(button2_, 118, 434, 230, 80, BUTTONGO);
-        scrollView1_->Add(button2_);
+        InitButtonExt(button_go, 118, 434, 230, 80, BUTTONGO, STR_SET_TARGET, 30);
+        button_go->SetText("直接开始");
+        scrollView1_->Add(button_go);
+        button_go->SetOnClickListener(presenter_);
 
         // 初始化Lable
-       InitLabel(label1_, 160, 52, 90, 35, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30);
-       InitLabel(label2_, 33, 215, 60, 40, "label2", "GPS仍在定位,建议等待定位\n完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30);
-       InitLabel(label3_, 181, 357, 60, 40, "label3", "继续等待", DEFAULT_VECTOR_FONT_FILENAME, 30);
-       InitLabel(label4_, 181, 457, 60, 40, "label4", "直接开始", DEFAULT_VECTOR_FONT_FILENAME, 30);
+       InitLabel(label1_, 133, 52, 200, 60, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30);
+       InitLabel(label2_, 33, 215, 400, 90, "label2", "GPS仍在定位,建议等待定位 完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30);
+
 
         scrollView1_->Add(label1_);
         scrollView1_->Add(label2_);
-        scrollView1_->Add(label3_);
-        scrollView1_->Add(label4_);
+
 
         // Add ImageView to App
         if (image2_ == nullptr)
@@ -94,19 +96,44 @@ namespace OHOS
     /* DeInit:删除组件 */
     void TraingGPSnoteView::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;
+        if (scrollView1_ != nullptr)
+        {
+            scrollView1_->RemoveAll();
+            if (image1_ != nullptr)
+            {
+                delete image1_;
+                image1_ = nullptr;
+            }
+            if (button_wait != nullptr)
+            {
+                delete button_wait;
+                button_wait = nullptr;
+            }
+            if(button_go != nullptr)
+            {
+                delete button_go;
+                button_go = nullptr;
+            }
+            if (label1_ != nullptr)
+            {
+                delete label1_;
+                label1_ = nullptr;
+            }
+            if (label2_ != nullptr)
+            {
+                delete label2_;
+                label2_ = nullptr;
+            }
+            if (image2_ != nullptr)
+            {
+                delete image2_;
+                image2_ = nullptr;
+            }
+
+            delete scrollView1_;
+            scrollView1_ = nullptr;
+        }
+        
     }
 
     void TraingGPSnoteView::PreLoad(void)
@@ -120,7 +147,6 @@ namespace OHOS
     void TraingGPSnoteView::OnStart()
     {
 
-
         // 创建 draglistener 实例并设置为拖动监听器
         UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingGPSnotePresenter::GetInstance());
         if (draglistener == nullptr)
@@ -136,5 +162,4 @@ namespace OHOS
 
     }
 
-
 }