From: Caisking Date: Tue, 15 Apr 2025 07:01:24 +0000 (+0800) Subject: 【设置卡片】UI X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~378 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=e0f39040e3ba7f9acb8f0855a9da45bc716cfccc;p=mirrors%2FFD230.git 【设置卡片】UI --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardPresenter.h index fb73852ce..716ee877d 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardPresenter.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardPresenter.h @@ -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, 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}; }; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardView.h index 22e95d899..ec161ca2f 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetCardView.h @@ -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 index 000000000..f76e5f8a0 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/include/SetMainView.h @@ -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 +#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 diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp index c916f4c7f..195276e5f 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardDeleteView.cpp @@ -7,8 +7,8 @@ #include "UiConfig.h" #include +#include "cmsis_os.h" #include "SetCardDeleteView.h" -#include "wearable_log.h" namespace OHOS { @@ -36,7 +36,7 @@ bool SetCardDeleteView::InitView() confirmBtn.SetPosition(184, 118); confirmBtn.Resize(86, 50); confirmBtn.SetViewId(SET_CARD_DEL_CONFIRM); - confirmBtn.SetText("删除"); + // confirmBtn.SetText("删除"); confirmBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); confirmBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); confirmBtn.SetOnClickListener(presenter_); @@ -44,7 +44,7 @@ bool SetCardDeleteView::InitView() cancelBtn.SetPosition(186, 231); cancelBtn.Resize(82, 50); cancelBtn.SetViewId(SET_CARD_DEL_CANCEL); - cancelBtn.SetText("取消"); + // cancelBtn.SetText("取消"); cancelBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); cancelBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); cancelBtn.SetOnClickListener(presenter_); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardModel.cpp index 32ca2b547..4f32dbc69 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardModel.cpp @@ -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]; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp index eadcec935..5ea913301 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardNoCardView.cpp @@ -7,8 +7,8 @@ #include "UiConfig.h" #include +#include "cmsis_os.h" #include "SetCardNoCardView.h" -#include "wearable_log.h" namespace OHOS { @@ -34,7 +34,7 @@ bool SetCardNoCardView::InitView() addBtn.SetPosition(184, 118); addBtn.Resize(86, 50); addBtn.SetViewId(SET_CARD_ADD); - addBtn.SetText("添加"); + // addBtn.SetText("添加"); addBtn.SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); addBtn.SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); addBtn.SetOnClickListener(presenter_); diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp index 11d88d816..01dd8b3cd 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp @@ -10,12 +10,10 @@ #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(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(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(HALTick::GetInstance().GetTime()); - + // startTime = osKernelGetTick2ms(); } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardView.cpp index c375c864c..e48b69eed 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetCardView.cpp @@ -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 index 000000000..68f87a55a --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_card/src/SetMainView.cpp @@ -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 +#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(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"); + } + /* -------------------------------------------------------------------------- */ +}