From 29ddd343987624240cc00c3ffe19792ea58fef29 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Wed, 12 Jun 2024 20:24:48 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?utf8?q?=E9=85=8D=E7=BD=AE=E5=8D=A1=E7=89=87=EF=BC=8CUI=E9=9C=80?= =?utf8?q?=E8=A6=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 1 + .../nativelauncher/include/UiConfig.h | 5 +- .../nativeui/main/include/MainViewSample.h | 9 +- .../fd230app/nativeui/main/src/MainModel.cpp | 8 +- .../nativeui/main/src/MainViewSample.cpp | 21 +++- .../set_card/include/SetCardPresenter.h | 14 ++- .../nativeui/set_card/include/SetMainView.h | 51 +++++++++ .../set_card/src/SetCardPresenter.cpp | 4 + .../nativeui/set_card/src/SetMainView.cpp | 101 ++++++++++++++++++ .../set_card/src/SetCardPresenter.cpp | 1 - .../fd230/fs/user/res/users/Enter.bin | 3 + .../fd230/fs/user/res/users/OK.bin | 3 + 12 files changed, 206 insertions(+), 15 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetMainView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/Enter.bin create mode 100644 code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/OK.bin diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index ed13545d8..35b5d6061 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -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 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h index 6f6e05d52..1ef68161c 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/UiConfig.h @@ -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图标 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h index 7ece8f974..85e765acb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainViewSample.h @@ -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 diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp index 0b2beb745..d0a781570 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp @@ -24,8 +24,9 @@ namespace OHOS {WEATHER, PNG_SET_CARD_WEATHER}, {TRAINING, PNG_SET_CARD_TRAIN}, {ACTIVITY, PNG_SET_CARD_ACTIVITY}, + {SETCARD, PNG_SET_CARD_ACTIVITY}, }; - + /*自定义map?*/ const DialInfo dialInfoMap[] = { {DIAL_CLOCK, "KUMI", DEFAULT_DIALPER_PATH, DEFAULT_TASK_PERIOD}, }; @@ -96,6 +97,7 @@ namespace OHOS cardSettings[index++] = COMPASS; cardSettings[index++] = ACTIVITY; cardSettings[index++] = MUSIC_PLAYER; + cardSettings[index++] = SETCARD; // 默认卡片增加设置卡片 cardSettingCount = index; } } @@ -165,7 +167,7 @@ namespace OHOS dialSetting.dialId = DIAL_CLOCK; dialSetting.dialFullName = ""; } - + /*更新表盘设置*/ void MainModel::AddDialSetting(const DialSetting &setting) { std::string tmp; @@ -177,7 +179,7 @@ namespace OHOS tmp += ","; (void)UtilsSetValue("dial_setting", tmp.c_str()); } - + /*加载kvstore里面的dial*/ void MainModel::InitDialSettings(void) { char temp[DIAL_SETTING_VALUE_LEN] = {0}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp index 5590ae764..1073acd65 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -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)) diff --git a/code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetCardPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetCardPresenter.h index c4080fab2..716ee877d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_card/include/SetCardPresenter.h +++ b/code/sdk/application/wearable/fd230app/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 @@ -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, 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 index 000000000..aad257463 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/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 "BaseView.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/fd230app/nativeui/set_card/src/SetCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetCardPresenter.cpp index a76bc3fbe..c36e8580a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetCardPresenter.cpp @@ -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 index 000000000..b5622b798 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/set_card/src/SetMainView.cpp @@ -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 +#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(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 + } + /* -------------------------------------------------------------------------- */ +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp index cefddd031..4c8ce181c 100644 --- a/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/set_card/src/SetCardPresenter.cpp @@ -24,7 +24,6 @@ namespace OHOS { keyActListenr = nullptr; } } - void SetCardPresenter::OnStart() { Presenter::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 index 000000000..99185a813 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/Enter.bin @@ -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 index 000000000..53b7d17d4 --- /dev/null +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/users/OK.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc5b0d633a9631629f6c1521d0c4248901d95418b970085cd6af81d9d5529b9f +size 4504 -- 2.17.1