主界面增加睡眠卡片
authorCaisking <3449750381@qq.com>
Wed, 26 Jun 2024 01:50:39 +0000 (09:50 +0800)
committerCaisking <3449750381@qq.com>
Wed, 26 Jun 2024 01:50:39 +0000 (09:50 +0800)
13 files changed:
code/sdk/application/wearable/fd230app/CMakeLists.txt
code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h
code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h
code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp
code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp
code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp
code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepCardView.h
code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepControlPresenter.h
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepCardView.cpp
code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepControlPresenter.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/SleepCard.bin [new file with mode: 0644]
tools/image_converter_tool/test/hert/maincard/SleepCard.png [new file with mode: 0644]
tools/image_converter_tool/test/hert/maincard/SleepCard.png:Zone.Identifier [new file with mode: 0644]

index cb109d1..33ca91d 100644 (file)
@@ -621,6 +621,7 @@ set(SOURCES
 
     #睡眠
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepCardView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepTimeView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepControlView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepControlPresenter.cpp
index b44e99a..28b74ea 100644 (file)
@@ -24,9 +24,9 @@ namespace OHOS
         BLOODOXGEN,
         WEATHER,
         TRAINING,
-        // ACTIVITY,
         SETCARD,
         GOAL,
+        SLEEP,
         MAX_CARD,
     } CardId;
 
@@ -79,6 +79,7 @@ namespace OHOS
     static constexpr const char *PNG_SET_CARD_WEATHER = APP_RES_PATH "/MainCard/WeatherCard.bin";
     static constexpr const char *PNG_SET_CARD_ACTIVITY = APP_RES_PATH "/MainCard/SportCard.bin";
     static constexpr const char *PNG_SET_CARD_MAIN = APP_RES_PATH "/MainCard/SetMainCard.bin";
+    static constexpr const char *PNG_SET_CARD_SLEEP = APP_RES_PATH "/MainCard/SleepCard.bin";
     static constexpr const char *DROPDOWN_IAMGES = APP_RES_PATH "/MainCard/dropdown.bin";
     static constexpr const char *CLOCK_IAMGES = APP_RES_PATH "/MainCard/clock.bin";
     static constexpr const char *PLAYER_IAMGES = APP_RES_PATH "/MainCard/player.bin";
index 353aa2b..39faea9 100644 (file)
@@ -39,6 +39,7 @@
 #include "goal/include/goalControlView.h"
 
 #include "message/include/MessageControlView.h"
+#include "sleep/include/SleepCardView.h"
 #include "set_card/include/SetMainView.h"
 namespace OHOS
 {
@@ -62,7 +63,8 @@ namespace OHOS
         UICardPage *InitBloodOxygenPage(void);
         UICardPage *InitWeatherPage(void);
         UICardPage *InitGoalPage(void);
-
+        
+        UICardPage *InitSleepPage(void);
         UICardPage *InitTrainingPage(void);
         UICardPage *InitApplistPage(void);
         UICardPage *InitSetMainPage(void);
@@ -106,15 +108,15 @@ namespace OHOS
         ActivityWeekView *activityWeekView{nullptr};
         PlayersView *playersView{nullptr};
         CompassControlView *compassControlView{nullptr};
+
         HeartRateView *heartRateView{nullptr};
         BloodCardView *bloodView{nullptr};
-
-        WeatherControlView *weatherControlView{nullptr};
-        goalControlView *GoalControlView{nullptr};
-
+        SleepCardView *sleepView{nullptr};
         Training_CardView *traingView{nullptr};
         SetMainView *setmainView{nullptr};
 
+        WeatherControlView *weatherControlView{nullptr};
+        goalControlView *GoalControlView{nullptr};
         // ApplistCardView *applistCardView{nullptr};
         UIButton *changebut{nullptr};
         UIImageView *disturbIcon{nullptr}; // 勿扰图标
index 9c055de..ccacb18 100644 (file)
@@ -24,7 +24,7 @@ namespace OHOS
         {WEATHER, PNG_SET_CARD_WEATHER},\r
         {TRAINING, PNG_SET_CARD_TRAIN},\r
         {GOAL, PNG_SET_CARD_ACTIVITY},\r
-        // {ACTIVITY, PNG_SET_CARD_ACTIVITY},\r
+        {SLEEP, PNG_SET_CARD_SLEEP},\r
     };\r
     /*自定义map?*/\r
     const DialInfo dialInfoMap[] = {\r
index 4c0c317..d3eac90 100644 (file)
@@ -36,9 +36,13 @@ namespace OHOS
         {BLOODOXGEN, &MainViewSample::InitBloodOxygenPage},
         {WEATHER, &MainViewSample::InitWeatherPage},
         {TRAINING, &MainViewSample::InitTrainingPage},
-        //{ACTIVITY, &MainViewSample::InitActivityPage},
         {SETCARD, &MainViewSample::InitSetMainPage},
         {GOAL, &MainViewSample::InitGoalPage},
+        {SLEEP, &MainViewSample::InitSleepPage},
+
+#if 0
+        {ACTIVITY, &MainViewSample::InitActivityPage},
+#endif
     };
     MainViewSample::MainViewSample()
     {
@@ -127,7 +131,18 @@ namespace OHOS
             delete bloodView;
             bloodView = nullptr;
         }
-
+        if (setmainView != nullptr)
+        {
+            setmainView->RemoveAll();
+            delete setmainView;
+            setmainView = nullptr;
+        }
+        if (sleepView != nullptr)
+        {
+            sleepView->RemoveAll();
+            delete sleepView;
+            sleepView = nullptr;
+        }
         if (traingView != nullptr)
         {
             traingView->RemoveAll();
@@ -495,6 +510,18 @@ namespace OHOS
         }
         return setmainView;
     }
+    /*主界面睡眠卡片*/
+    UICardPage *MainViewSample::InitSleepPage(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitSetMainPage");
+        sleepView = new SleepCardView();
+        if (sleepView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepView new fail");
+            return nullptr;
+        }
+        return sleepView;
+    }
     void MainViewSample::SetPage(int16_t page)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::SetPage");
index b5622b7..63bfdb3 100644 (file)
@@ -49,7 +49,7 @@ namespace OHOS
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bool SetMainView::InitView()");
         //  初始化label
-        InitLabel(setLabel, 83, 50, 300, 35, "labletitle", "设置卡片", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        InitLabelExt(setLabel, 83, 50, 300, 35, "labletitle", STR_CARD_MANAGEMENT, DEFAULT_VECTOR_FONT_FILENAME, 30);
         Add(setLabel);
         //  初始化Button
         InitButton(setButton, 183, 183, 100, 100, SET_CARD_MAIN);
index e69de29..c916e8e 100644 (file)
@@ -0,0 +1,27 @@
+#ifndef SLEEP_CARD_VIEW_H\r
+#define SLEEP_CARD_VIEW_H\r
+\r
+#include "components/root_view.h"\r
+#include "components/ui_card_page.h"\r
+#include "wearable_log.h"\r
+#include "sleep/include/SleepControlView.h"\r
+namespace OHOS\r
+{\r
+    class SleepControlView;\r
+    class SleepCardView : public UICardPage\r
+    {\r
+    public:\r
+        SleepCardView();\r
+        virtual ~SleepCardView();\r
+        bool InitView(void);\r
+        void PreLoad(void) override;\r
+        void UnLoad(void) override;\r
+\r
+    private:\r
+        void ClearAll(void);\r
+        SleepControlView *sleepcontrolView{nullptr};\r
+        UISwipeView::OnSwipeListener *sleepOnSwipeListener{nullptr};\r
+        bool viewiInitStatus{false};\r
+    };\r
+}\r
+#endif
\ No newline at end of file
index c1e48ca..29cfd42 100644 (file)
@@ -1,15 +1,4 @@
-/***
- * @Date: 2024-06-25 10:32:53
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-06-25 17:35:04
- * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepControlPresenter.h
- */
-/***
- * @Date: 2024-06-25 10:32:53
- * @LastEditors: Caisking 3449750381@qq.com
- * @LastEditTime: 2024-06-25 17:33:56
- * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepControlPresenter.h
- */
+
 /***
  * @Date: 2024-06-25 10:32:53
  * @LastEditors: Caisking 3449750381@qq.com
 #include "sleep/include/SleepControlView.h"
 namespace OHOS
 {
-    class SleepViewOnSwipeListener : public UISwipeView::OnSwipeListener
+    class SleepOnSwipeListener : public UISwipeView::OnSwipeListener
     {
     public:
-        SleepViewOnSwipeListener() {}
-        ~SleepViewOnSwipeListener() {}
+        SleepOnSwipeListener() {}
+        ~SleepOnSwipeListener() {}
         void OnSwipe(UISwipeView &view) override;
     };
 
index e69de29..780c41c 100644 (file)
@@ -0,0 +1,84 @@
+#include "sleep/include/SleepCardView.h"\r
+#include "sleep/include/SleepControlView.h"\r
+#include "sleep/include/SleepControlPresenter.h"\r
+namespace OHOS\r
+{\r
+    SleepCardView::SleepCardView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepCardView::SleepCardView");\r
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);\r
+    }\r
+\r
+    SleepCardView::~SleepCardView()\r
+    {\r
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepCardView::~SleepCardView");\r
+        ClearAll();\r
+    }\r
+\r
+    void SleepCardView::ClearAll(void)\r
+    {\r
+        if (viewiInitStatus == true)\r
+        {\r
+            RemoveAll();\r
+            if (sleepcontrolView != nullptr)\r
+            {\r
+                if (sleepOnSwipeListener != nullptr)\r
+                {\r
+                    delete sleepOnSwipeListener;\r
+                    sleepOnSwipeListener = nullptr;\r
+                }\r
+                \r
+                if (sleepcontrolView != nullptr)\r
+                {\r
+                    delete sleepcontrolView;\r
+                    sleepcontrolView = nullptr;\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    bool SleepCardView::InitView(void)\r
+    {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepCardView::InitView");\r
+        sleepcontrolView = new SleepControlView();\r
+        if (sleepcontrolView == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepView::new SleepView fail!");\r
+            return false;\r
+        }\r
+\r
+        UISwipeView *SleepSwipView = dynamic_cast<UISwipeView *>(sleepcontrolView->GetSleepControlPageView());\r
+        if (SleepSwipView == nullptr)\r
+        {\r
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepView->SleepViewInit() == nullptr!!");\r
+            return false;\r
+        }\r
+\r
+        sleepOnSwipeListener = static_cast<UISwipeView::OnSwipeListener *>(new SleepControlPresenter());\r
+        if (sleepOnSwipeListener == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleepOnSwipeListener new fail");\r
+            return false;\r
+        }\r
+        SleepSwipView->SetOnSwipeListener(sleepOnSwipeListener);\r
+        Add(SleepSwipView);\r
+       \r
+        return true;\r
+    }\r
+\r
+    void SleepCardView::PreLoad(void)\r
+    {\r
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepCardView::PreLoad");\r
+        if (!viewiInitStatus)\r
+        {\r
+            InitView();\r
+            viewiInitStatus = true;\r
+        }\r
+    }\r
+\r
+    void SleepCardView::UnLoad(void)\r
+    {\r
+        // Weather's usage scenes is complicated, so we do not release it's resources inner slice.\r
+    }\r
+\r
+}
\ No newline at end of file
index 0c84616..5c32fd1 100644 (file)
@@ -6,7 +6,7 @@
 #include <custom_utils.h>
 #include <ohos_types.h>
 #include "UiConfig.h"
-
+#include "string.h"
 namespace OHOS
 {
 
@@ -96,11 +96,10 @@ namespace OHOS
     }
 
     void SleepControlPresenter::OnSwipe(UISwipeView &view) {}
-#if 0
-    void SleepControlViewOnSwipeListener::OnSwipe(UISwipeView &view)
+    void SleepOnSwipeListener::OnSwipe(UISwipeView &view)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepControlViewOnSwipeListener::OnSwipe,current tab index = %d", view.GetCurrentPage());
-        if (view.GetCurrentPage() == SleepControlView)
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepOnSwipeListener::OnSwipe,current tab index = %d", view.GetCurrentPage());
+        if (view.GetCurrentPage() == MAINSLEEPVIEW)
         {
             view.SetIntercept(false);
         }
@@ -110,5 +109,4 @@ namespace OHOS
         }
         return;
     }
-#endif
 }
\ No newline at end of file
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/SleepCard.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/MainCard/SleepCard.bin
new file mode 100644 (file)
index 0000000..55488d0
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4463577e620d95e311db7999ae4318d15d66238b05cf8a4f08973151876b9702
+size 52664
diff --git a/tools/image_converter_tool/test/hert/maincard/SleepCard.png b/tools/image_converter_tool/test/hert/maincard/SleepCard.png
new file mode 100644 (file)
index 0000000..c065a4c
Binary files /dev/null and b/tools/image_converter_tool/test/hert/maincard/SleepCard.png differ
diff --git a/tools/image_converter_tool/test/hert/maincard/SleepCard.png:Zone.Identifier b/tools/image_converter_tool/test/hert/maincard/SleepCard.png:Zone.Identifier
new file mode 100644 (file)
index 0000000..053d112
--- /dev/null
@@ -0,0 +1,3 @@
+[ZoneTransfer]\r
+ZoneId=3\r
+HostUrl=about:internet\r