【设置卡片】UI
authorCaisking <Casiking@zhihuishixun.com>
Tue, 15 Apr 2025 07:01:24 +0000 (15:01 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Tue, 15 Apr 2025 07:01:24 +0000 (15:01 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardPresenter.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardView.h
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetMainView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardModel.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardView.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetMainView.cpp [new file with mode: 0644]

index fb73852..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
@@ -11,6 +17,7 @@
 #include "Presenter.h"
 #include "components/ui_list.h"
 #include "components/ui_view.h"
+#include "KeyInputListener.h"
 #include "ModelListenerSample.h"
 
 namespace OHOS {
@@ -20,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;
 
@@ -31,7 +39,15 @@ 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;
     bool OnClick(UIView &view, const ClickEvent &event) override;
     void OnScrollStart(int16_t index, UIView *view) override;
     void OnScrollEnd(int16_t index, UIView *view) override;
@@ -47,6 +63,7 @@ public:
 private:
     void GoToMainView(void);
     void ResetTickTimer(void);
+    KeyInputListener *keyActListenr{nullptr};
     SetCardModel *model{nullptr};
     uint64_t startTime{0};
 };
index 22e95d8..ec161ca 100644 (file)
@@ -13,6 +13,8 @@
 #include "components/ui_label.h"
 #include "components/ui_image_view.h"
 #include "components/ui_toggle_button.h"
+#include "window/window.h"
+
 #include "ChangeSliceListener.h"
 #include "UiConfig.h"
 #include "SetCardAdapter.h"
@@ -35,6 +37,7 @@ public:
     }
 
     void OnStart() override;
+   
     void ShowDeleteView(bool show);
     void ShowAddView(bool show);
     void RefreshCardList(void);
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetMainView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetMainView.h
new file mode 100644 (file)
index 0000000..f76e5f8
--- /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 "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 c916f4c..195276e 100644 (file)
@@ -7,8 +7,8 @@
 \r
 #include "UiConfig.h"\r
 #include <string>\r
+#include "cmsis_os.h"\r
 #include "SetCardDeleteView.h"\r
-#include "wearable_log.h"\r
 \r
 namespace OHOS {\r
 \r
@@ -36,7 +36,7 @@ bool SetCardDeleteView::InitView()
     confirmBtn.SetPosition(184, 118);\r
     confirmBtn.Resize(86, 50);\r
     confirmBtn.SetViewId(SET_CARD_DEL_CONFIRM);\r
-    confirmBtn.SetText("删除");\r
+    // confirmBtn.SetText("删除");\r
     confirmBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
     confirmBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
     confirmBtn.SetOnClickListener(presenter_);\r
@@ -44,7 +44,7 @@ bool SetCardDeleteView::InitView()
     cancelBtn.SetPosition(186, 231);\r
     cancelBtn.Resize(82, 50);\r
     cancelBtn.SetViewId(SET_CARD_DEL_CANCEL);\r
-    cancelBtn.SetText("取消");\r
+    // cancelBtn.SetText("取消");\r
     cancelBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
     cancelBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
     cancelBtn.SetOnClickListener(presenter_);\r
index 32ca2b5..4f32dbc 100644 (file)
@@ -10,7 +10,8 @@
 #include "kv_store.h"
 #include "securec.h"
 
-namespace OHOS {
+namespace OHOS
+{
     SetCardModel::SetCardModel() {}
 
     SetCardModel::~SetCardModel() {}
@@ -27,8 +28,10 @@ namespace OHOS {
         uint8_t cardCount = MainModel::GetInstance().GetCardSettingCount();
         CardId *cardSettings = MainModel::GetInstance().GetCardSettings();
         cardShowCount = 0;
-        for (uint8_t i = 0; i < cardCount; i++) {
-            if (cardSettings[i] == WATCH_FACE) {
+        for (uint8_t i = 0; i < cardCount; i++)
+        {
+            if (cardSettings[i] == WATCH_FACE)
+            {
                 continue;
             }
             cardShowList[cardShowCount++] = cardSettings[i];
index eadcec9..5ea9133 100644 (file)
@@ -7,8 +7,8 @@
 \r
 #include "UiConfig.h"\r
 #include <string>\r
+#include "cmsis_os.h"\r
 #include "SetCardNoCardView.h"\r
-#include "wearable_log.h"\r
 \r
 namespace OHOS {\r
 \r
@@ -34,7 +34,7 @@ bool SetCardNoCardView::InitView()
     addBtn.SetPosition(184, 118);\r
     addBtn.Resize(86, 50);\r
     addBtn.SetViewId(SET_CARD_ADD);\r
-    addBtn.SetText("添加");\r
+    // addBtn.SetText("添加");\r
     addBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
     addBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
     addBtn.SetOnClickListener(presenter_);\r
index 11d88d8..01dd8b3 100644 (file)
 #include "SetCardPresenter.h"
 #include "hal_tick.h"
 #include "NativeRegisterManager.h"
+namespace OHOS
+{
 
-
-namespace OHOS {
-
-REGIST_SLICE(VIEW_SET_CARD, SetCardView, SetCardPresenter);
-
+    REGIST_SLICE(VIEW_SET_CARD, SetCardView, SetCardPresenter);
     SetCardPresenter::SetCardPresenter()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SetCardPresenter");
@@ -27,28 +25,55 @@ REGIST_SLICE(VIEW_SET_CARD, SetCardView, SetCardPresenter);
     {
     }
 
+    void SetCardPresenter::OnStart()
+    {
+    }
+
+    void SetCardPresenter::OnResume(void)
+    {
+    }
+
+    void SetCardPresenter::OnStop(void)
+    {
+        RootView::GetInstance()->ClearOnKeyActListener();
+    }
+
     bool SetCardPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnClick");
-        if (strcmp(view.GetViewId(), SET_CARD_ADD) == 0) {
+        if (strcmp(view.GetViewId(), SET_CARD_ADD) == 0)
+        {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_ADD");
             NativeAbility::GetInstance().ChangeSlice(VIEW_ADD_CARD);
-        } else if (strcmp(view.GetViewId(), SET_CARD_DEL) == 0) {
+        }
+        else if (strcmp(view.GetViewId(), SET_CARD_DEL) == 0)
+        {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL");
             view_->SaveSelectCardIndex();
             view_->ShowDeleteView(true);
-        } else if (strcmp(view.GetViewId(), SET_CARD_DEL_CONFIRM) == 0) {
+        }
+        else if (strcmp(view.GetViewId(), SET_CARD_DEL_CONFIRM) == 0)
+        {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL_CONFIRM");
             model->DeleteCardSetting();
             view_->ShowDeleteView(false);
             view_->RefreshCardList();
-        } else if (strcmp(view.GetViewId(), SET_CARD_DEL_CANCEL) == 0) {
+        }
+        else if (strcmp(view.GetViewId(), SET_CARD_DEL_CANCEL) == 0)
+        {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::SET_CARD_DEL_CANCEL");
             view_->ShowDeleteView(false);
-        } else if (strcmp(view.GetViewId(), SET_CARD_IMG) == 0) {
+        }
+        else if (strcmp(view.GetViewId(), SET_CARD_IMG) == 0)
+        {
             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_ADD_CARD);
+        }
         ResetTickTimer();
         return true;
     }
@@ -62,17 +87,19 @@ REGIST_SLICE(VIEW_SET_CARD, SetCardView, SetCardPresenter);
     void SetCardPresenter::OnScrollEnd(int16_t index, UIView *view)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnScrollEnd index = %d", index);
-        if (view == nullptr) {
+        if (view == nullptr)
+        {
             return;
         }
         SetSelectedCardIndex(index);
         ResetTickTimer();
     }
 
-    void SetCardPresenter::OnItemSelected(int16_t index, UIView* view)
+    void SetCardPresenter::OnItemSelected(int16_t index, UIView *view)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::OnItemSelected index = %d", index);
-        if (view == nullptr) {
+        if (view == nullptr)
+        {
             return;
         }
     }
@@ -111,9 +138,11 @@ REGIST_SLICE(VIEW_SET_CARD, SetCardView, SetCardPresenter);
     {
         uint8_t *cardSettings = model->GetCardShowList();
         uint8_t selectIndex = model->GetSelectedCardIndex();
-        if (selectIndex < model->GetCardShowCount()) {
+        if (selectIndex < model->GetCardShowCount())
+        {
             const CardInfo *info = MainModel::GetInstance().GetCardInfo(static_cast<CardId>(cardSettings[selectIndex]));
-            if (info != nullptr) {
+            if (info != nullptr)
+            {
                 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardPresenter::GoToMainView %d", info->id);
                 MainModel::GetInstance().SetFromSetCardView(true);
                 MainModel::GetInstance().SetFromCardId(info->id);
@@ -124,16 +153,15 @@ REGIST_SLICE(VIEW_SET_CARD, SetCardView, SetCardPresenter);
 
     void SetCardPresenter::OnTickEvent()
     {
-        uint64_t current_time = static_cast<uint64_t>(HALTick::GetInstance().GetTime());
-
-        if ((startTime != 0) && (current_time - startTime > MISS_SET_CARD_OPERATION_TIME)) {
-            GoToMainView();
-        }
+        // uint64_t current_time = osKernelGetTick2ms();
+        // if ((startTime != 0) && (current_time - startTime > MISS_SET_CARD_OPERATION_TIME))
+        // {
+        //     GoToMainView();
+        // }
     }
 
     void SetCardPresenter::ResetTickTimer(void)
     {
-        startTime = static_cast<uint64_t>(HALTick::GetInstance().GetTime());
-
+        // startTime = osKernelGetTick2ms();
     }
 }
index c375c86..e48b69e 100644 (file)
@@ -36,18 +36,25 @@ SetCardView::~SetCardView()
 
 void SetCardView::OnStart()
 {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetCardView::OnStart");
+   
     setCardAdapter_ = new SetCardAdapter();
     setCardAdapter_->SetItemClickListener(presenter_);
     SetUpListInfo();
     SetUpListView();
     SetUpDeleteView();
     SetUpAddView();
+
     ShowDeleteView(false);
     if (setCardAdapter_->GetCount() == 0) {
         ShowAddView(true);
     }
 }
 
+
+
+
+
 void SetCardView::SetUpListInfo(void)
 {
     presenter_->InitCardShowList();
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetMainView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetMainView.cpp
new file mode 100644 (file)
index 0000000..68f87a5
--- /dev/null
@@ -0,0 +1,106 @@
+/***
+ * @Date: 2024-07-04 19:24:05
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-02 14:31:07
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp
+ */
+/***
+ * @Date: 2024-06-11 20:17:37
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-26 11:25:56
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp
+ */
+/***
+ * @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 "MainPresenterSample.h"
+#include "SetCardPresenter.h"
+#include "MainPresenterSample.h"
+namespace OHOS
+{
+    static SetMainView *g_pSetMainView{nullptr};
+    static constexpr const char *BUTTONENTER_IMAGE = "user/res/users/AddCard.bin";
+    SetMainView::SetMainView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetMainView::SetMainView");
+        SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        g_pSetMainView = this;
+    }
+
+    SetMainView::~SetMainView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetMainView::~SetMainView");
+        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
+        InitLabelExt(setLabel, 83, 330, 300, 35, "labletitle", STR_CARD_MANAGEMENT, DEFAULT_VECTOR_FONT_FILENAME, 30);
+        Add(setLabel);
+        //  初始化Button
+        InitButton(setButton, 158, 158, 150, 150, MAIN_CLICK_SETCARD);
+        setButton->SetImageSrc(BUTTONENTER_IMAGE, BUTTONENTER_IMAGE);
+        setButton->SetOnClickListener(static_cast<UIView::OnClickListener *>(MainPresenterSample::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)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetMainView::PreLoad");
+        if (!viewiInitStatus)
+        {
+            InitView();
+            viewiInitStatus = true;
+        }
+    }
+    void SetMainView::UnLoad(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetMainView::UnLoad");
+    }
+    /* -------------------------------------------------------------------------- */
+}