增加主界面配置卡片,UI需要优化
authorCaisking <3449750381@qq.com>
Wed, 12 Jun 2024 12:24:48 +0000 (20:24 +0800)
committerCaisking <3449750381@qq.com>
Wed, 12 Jun 2024 12:24:48 +0000 (20:24 +0800)
12 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/include/SetCardPresenter.h
code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetMainView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetCardPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp [new file with mode: 0644]
code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/Enter.bin [new file with mode: 0644]
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/OK.bin [new file with mode: 0644]

index ed13545..35b5d60 100644 (file)
@@ -271,6 +271,7 @@ set(SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardModel.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardPresenter.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardView.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetMainView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardNoCardView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/set_card/src/SetCardDeleteView.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/add_card/src/AddCardAdapter.cpp
index 6f6e05d..1ef6816 100644 (file)
@@ -25,6 +25,7 @@ namespace OHOS
         WEATHER,
         TRAINING,
         ACTIVITY,
+        SETCARD,     
         MAX_CARD,
     } CardId;
 
@@ -318,9 +319,9 @@ namespace OHOS
     static constexpr const char *PNG_TOGGLEBUTTON_ON_IMAGE = APP_RES_PATH "/TOGGLEBUTTON_ON.bin";              // togglebuttton选中图片
     static constexpr const char *PNG_ATTENTION_IMAGE = APP_RES_PATH "/Attention.bin";                          // 注意
 
-    static constexpr const char *PNG_SUCC_IMAGE = APP_RES_PATH "/OK.bin";                          // 成功
+    static constexpr const char *PNG_SUCC_IMAGE = APP_RES_PATH "/OK.bin"; // 成功
 
-    static constexpr const char *PNG_466x100BUTTON_IMAGE = APP_RES_PATH "/466x100button.bin";                  // 466x100button图片
+    static constexpr const char *PNG_466x100BUTTON_IMAGE = APP_RES_PATH "/466x100button.bin"; // 466x100button图片
 
     /* -------------------------------- 已删除的不必要图片 ------------------------------- */
     static constexpr const char *PNG_APPLIST_UI_SAMPLE_IMAGE = APP_RES_PATH "/APPLIST_UI_SAMPLE.bin"; // Applist图标
index 7ece8f9..85e765a 100644 (file)
@@ -37,6 +37,7 @@
 // #include "ApplistCardView.h"
 #include "weather/include/WeatherControlView.h"
 #include "message/include/MessageCardView.h"
+#include "set_card/include/SetMainView.h"
 namespace OHOS
 {
     class MainPresenterSample;
@@ -60,6 +61,7 @@ namespace OHOS
         UICardPage *InitWeatherPage(void);
         UICardPage *InitTrainingPage(void);
         UICardPage *InitApplistPage(void);
+        UICardPage *InitSetMainPage(void);
 
         void AnimatorStart(int pageIndex);
         void AnimatorStop(void);
@@ -85,7 +87,7 @@ namespace OHOS
                 SetPage(mainClockView->GetViewIndex());
             }
         }
-    void SwitchToCard(uint8_t cardId);
+        void SwitchToCard(uint8_t cardId);
         bool IsMainClockPage(void);
         bool IsPullUpViewPage(void);
         void SetDragFg(bool continFg);
@@ -104,6 +106,7 @@ namespace OHOS
         BloodCardView *bloodView{nullptr};
         WeatherControlView *weatherControlView{nullptr};
         Training_CardView *traingView{nullptr};
+        SetMainView *setmainView{nullptr};
         // ApplistCardView *applistCardView{nullptr};
         UIButton *changebut{nullptr};
         UIImageView *disturbIcon{nullptr}; // 勿扰图标
@@ -118,8 +121,8 @@ namespace OHOS
         void VertViewLoad(void);
         void HorViewLoad(void);
 
-    UICardPage *InitWatchOffDial(DialSetting &setting);
-    UICardPage *InitWatchDial(DialSetting &setting);
+        UICardPage *InitWatchOffDial(DialSetting &setting);
+        UICardPage *InitWatchDial(DialSetting &setting);
     };
 } // namespace OHOS
 #endif // MAIN_VIEW_SAMPLE_H
index 0b2beb7..d0a7815 100644 (file)
@@ -24,8 +24,9 @@ namespace OHOS
         {WEATHER, PNG_SET_CARD_WEATHER},\r
         {TRAINING, PNG_SET_CARD_TRAIN},\r
         {ACTIVITY, PNG_SET_CARD_ACTIVITY},\r
+        {SETCARD, PNG_SET_CARD_ACTIVITY},\r
     };\r
-\r
+    /*自定义map?*/\r
     const DialInfo dialInfoMap[] = {\r
         {DIAL_CLOCK, "KUMI", DEFAULT_DIALPER_PATH, DEFAULT_TASK_PERIOD},\r
     };\r
@@ -96,6 +97,7 @@ namespace OHOS
             cardSettings[index++] = COMPASS;\r
             cardSettings[index++] = ACTIVITY;\r
             cardSettings[index++] = MUSIC_PLAYER;\r
+            cardSettings[index++] = SETCARD; // 默认卡片增加设置卡片\r
             cardSettingCount = index;\r
         }\r
     }\r
@@ -165,7 +167,7 @@ namespace OHOS
         dialSetting.dialId = DIAL_CLOCK;\r
         dialSetting.dialFullName = "";\r
     }\r
-\r
+    /*更新表盘设置*/\r
     void MainModel::AddDialSetting(const DialSetting &setting)\r
     {\r
         std::string tmp;\r
@@ -177,7 +179,7 @@ namespace OHOS
         tmp += ",";\r
         (void)UtilsSetValue("dial_setting", tmp.c_str());\r
     }\r
-\r
+    /*加载kvstore里面的dial*/\r
     void MainModel::InitDialSettings(void)\r
     {\r
         char temp[DIAL_SETTING_VALUE_LEN] = {0};\r
index 5590ae7..1073acd 100644 (file)
@@ -37,8 +37,8 @@ namespace OHOS
         {WEATHER, &MainViewSample::InitWeatherPage},
         {TRAINING, &MainViewSample::InitTrainingPage},
         {ACTIVITY, &MainViewSample::InitActivityPage},
+        {SETCARD, &MainViewSample::InitSetMainPage},
     };
-
     MainViewSample::MainViewSample()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::MainViewSample");
@@ -329,7 +329,7 @@ namespace OHOS
         RootView::GetInstance()->RemoveAll();
         return;
     }
-UICardPage *MainViewSample::InitWatchOffDial(DialSetting &setting)
+    UICardPage *MainViewSample::InitWatchOffDial(DialSetting &setting)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitWathOffDial");
         DialViewGroup *dial = new DialViewGroup();
@@ -337,7 +337,7 @@ UICardPage *MainViewSample::InitWatchOffDial(DialSetting &setting)
         // dial->SetDial(DEFAULT_DIAL_PATH);
         return dial;
     }
-UICardPage *MainViewSample::InitWatchDial(DialSetting &setting)
+    UICardPage *MainViewSample::InitWatchDial(DialSetting &setting)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitWathDial");
         switch (setting.dialId)
@@ -462,7 +462,18 @@ UICardPage *MainViewSample::InitWatchDial(DialSetting &setting)
         }
         return activityWeekView;
     }
-
+    /*主界面设置卡片*/
+    UICardPage *MainViewSample::InitSetMainPage(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::InitSetMainPage");
+        setmainView = new SetMainView();
+        if (setmainView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "setmainView new fail");
+            return nullptr;
+        }
+        return setmainView;
+    }
     void MainViewSample::SetPage(int16_t page)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainViewSample::SetPage");
@@ -512,7 +523,7 @@ UICardPage *MainViewSample::InitWatchDial(DialSetting &setting)
         /* pageId 与CardId 没有对应关系,需要一次转换 */
         return cardSettings[pageId];
     }
-    
+
     void MainViewSample::SwitchToCard(uint8_t cardId)
     {
         if ((cardId < MAX_CARD) && (recordCard[cardId] != nullptr))
index c4080fa..716ee87 100644 (file)
@@ -1,3 +1,9 @@
+/*** 
+ * @Date: 2024-06-07 16:39:04
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-11 20:18:34
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetCardPresenter.h
+ */
 /*
  * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
  * Description: SetCardPresenter.h
@@ -21,6 +27,7 @@ static const char *SET_CARD_DEL = "setcarddel";
 static const char *SET_CARD_DEL_CONFIRM = "setcarddelconfirm";
 static const char *SET_CARD_DEL_CANCEL = "setcarddelcancel";
 static const char *SET_CARD_IMG = "setcardimg";
+static const char *SET_CARD_MAIN = "setmaincard";
 
 const uint16_t MISS_SET_CARD_OPERATION_TIME = 3000;
 
@@ -32,7 +39,12 @@ class SetCardPresenter : public Presenter<SetCardView>,
 public:
     SetCardPresenter();
     ~SetCardPresenter() override;
-
+    static SetCardPresenter *GetInstance()
+    {
+        static SetCardPresenter instance;
+        return &instance;
+    }
+    
     void OnStart() override;
     void OnResume() override;
     void OnStop() override;
diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetMainView.h b/code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetMainView.h
new file mode 100644 (file)
index 0000000..aad2574
--- /dev/null
@@ -0,0 +1,51 @@
+/***
+ * @Date: 2024-06-11 20:17:28
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-11 20:23:43
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetMainView.h
+ */
+
+#ifndef _Set_Main_VIEW_H
+#define _Set_Main_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_card_page.h"
+#include "SetCardPresenter.h"
+
+namespace OHOS
+{
+
+    class SetMainView : public UICardPage
+    {
+
+    public:
+        SetMainView();
+        virtual ~SetMainView();
+        static SetMainView *GetInstance(void);
+
+        bool InitView();
+        void DeInit();
+        void PreLoad(void) override;
+        void UnLoad(void) override;
+
+    private:
+        SetCardPresenter *presenter_;
+        SetMainView(SetMainView &&) = delete;
+        SetMainView &operator=(SetMainView &&) = delete;
+
+        UIButton *setButton = nullptr;
+        UILabelExt *setLabel = nullptr;
+
+        bool viewiInitStatus{false};
+    };
+} // namespace OHOS
+#endif // Set_PRESENTER_H
index a76bc3f..c36e858 100644 (file)
@@ -69,6 +69,10 @@ namespace OHOS {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_IMG");
             GoToMainView();
         }
+        else if (strcmp(view.GetViewId(), SET_CARD_MAIN) == 0) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_MAIN");
+            NativeAbility::GetInstance().ChangeSlice(VIEW_SET_CARD);
+        }
         ResetTickTimer();
         return true;
     }
diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp
new file mode 100644 (file)
index 0000000..b5622b7
--- /dev/null
@@ -0,0 +1,101 @@
+/***
+ * @Date: 2024-06-11 20:17:37
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-11 20:25:06
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp
+ */
+
+#include "set_card/include/SetMainView.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 "MainViewSample.h"
+#include "components/ui_view_group.h"
+#include "UiConfig.h"
+#include "uicomponents/UIComponents.h"
+#include "MainPresenter.h"
+#include "SetCardPresenter.h"
+namespace OHOS
+{
+    static SetMainView *g_pSetMainView{nullptr};
+    static constexpr const char *BUTTONENTER_IMAGE = "user/res/users/Enter.bin";
+    SetMainView::SetMainView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMainView::SetMainView");
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        g_pSetMainView = this;
+    }
+
+    SetMainView::~SetMainView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetMainView::~SetMainView");
+        RemoveAll();
+        DeInit();
+        g_pSetMainView = nullptr;
+    }
+
+    SetMainView *SetMainView::GetInstance()
+    {
+        return g_pSetMainView;
+    }
+
+    /***
+     * @description:
+     * @return 是否初始化成功
+     */
+    bool SetMainView::InitView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "bool SetMainView::InitView()");
+        //  初始化label
+        InitLabel(setLabel, 83, 50, 300, 35, "labletitle", "设置卡片", DEFAULT_VECTOR_FONT_FILENAME, 30);
+        Add(setLabel);
+        //  初始化Button
+        InitButton(setButton, 183, 183, 100, 100, SET_CARD_MAIN);
+        setButton->SetImageSrc(BUTTONENTER_IMAGE, BUTTONENTER_IMAGE);
+        setButton->SetOnClickListener(static_cast<UIView::OnClickListener *>(SetCardPresenter::GetInstance()));
+        Add(setButton);
+        return true;
+    }
+    /***
+     * @description:
+     * @return 删除组件
+     */
+    void SetMainView::DeInit()
+    {
+        RemoveAll();
+        if (setButton != nullptr)
+        {
+            delete setButton;
+            setButton = nullptr;
+        }
+        if (setLabel != nullptr)
+        {
+            delete setLabel;
+            setLabel = nullptr;
+        }
+    }
+    /* -------------------------------------------------------------------------- */
+    void SetMainView::PreLoad(void)
+    {
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void SetMainView::UnLoad(void)
+    {
+#if 0
+        if (resLoadStatus)
+        {
+            ImageInfo *img = nullptr;
+            background->SetSrc(img);
+            ImageCacheManager::GetInstance().UnloadOneInMultiRes(BLOODOXYGEN_BACKGOUND, BLOOD_IAMGES);
+            resLoadStatus = false;
+        }
+#endif
+    }
+    /* -------------------------------------------------------------------------- */
+}
index cefddd0..4c8ce18 100644 (file)
@@ -24,7 +24,6 @@ namespace OHOS {
             keyActListenr = nullptr;
         }
     }
-
     void SetCardPresenter::OnStart()
     {
         Presenter<SetCardView>::OnStart();
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/Enter.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/Enter.bin
new file mode 100644 (file)
index 0000000..99185a8
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cdbfe351e463c51444d5193c213021d6c99de65721a43863aa32525744ac12af
+size 6824
diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/OK.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/OK.bin
new file mode 100644 (file)
index 0000000..53b7d17
--- /dev/null
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:bc5b0d633a9631629f6c1521d0c4248901d95418b970085cd6af81d9d5529b9f
+size 4504