无训练记录UI
authorCaisking <3449750381@qq.com>
Tue, 23 Apr 2024 07:03:56 +0000 (15:03 +0800)
committerCaisking <3449750381@qq.com>
Tue, 23 Apr 2024 07:03:56 +0000 (15:03 +0800)
code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h
code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h
code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingWinView.h [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingWinView.cpp [deleted file]
code/sdk/application/wearable/fd230app/nativeui/traingrecord/include/TraingRecordView.h
code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Norecord.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Walking_54.bin [new file with mode: 0644]

index c40e47e..fbea038 100644 (file)
@@ -104,10 +104,11 @@ typedef enum : uint16_t
 #ifdef SUPPORT_ALIPAY_SEC
     VIEW_MAIN_ALIPAY,
 #endif
-    VIEW_SET_DESKTOP,
-    VIEW_SET_CARD,
-    VIEW_ADD_CARD,
-    VIEW_SET_DIAL,
+    VIEW_SET_DESKTOP,         // 主题样式
+    VIEW_SET_CARD,            // 卡片管理
+    VIEW_ADD_CARD,            // 添加卡片
+    VIEW_SET_DIAL,            // 切换表盘
+
     VIEW_MAX_INTER_APP,       // 在此之前添加native应用ID.
     VIEW_EXTERN_APP = 0xFFFE, // 三方应用
     VIEW_INVALIDE_APP = 0xFFFF,
index 04d125e..190cb4b 100644 (file)
@@ -107,9 +107,10 @@ namespace OHOS
     static constexpr const char *STEP_30_IMAGE = MODULES "/Step_30.bin";
     static constexpr const char *SPORT_HEARTRATE_IMAGE = MODULES "/sport_heartrate.bin";
     static constexpr const char *TIME_IMAGE = MODULES "/Time.bin";
-    //static constexpr const char *WALKING_54_IMAGE = MODULES "/Walking_54.bin";
+    // static constexpr const char *WALKING_54_IMAGE = MODULES "/Walking_54.bin";
     static constexpr const char *WARNING_IMAGE = MODULES "/Warning.bin";
     static constexpr const char *YES_IMAGE = MODULES "/Yes.bin";
+    static constexpr const char *RECOED_IMAGE = MODULES "/Norecord.bin";
 
     // Training GIF
     static constexpr const char *TRAINING_GIF_IMAGE_1 = TRAINING_GIF "/win/1.bin";
index d56ad2d..be23114 100644 (file)
@@ -36,7 +36,7 @@
 
 #include <string>
 #include <memory>
-#include <cmath> 
+#include <cmath>
 
 #define GILROY_REGULAR_FONT "./font_library/gilroy-regular-3.ttf"
 #define GILROY_BOLD_FONT "./font_library/gilroy-bold-4.ttf"
@@ -99,7 +99,7 @@ extern "C"
         // 最高海拔高度
         uint32_t alt;
     };
-    Trainingdata *read_Trainingdata_data(char* timedata, uint16_t offset);
+    Trainingdata *read_Trainingdata_data(char *timedata, uint16_t offset);
 
     int write_Trainingdata_data(Trainingdata data);
 
@@ -217,15 +217,27 @@ namespace OHOS
         static TraingModel *GetInstance(void);
         void Init();
 
-        /*训练组件初始化*/
+        /* --------------------------------- 训练组件初始化 -------------------------------- */
+        /*初始化label[可使用text]*/
         bool InitLabel(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
+        /*初始化labelExt*/
         bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize);
+        /*初始化button*/
         bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId);
+        /*初始化buttonExt*/
         bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, int fontSize);
+        /*初始化image*/
         bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath);
+        /*生成动画资源数组*/
         const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages);
+        /*初始化动画资源*/
         void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time);
-        void InitList();
+        /*InitLabel[默认参数]*/
+        void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize = 30, const char *fontName = DEFAULT_VECTOR_FONT_FILENAME)
+        {
+            InitLabel(label, x, y, width, height, viewId, text, fontName, fontSize);
+        }
+        /* -------------------------------------------------------------------------- */
 
         /*定时器 */
         std::string DisplayMotionDuration();
index a8e0bf0..1193902 100644 (file)
@@ -1,3 +1,9 @@
+/*** \r
+ * @Date: 2024-04-15 11:46:23\r
+ * @LastEditors: Caisking 3449750381@qq.com\r
+ * @LastEditTime: 2024-04-23 11:00:11\r
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h\r
+ */\r
 #ifndef _TraingCard_VIEW_H\r
 #define _TraingCard_VIEW_H\r
 \r
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingWinView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingWinView.h
deleted file mode 100644 (file)
index 4bb465c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*** 
- * @Date: 2024-04-17 16:32:02
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-04-19 10:20:35
- * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingWinView.h
- */
-#ifndef _TrainingWin_VIEW_H
-#define _TrainingWin_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_label_ext.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 "traing/include/TraingModel.h"
-#include "traing/Training_UiConfig.h"
-
-namespace OHOS
-{
-#define BUTTONWINOK "buttonwin"
-
-    class TrainingWinPresenter;
-    class TrainingWinView : public View<TrainingWinPresenter>
-    {
-
-    public:
-        TrainingWinView();
-        virtual ~TrainingWinView();
-        static TrainingWinView *GetInstance(void);
-
-
-        void InitView();
-        void DeInit();
-        void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId,int time);
-        void PreLoad(void);
-
-    private:
-        UIView::OnDragListener *draglistener{nullptr};
-        TrainingWinView(TrainingWinView &&) = delete;
-        TrainingWinView &operator=(TrainingWinView &&) = delete;
-        UIViewGroup *container_ = nullptr;
-        UILabelExt *labeltitle = nullptr;
-        UILabelExt *labeltag = nullptr;
-        UILabelExt *labelgettag = nullptr;
-        UILabelExt *labelpre = nullptr;
-        UIButton *buttonok_ = nullptr;
-        UIImageView *image1_ = nullptr;
-        UIImageAnimatorView *imageAnimator;
-        bool viewiInitStatus{false};
-    };
-
-} // namespace OHOS
-#endif // TrainingWin_PRESENTER_H
diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingWinView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingWinView.cpp
deleted file mode 100644 (file)
index e69de29..0000000
index e2cfe4b..90b0a71 100644 (file)
 #include "ohos_types.h"
 #include "components/ui_card_page.h"
 
+#include "traing/include/TraingModel.h"
+#include "traing/Training_UiConfig.h"
 #include "TraingRecordPresenter.h"
 namespace OHOS
 {
-#define BUTTONNOTE "button1"
+#define BUTTONGO "button_go"
+
+    enum class PopupView
+    {
+        LackPopup,
+        RecordPopup
+    };
 
     class TraingRecordPresenter;
     class TraingRecordView : public View<TraingRecordPresenter>
     {
-
     public:
         TraingRecordView();
         virtual ~TraingRecordView();
@@ -38,24 +45,27 @@ namespace OHOS
         void OnStop() override;
         void InitView();
         void DeInit();
-        void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize);
-        void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId);
-        void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath);
-        void InitList();
         void PreLoad(void);
 
-        // 通过函数改变
-        void SetLabel();
-        void SetButton();
+        void ShowLackView();
+        void ShowRecordView();
+        void SetPopupViewStatus(PopupView view, bool status);
 
     private:
         UIView::OnDragListener *draglistener{nullptr};
         TraingRecordView(TraingRecordView &&) = delete;
         TraingRecordView &operator=(TraingRecordView &&) = delete;
+        UIScrollView *container_ = nullptr;
+
+        /*无训练记录界面*/
+        UIScrollView *lackView{nullptr};
+        UILabelExt *labeltitle_ = nullptr;
+        UILabelExt *labelrecord_ = nullptr;
+        UILabelButtonExt *buttongo = nullptr;
+        UIImageView *imagerecord = nullptr;
 
-        UIViewGroup *container_ = nullptr;
-        UILabel *label1_ = nullptr;
-        UILabel *label2_ = nullptr;
+        /*训练列表界面*/
+        UIScrollView *recordView{nullptr};
 
         bool viewiInitStatus{false};
     };
index 22a0c8b..61de102 100644 (file)
@@ -1,6 +1,6 @@
 #include "AppViewIDs.h"
 #include "components/ui_label_ext.h"
-#include"language/font/ui_resource_string.h"
+#include "language/font/ui_resource_string.h"
 #include "NativeAbility.h"
 
 #include <iostream>
@@ -53,12 +53,18 @@ namespace OHOS
     {
         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+            NativeAbility::GetInstance().Back();
         }
         return true;
     }
 
     bool TraingRecordPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
+        // 返回按键
+        if (strcmp(view.GetViewId(), BUTTONGO) == 0)
+        {
+            NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGMORE);
+        }
+        return true;
     }
 }
index 9375a7c..875c3b6 100644 (file)
@@ -8,6 +8,7 @@
 #include "components/ui_button.h"
 namespace OHOS
 {
+    static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6;
 
     static TraingRecordView *g_pTraingRecordView{nullptr};
 
@@ -24,80 +25,69 @@ namespace OHOS
 
     TraingRecordView *TraingRecordView::GetInstance()
     {
-
         return g_pTraingRecordView;
     }
- 
+
     /* InitView:初始化界面*/
     void TraingRecordView ::InitView()
     {
         if (container_ == nullptr)
         {
-            container_ = new UIViewGroup();
+            container_ = new UIScrollView();
             container_->SetPosition(0, 0, 466, 466);
             container_->SetStyle(STYLE_BACKGROUND_OPA, 0);
         }
-        // 初始化Lable
-        // Add Label to App
-        if (label1_ == nullptr)
-        {
-            label1_ = new UILabel();
-        }
-        label1_->SetPosition(181, 52); // widget's left position and top position
-        label1_->Resize(200, 60);      // widget's width and height
-        label1_->SetViewId("label1");  // Set style
-        label1_->SetStyle(STYLE_TEXT_FONT, 26);
-
-        // Set additional property
-        label1_->SetText("训练记录");
-        label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-        label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        label1_->SetRollSpeed(0);
-        label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26);
-
-        // Add to rootView
-        container_->Add(label1_);
-        label1_->SetVisible(true);
-
-        // Add Label to App
-        if (label2_ == nullptr)
-        {
-            label2_ = new UILabel();
-        }
-        label2_->SetPosition(188, 217); // widget's left position and top position
-        label2_->Resize(200, 60);       // widget's width and height
-        label2_->SetViewId("label2");   // Set style
-        label2_->SetStyle(STYLE_TEXT_FONT, 30);
-
-        // Set additional property
-        label2_->SetText("无记录");
-        label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
-        label2_->SetTextColor(Color::GetColorFromRGBA(0x28, 0xbc, 0x0c, 0xff));
-        label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-        label2_->SetRollSpeed(0);
-        label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-
-        // Add to rootView
-        container_->Add(label2_);
-        label2_->SetVisible(true);
+        // 展示无记录界面。后续需要加入函数判断
+        SetPopupViewStatus(PopupView::LackPopup, true);
     }
 
     /* DeInit:删除组件 */
     void TraingRecordView::DeInit()
     {
         container_->RemoveAll();
-        if (label1_ != nullptr)
+        if (labeltitle_ != nullptr)
+        {
+            lackView->Remove(labeltitle_);
+            delete labeltitle_;
+            labeltitle_ = nullptr;
+        }
+        if (labelrecord_ != nullptr)
+        {
+            lackView->Remove(labelrecord_);
+            delete labelrecord_;
+            labelrecord_ = nullptr;
+        }
+        if (buttongo != nullptr)
+        {
+            lackView->Remove(buttongo);
+            delete buttongo;
+            buttongo = nullptr;
+        }
+        if (imagerecord != nullptr)
+        {
+            lackView->Remove(imagerecord);
+            delete imagerecord;
+            imagerecord = nullptr;
+        }
+
+        if (lackView != nullptr)
         {
-            delete label1_;
-            label1_ = nullptr;
+            lackView->RemoveAll();
+            delete lackView;
+            lackView = nullptr;
         }
-        if (label2_ != nullptr)
+        if (recordView != nullptr)
         {
-            delete label2_;
-            label2_ = nullptr;
+            recordView->RemoveAll();
+            delete recordView;
+            recordView = nullptr;
+        }
+        if (container_ != nullptr)
+        {
+            container_->RemoveAll();
+            delete container_;
+            container_ = nullptr;
         }
-        delete container_;
-        container_ = nullptr;
     }
 
     void TraingRecordView::PreLoad(void)
@@ -108,17 +98,90 @@ namespace OHOS
             viewiInitStatus = true;
         }
     }
+    /*显示无记录界面*/
+    void TraingRecordView::ShowLackView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowLackView start");
+        lackView = new UIScrollView();
+        if (lackView == nullptr)
+        {
+            return;
+        }
+        lackView->SetPosition(0, 0);
+        lackView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION);
+        lackView->SetScrollBlankSize(20);
+        lackView->SetReboundSize(50);
+        lackView->SetDirection(1);
+        /*初始化label*/
+        TraingModel::GetInstance()->InitLabelDefault(labeltitle_, 83, 50, 300, 35, "labletitle", "训练记录");
+        TraingModel::GetInstance()->InitLabelDefault(labelrecord_, 53, 260, 360, 40, "labelrecord", "无记录");
+        /*初始化image*/
+        TraingModel::GetInstance()->InitImageView(imagerecord, 174, 120, 118, 120, "image", RECOED_IMAGE);
+        /*初始化按键*/
+        TraingModel::GetInstance()->InitButtonExt(buttongo, 93, 330, 280, 90, BUTTONGO, STR_TRAINING, 26);
+        buttongo->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 设置按键颜色
+        buttongo->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingRecordPresenter::GetInstance()));
+
+        lackView->Add(labeltitle_);
+        lackView->Add(labelrecord_);
+        lackView->Add(imagerecord);
+        lackView->Add(buttongo);
+
+        RootView::GetInstance()->Add(lackView);
+        lackView->SetDraggable(true);
+        lackView->SetTouchable(true);
+
+        UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingRecordPresenter::GetInstance());
+        if (draglistener == nullptr)
+        {
+            return;
+        }
+        lackView->SetOnDragListener(draglistener);
+
+        lackView->SetVisible(false); // 界面隐藏
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowLackView end");
+    }
+    /*记录列表界面*/
+    void TraingRecordView::ShowRecordView()
+    {
+    }
+    /*控制显示界面*/
+    void TraingRecordView::SetPopupViewStatus(PopupView view, bool status)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view);
+        UIView *popupView = nullptr;
+        if (view == PopupView::LackPopup)
+        {
+            popupView = lackView;
+        }
+        else if (view == PopupView::RecordPopup)
+        {
+            popupView = recordView;
+        }
+
+        if (popupView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL");
+            return;
+        }
+
+        if (container_ != nullptr)
+        {
+            container_->SetVisible(!status);
+        }
+
+        popupView->SetVisible(status);
+    }
+
     void TraingRecordView::OnStart()
     {
-        container_ = new UIViewGroup();
+        container_ = new UIScrollView();
         if (container_ == nullptr)
         {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail");
             return;
         }
-        container_->SetPosition(0, 0);
-        container_->SetWidth(Screen::GetInstance().GetWidth());
-        container_->SetHeight(Screen::GetInstance().GetHeight());
-
+        container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
         // 创建 draglistener 实例并设置为拖动监听器
         UIView::OnDragListener *draglistener = static_cast<UIView::OnDragListener *>(TraingRecordPresenter::GetInstance());
         if (draglistener == nullptr)
@@ -126,10 +189,12 @@ namespace OHOS
             return;
         }
         container_->SetOnDragListener(draglistener);
-
         container_->SetTouchable(true);
         container_->SetDraggable(true);
+        container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR);
+        container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full);
 
+        ShowLackView();
         PreLoad();
         RootView::GetInstance()->Add(container_);
     }
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Norecord.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Norecord.bin
new file mode 100644 (file)
index 0000000..efc960e
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Norecord.bin differ
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Walking_54.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Walking_54.bin
new file mode 100644 (file)
index 0000000..0c97705
Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Walking_54.bin differ