From: Caisking <3449750381@qq.com> Date: Tue, 26 Mar 2024 03:20:49 +0000 (+0800) Subject: 统一训练UI组件初始化接口 X-Git-Tag: release_V1.2.70_20241020_135402~1260 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=9d42d67c52cd88adc2824953b5dd3383971e7a9c;p=mirrors%2FFD230.git 统一训练UI组件初始化接口 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 9648243b7..7713f0d54 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -396,8 +396,8 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingMoreView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingMorePresenter.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingLimitView.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingLimitPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingListLimitView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingListLimitPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingNomalView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingNomalPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingSetView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index e2089189f..979d989c6 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -56,7 +56,7 @@ namespace OHOS void InitTraingSlice(void); void InitTraingMusicSlice(void); void InitTraingMoreSlice(void); - void InitTraingLimitSlice(void); + void InitTraingListLimitSlice(void); void InitTraingNomalSlice(void); void InitTraingSetSlice(void); void InitTraingGPSSetSlice(void); diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index 0038c7d59..dd7b177ec 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -143,8 +143,8 @@ #include "traing/include/TraingPresenter.h" #include "traing/include/TraingMorePresenter.h" #include "traing/include/TraingMoreView.h" -#include "traing/include/TraingLimitPresenter.h" -#include "traing/include/TraingLimitView.h" +#include "traing/include/TraingListLimitPresenter.h" +#include "traing/include/TraingListLimitView.h" #include "traing/include/TraingNomalPresenter.h" #include "traing/include/TraingNomalView.h" #include "traing/include/TraingSetPresenter.h" @@ -261,7 +261,7 @@ namespace OHOS {VIEW_TRAINING, &NativeLauncher::InitTraingSlice}, // 训练 {VIEW_TRAININGMUSIC, &NativeLauncher::InitTraingMusicSlice}, // 训练音乐卡片 {VIEW_TRAININGMORE, &NativeLauncher::InitTraingMoreSlice}, // 更多训练 - {VIEW_TRAININGLIMIT, &NativeLauncher::InitTraingLimitSlice}, // 极限训练 + {VIEW_TRAININGLIMIT, &NativeLauncher::InitTraingListLimitSlice}, // 极限训练 {VIEW_TRAININGNOMAL, &NativeLauncher::InitTraingNomalSlice}, // 正常训练初始界面 {VIEW_TRAININGSET, &NativeLauncher::InitTraingSetSlice}, // 训练目标设置界面 {VIEW_TRAININGGPSSET, &NativeLauncher::InitTraingGPSSetSlice}, // 训练GPS目标设置界面 @@ -865,10 +865,10 @@ namespace OHOS SliceProxy *traingmoreview = new AbilitySliceProxy; NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGMORE, traingmoreview); } - void NativeLauncher::InitTraingLimitSlice(void) + void NativeLauncher::InitTraingListLimitSlice(void) { - SliceProxy *trainglimitview = new AbilitySliceProxy; - NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGLIMIT, trainglimitview); + SliceProxy *TraingListLimitview = new AbilitySliceProxy; + NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGLIMIT, TraingListLimitview); } void NativeLauncher::InitTraingNomalSlice(void) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingCardView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingCardView.h index bdf142e10..31371adf7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingCardView.h @@ -16,8 +16,12 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "components/ui_swipe_view.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingCardPresenter.h" namespace OHOS { @@ -36,9 +40,6 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); void InitList(); void PreLoad(void); @@ -53,9 +54,9 @@ namespace OHOS UISwipeView *swipe_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; bool viewiInitStatus{false}; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlView.h index 3f6f6eb4f..080ff80c5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingControlView.h @@ -16,7 +16,11 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingControlPresenter.h" namespace OHOS { @@ -41,9 +45,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -58,10 +60,10 @@ namespace OHOS UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; UIImageView *image1_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataView.h index c782f9480..307dcb2a6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDataView.h @@ -16,7 +16,11 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingDataPresenter.h" namespace OHOS { @@ -38,9 +42,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -55,11 +57,11 @@ namespace OHOS UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label5_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; + UILabelExt *label5_ = nullptr; UIImageView *image1_ = nullptr; UIImageView *image2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailView.h index 735c9975a..f965c9780 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingDetailView.h @@ -16,7 +16,11 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingDetailPresenter.h" namespace OHOS { @@ -35,9 +39,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -52,14 +54,14 @@ namespace OHOS UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label5_ = nullptr; - UILabel *label6_ = nullptr; - UILabel *label7_ = nullptr; - UILabel *label8_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; + UILabelExt *label5_ = nullptr; + UILabelExt *label6_ = nullptr; + UILabelExt *label7_ = nullptr; + UILabelExt *label8_ = nullptr; UIImageView *image1_ = nullptr; UIImageView *image2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h index 56c9294ba..505bdfbfa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEnddataView.h @@ -16,7 +16,11 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingEnddataPresenter.h" namespace OHOS { @@ -37,10 +41,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); - void InitList(); + void PreLoad(void); // 通过函数改变 @@ -55,25 +56,25 @@ namespace OHOS UIViewGroup *container_ = nullptr; UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label5_ = nullptr; - UILabel *label6_ = nullptr; - UILabel *label7_ = nullptr; - UILabel *label8_ = nullptr; - UILabel *label9_ = nullptr; - UILabel *label10_ = nullptr; - UILabel *label11_ = nullptr; - UILabel *label12_ = nullptr; - UILabel *label13_ = nullptr; - UILabel *label14_ = nullptr; - UILabel *label15_ = nullptr; - UILabel *label16_ = nullptr; - UILabel *label17_ = nullptr; - UILabel *label18_ = nullptr; - UILabel *label19_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; + UILabelExt *label5_ = nullptr; + UILabelExt *label6_ = nullptr; + UILabelExt *label7_ = nullptr; + UILabelExt *label8_ = nullptr; + UILabelExt *label9_ = nullptr; + UILabelExt *label10_ = nullptr; + UILabelExt *label11_ = nullptr; + UILabelExt *label12_ = nullptr; + UILabelExt *label13_ = nullptr; + UILabelExt *label14_ = nullptr; + UILabelExt *label15_ = nullptr; + UILabelExt *label16_ = nullptr; + UILabelExt *label17_ = nullptr; + UILabelExt *label18_ = nullptr; + UILabelExt *label19_ = nullptr; UIButton *button1_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2View.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2View.h index baee7a423..e741a54ea 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2View.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnote2View.h @@ -16,7 +16,11 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingEndnote2Presenter.h" namespace OHOS { @@ -38,10 +42,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); - void InitList(); + void PreLoad(void); // 通过函数改变 @@ -55,8 +56,8 @@ namespace OHOS UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; UIButton *button1_ = nullptr; UIButton *button2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnoteView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnoteView.h index 243b52157..71e68c534 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnoteView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingEndnoteView.h @@ -16,7 +16,11 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingEndnotePresenter.h" namespace OHOS { @@ -38,9 +42,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -55,8 +57,8 @@ namespace OHOS UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; UIButton *button1_ = nullptr; UIButton *button2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSView.h index 4fa461646..843da1446 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingGPSPresenter.h" namespace OHOS @@ -38,9 +40,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -50,10 +50,10 @@ namespace OHOS TraingGPSView &operator=(TraingGPSView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; UIButton *button1_ = nullptr; UIButton *button2_ = nullptr; UIImageView *image1_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSbackView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSbackView.h index cf28aa9a8..a5dfee849 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSbackView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSbackView.h @@ -1,3 +1,11 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-03-19 17:37:18 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-03-26 10:40:11 + * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSbackView.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ #ifndef _TraingGPSback_VIEW_H #define _TraingGPSback_VIEW_H @@ -16,7 +24,11 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingGPSbackPresenter.h" namespace OHOS { @@ -38,9 +50,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -49,8 +59,8 @@ namespace OHOS TraingGPSbackView(TraingGPSbackView &&) = delete; TraingGPSbackView &operator=(TraingGPSbackView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; UIButton *button1_ = nullptr; UIImageView *image1_ = nullptr; bool viewiInitStatus{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSlackView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSlackView.h index c96f41e18..60cf6b39c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSlackView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSlackView.h @@ -16,6 +16,10 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingGPSlackPresenter.h" namespace OHOS @@ -38,9 +42,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -50,10 +52,10 @@ namespace OHOS TraingGPSlackView &operator=(TraingGPSlackView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; UIButton *button1_ = nullptr; UIButton *button2_ = nullptr; UIImageView *image1_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSlostView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSlostView.h index d61e398eb..5d0379718 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSlostView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSlostView.h @@ -16,7 +16,11 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingGPSlostPresenter.h" namespace OHOS { @@ -38,9 +42,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -49,8 +51,8 @@ namespace OHOS TraingGPSlostView(TraingGPSlostView &&) = delete; TraingGPSlostView &operator=(TraingGPSlostView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; UIButton *button1_ = nullptr; UIImageView *image1_ = nullptr; bool viewiInitStatus{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSnoteView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSnoteView.h index 555f4c4ca..5b8c527fd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSnoteView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSnoteView.h @@ -1,3 +1,11 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-03-19 17:37:18 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-03-26 10:32:56 + * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSnoteView.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ #ifndef _TraingGPSnote_VIEW_H #define _TraingGPSnote_VIEW_H @@ -16,6 +24,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingGPSnotePresenter.h" namespace OHOS @@ -38,9 +48,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -52,10 +60,10 @@ namespace OHOS UIViewGroup *container_ = nullptr; UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; UIButton *button1_ = nullptr; UIButton *button2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSsetView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSsetView.h index 550339843..1a95a8d4c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSsetView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingGPSsetView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingGPSsetPresenter.h" namespace OHOS @@ -40,9 +42,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -54,11 +54,11 @@ namespace OHOS UIViewGroup *container_ = nullptr; UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label5_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; + UILabelExt *label5_ = nullptr; UIButton *button1_ = nullptr; UIButton *button2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListAquaticPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListAquaticPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListAquaticView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListAquaticView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListBallPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListBallPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListBallView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListBallView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListDancePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListDancePresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListDanceView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListDanceView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListFitnessPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListFitnessPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListFitnessView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListFitnessView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListIcePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListIcePresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListIceView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListIceView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingLimitPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListLimitPresenter.h similarity index 64% rename from code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingLimitPresenter.h rename to code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListLimitPresenter.h index ef58d0e23..0be424e38 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingLimitPresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListLimitPresenter.h @@ -1,28 +1,28 @@ -#ifndef _TraingLimit_PRESENTER_H -#define _TraingLimit_PRESENTER_H +#ifndef _TraingListLimit_PRESENTER_H +#define _TraingListLimit_PRESENTER_H #include "Presenter.h" -#include "TraingLimitView.h" +#include "TraingListLimitView.h" namespace OHOS { - class TraingLimitView; + class TraingListLimitView; - class TraingLimitPresenter : public Presenter, + class TraingListLimitPresenter : public Presenter, public UIView::OnClickListener, public UIView::OnDragListener { public: - TraingLimitPresenter(); - virtual ~TraingLimitPresenter(); + TraingListLimitPresenter(); + virtual ~TraingListLimitPresenter(); void OnStart() override; void OnPause() override; void OnResume() override; void OnStop() override; - static TraingLimitPresenter *GetInstance(); + static TraingListLimitPresenter *GetInstance(); private: // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingLimitView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListLimitView.h similarity index 69% rename from code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingLimitView.h rename to code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListLimitView.h index 604050d87..ec9ee41f2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingLimitView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListLimitView.h @@ -1,5 +1,5 @@ -#ifndef _TraingLimit_VIEW_H -#define _TraingLimit_VIEW_H +#ifndef _TraingListLimit_VIEW_H +#define _TraingListLimit_VIEW_H #include "BaseView.h" #include "View.h" @@ -16,8 +16,10 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" -#include "TraingLimitPresenter.h" +#include "TraingListLimitPresenter.h" namespace OHOS { #define BUTTON1 "button1" @@ -29,14 +31,14 @@ namespace OHOS #define BUTTON7 "button7" #define BUTTON8 "button8" - class TraingLimitPresenter; - class TraingLimitView : public View + class TraingListLimitPresenter; + class TraingListLimitView : public View { public: - TraingLimitView(); - virtual ~TraingLimitView(); - static TraingLimitView *GetInstance(void); + TraingListLimitView(); + virtual ~TraingListLimitView(); + static TraingListLimitView *GetInstance(void); void OnStart() override; void OnSetUpView() override; @@ -44,20 +46,18 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); private: UIView::OnDragListener *draglistener{nullptr}; - TraingLimitView(TraingLimitView &&) = delete; - TraingLimitView &operator=(TraingLimitView &&) = delete; + TraingListLimitView(TraingListLimitView &&) = delete; + TraingListLimitView &operator=(TraingListLimitView &&) = delete; UIViewGroup *container_ = nullptr; UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; + UILabelExt *label1_ = nullptr; UIImageView *image1_ = nullptr; UIImageView *image2_ = nullptr; UIImageView *image3_ = nullptr; @@ -80,4 +80,4 @@ namespace OHOS bool viewiInitStatus{false}; }; } // namespace OHOS -#endif // TraingLimit_PRESENTER_H +#endif // TraingListLimit_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListOtherPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListOtherPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListOtherView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListOtherView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListRestPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListRestPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListRestView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingListRestView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index 6edc60de5..f96c81004 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -1,3 +1,11 @@ +/*** + * @Author: Caisking 3449750381@qq.com + * @Date: 2024-03-20 15:35:57 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-03-25 18:21:44 + * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ #ifndef Traing_MODEL_H #define Traing_MODEL_H @@ -18,6 +26,9 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" +#include "components/ui_label_ext.h" #include "traing/include/TraingModel.h" #include "traing/Training_UiConfig.h" @@ -51,16 +62,23 @@ namespace OHOS ~TraingModel(); static TraingModel *GetInstance(void); bool InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); + bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); void InitList(); void SetQuickTraining(QuickTraining *quickTraining); QuickTraining *GetQuickTraining() const; + /* ----------------------------------- 定时器 ---------------------------------- */ + void StartTimer(uint32_t interval); + void StopTimer(void); + char *ShowTimer(void); private: TraingModel(const TraingModel &) = delete; TraingModel &operator=(const TraingModel &) = delete; + + std::string trainingTimer; // 训练时长 }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMoreView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMoreView.h index 5e17f88c2..fe97afce9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMoreView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMoreView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingMorePresenter.h" namespace OHOS @@ -44,9 +46,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -57,7 +57,7 @@ namespace OHOS UIViewGroup *container_ = nullptr; UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; + UILabelExt *label1_ = nullptr; UIImageView *image1_ = nullptr; UIImageView *image2_ = nullptr; UIImageView *image3_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicView.h index b256d945f..f0813a6c4 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingMusicView.h @@ -17,6 +17,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "PlayersView.h" #include "TraingMusicPresenter.h" namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h index 0d6ba03fd..f05867b90 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingNomalPresenter.h" namespace OHOS @@ -38,9 +40,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -50,8 +50,8 @@ namespace OHOS TraingNomalView &operator=(TraingNomalView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; UIButton *button1_ = nullptr; UIButton *button2_ = nullptr; bool viewiInitStatus{false}; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetCaluliView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetCaluliView.h index 2b9f128b3..24792f201 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetCaluliView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetCaluliView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "components/ui_picker.h" #include "TraingSetCaluliPresenter.h" @@ -39,9 +41,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId); void InitList(); void PreLoad(void); @@ -52,7 +52,7 @@ namespace OHOS TraingSetCaluliView &operator=(TraingSetCaluliView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; + UILabelExt *label1_ = nullptr; UIButton *button1_ = nullptr; UIPicker *uiPicker1_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetDistView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetDistView.h index 93807d2b9..877915c3d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetDistView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetDistView.h @@ -17,6 +17,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "components/ui_picker.h" #include "TraingSetDistPresenter.h" @@ -40,9 +42,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId); void InitList(); void PreLoad(void); @@ -53,7 +53,7 @@ namespace OHOS TraingSetDistView &operator=(TraingSetDistView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; + UILabelExt *label1_ = nullptr; UIButton *button1_ = nullptr; UIPicker *uiPicker1_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetSeptView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetSeptView.h index a57c92d66..d3651a88c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetSeptView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetSeptView.h @@ -17,6 +17,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "components/ui_picker.h" #include "TraingSetSeptPresenter.h" @@ -40,9 +42,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId); void InitList(); void PreLoad(void); @@ -53,7 +53,7 @@ namespace OHOS TraingSetSeptView &operator=(TraingSetSeptView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; + UILabelExt *label1_ = nullptr; UIButton *button1_ = nullptr; UIPicker *uiPicker1_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetTimeView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetTimeView.h index 2256e9896..79fc62628 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetTimeView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetTimeView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "components/ui_picker.h" #include "TraingSetTimePresenter.h" @@ -39,9 +41,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitUIPicker(UIPicker *&picker, int x, int y, int width, int height, const char *viewId); void InitList(); void PreLoad(void); @@ -52,7 +52,7 @@ namespace OHOS TraingSetTimeView &operator=(TraingSetTimeView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; + UILabelExt *label1_ = nullptr; UIButton *button1_ = nullptr; UIPicker *uiPicker1_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetView.h index a78a94198..a9e6d4d03 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingSetView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingSetPresenter.h" namespace OHOS @@ -38,9 +40,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -51,11 +51,11 @@ namespace OHOS UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label5_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; + UILabelExt *label5_ = nullptr; UIImageView *image1_ = nullptr; UIImageView *image2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingStrongView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingStrongView.h index 8cf7ba91d..db70d9ec2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingStrongView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingStrongView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingStrongPresenter.h" namespace OHOS @@ -38,9 +40,7 @@ namespace OHOS void OnStop() override; void InitView(); void DeInit(); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -56,12 +56,12 @@ namespace OHOS UIViewGroup *container_ = nullptr; UIScrollView *scrollView1_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; - UILabel *label5_ = nullptr; - UILabel *label6_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; + UILabelExt *label5_ = nullptr; + UILabelExt *label6_ = nullptr; UIImageView *image1_ = nullptr; UIImageView *image2_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h index 1fcea8104..9041b93b3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingView.h @@ -53,11 +53,11 @@ namespace OHOS UIButton *button2_ = nullptr; UIButton *button3_ = nullptr; - UILabel *title_label = nullptr; - UILabel *btn1_label = nullptr; - UILabel *btn2_label = nullptr; - UILabel *btn3_label = nullptr; - UILabel *btnmore_label = nullptr; + UILabelExt *title_label = nullptr; + UILabelExt *btn1_label = nullptr; + UILabelExt *btn2_label = nullptr; + UILabelExt *btn3_label = nullptr; + UILabelExt *btnmore_label = nullptr; UIImageView *btn1_image = nullptr; UIImageView *btn2_image = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinView.h index 0fc9d8fda..a42a7b728 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingWinView.h @@ -16,6 +16,8 @@ #include "wearable_log.h" #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingWinPresenter.h" namespace OHOS @@ -39,9 +41,7 @@ namespace OHOS void DeInit(); void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId,int time); - void InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); - void InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); - void InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + void InitList(); void PreLoad(void); @@ -50,10 +50,10 @@ namespace OHOS TraingWinView(TraingWinView &&) = delete; TraingWinView &operator=(TraingWinView &&) = delete; UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; - UILabel *label3_ = nullptr; - UILabel *label4_ = nullptr; + UILabelExt *label1_ = nullptr; + UILabelExt *label2_ = nullptr; + UILabelExt *label3_ = nullptr; + UILabelExt *label4_ = nullptr; UIButton *button1_ = nullptr; UIImageView *image1_ = nullptr; UIImageAnimatorView *imageAnimator; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingCardView.cpp index 422454bac..4f0bddf13 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingCardView.cpp @@ -34,96 +34,7 @@ namespace OHOS return g_pTraingCardView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingCardView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x43, 0xff)); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingCardView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingCardPresenter 的实例 - button->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingCardView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } - + /* InitView:初始化界面*/ void TraingCardView ::InitView() { @@ -135,9 +46,9 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 0, 55, 466, 466, "label1", "训练", DEFAULT_VECTOR_FONT_FILENAME, 200); - InitLabel(label2_, 0, 55, 466, 466, "label2", "暂停", DEFAULT_VECTOR_FONT_FILENAME, 200); - InitLabel(label3_, 0, 55, 466, 466, "label3", "结束", DEFAULT_VECTOR_FONT_FILENAME, 200); + TraingModel::GetInstance()->InitLabelExt(label1_, 0, 55, 466, 466, "label1", "训练", DEFAULT_VECTOR_FONT_FILENAME, 200); + TraingModel::GetInstance()->InitLabelExt(label2_, 0, 55, 466, 466, "label2", "暂停", DEFAULT_VECTOR_FONT_FILENAME, 200); + TraingModel::GetInstance()->InitLabelExt(label3_, 0, 55, 466, 466, "label3", "结束", DEFAULT_VECTOR_FONT_FILENAME, 200); swipe_->Add(label1_); swipe_->Add(label2_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlView.cpp index 1f0fe445d..9dfa98990 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingControlView.cpp @@ -30,94 +30,7 @@ namespace OHOS return g_pTraingControlView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingControlView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingControlView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingControlPresenter 的实例 - button->SetOnClickListener(static_cast(TraingControlPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingControlView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingControlView ::InitView() { @@ -129,27 +42,30 @@ namespace OHOS } // 初始化Button - InitButton(button1_, 100, 202, 100, 100, BUTTONSTOP); + TraingModel::GetInstance()->InitButton(button1_, 100, 202, 100, 100, BUTTONSTOP); // Set additional property button1_->SetImageSrc(SPORT_STOP_IMAGE, nullptr); + // 设置按钮的点击事件监听器为 TraingGPSPresenter 的实例 + button1_->SetOnClickListener(static_cast(TraingControlPresenter::GetInstance())); container_->Add(button1_); - InitButton(button2_, 255, 202, 100, 100, BUTTONPAUSE); + TraingModel::GetInstance()->InitButton(button2_, 255, 202, 100, 100, BUTTONPAUSE); // Set additional property button2_->SetImageSrc(SPORT_PAUSE_IMAGE, nullptr); + button2_->SetOnClickListener(static_cast(TraingControlPresenter::GetInstance())); container_->Add(button2_); // 初始化Lable - InitLabel(label1_, 188, 52, 90, 35, "label1", "训练中", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label2_, 98, 110, 60, 35, "label2", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 65); - InitLabel(label3_, 125, 324, 60, 40, "label3", "结束", DEFAULT_VECTOR_FONT_FILENAME, 20); - InitLabel(label4_, 280, 324, 60, 40, "label4", "暂停", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label1_, 188, 52, 90, 35, "label1", "训练中", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 98, 110, 60, 35, "label2", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 65); + TraingModel::GetInstance()->InitLabelExt(label3_, 125, 324, 60, 40, "label3", "结束", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label4_, 280, 324, 60, 40, "label4", "暂停", DEFAULT_VECTOR_FONT_FILENAME, 20); container_->Add(label1_); container_->Add(label2_); container_->Add(label3_); container_->Add(label4_); // 初始化Image - InitImageView(image1_, 193, 421, 80, 20, "image1", CONTROL_POINT_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 193, 421, 80, 20, "image1", CONTROL_POINT_IMAGE); container_->Add(image1_); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataView.cpp index 87832a024..01cb5fdcf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDataView.cpp @@ -29,94 +29,7 @@ namespace OHOS return g_pTraingDataView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingDataView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingDataView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingDataPresenter 的实例 - button->SetOnClickListener(static_cast(TraingDataPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingDataView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingDataView ::InitView() { @@ -128,31 +41,32 @@ namespace OHOS } // 初始化Image - InitImageView(image1_, 13, 13, 440, 386, "image1", PROGRESS_IMAGE); - InitImageView(image2_, 208, 297, 20, 20, "image2", ARROWS_IMAGE); - InitImageView(image3_, 98, 314, 270, 20, "image3", SPORT_STRENGTH_IMAGE); - InitImageView(image4_, 225, 396, 16, 10, "image4", INCO_UP_IMAGE); - InitImageView(image5_, 193, 421, 80, 20, "image5", DATA_POINT_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 13, 13, 440, 386, "image1", PROGRESS_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 208, 297, 20, 20, "image2", ARROWS_IMAGE); + TraingModel::GetInstance()->InitImageView(image3_, 98, 314, 270, 20, "image3", SPORT_STRENGTH_IMAGE); + TraingModel::GetInstance()->InitImageView(image4_, 225, 396, 16, 10, "image4", INCO_UP_IMAGE); + TraingModel::GetInstance()->InitImageView(image5_, 193, 421, 80, 20, "image5", DATA_POINT_IMAGE); container_->Add(image1_); container_->Add(image2_); container_->Add(image3_); container_->Add(image4_); container_->Add(image5_); // 初始化Lable - InitLabel(label1_, 185, 60, 90, 35, "label1", "23:54", DEFAULT_VECTOR_FONT_FILENAME, 40); - InitLabel(label2_, 158, 120, 150, 35, "label2", "跳绳运动中", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label3_, 90, 175, 60, 40, "label3", "00:31:26", DEFAULT_VECTOR_FONT_FILENAME, 80); - InitLabel(label4_, 150, 276, 60, 40, "label4", "144", DEFAULT_VECTOR_FONT_FILENAME, 23); - InitLabel(label5_, 167, 350, 60, 40, "label4", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label1_, 185, 60, 90, 35, "label1", "23:54", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label2_, 158, 120, 150, 35, "label2", "跳绳运动中", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label3_, 90, 175, 60, 40, "label3", "00:31:26", DEFAULT_VECTOR_FONT_FILENAME, 80); + TraingModel::GetInstance()->InitLabelExt(label4_, 150, 276, 60, 40, "label4", "144", DEFAULT_VECTOR_FONT_FILENAME, 23); + TraingModel::GetInstance()->InitLabelExt(label5_, 167, 350, 60, 40, "label4", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 26); container_->Add(label1_); container_->Add(label2_); container_->Add(label3_); container_->Add(label4_); container_->Add(label5_); // 初始化Button - InitButton(button1_, 275, 350, 26, 26, BUTTONNOTE); + TraingModel::GetInstance()->InitButton(button1_, 275, 350, 26, 26, BUTTONNOTE); // Set additional property button1_->SetImageSrc(NOTE_IMAGE, nullptr); + button1_->SetOnClickListener(static_cast(TraingDataPresenter::GetInstance())); container_->Add(button1_); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailView.cpp index 306679e2e..4932ae601 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingDetailView.cpp @@ -11,12 +11,8 @@ namespace OHOS { - static const char *imagePath_heartrate = "/user/res/Training/heartrat_30.bin"; - static const char *imagePath_mileage = "/user/res/Training/mileage_30.bin"; - static const char *imagePath_step = "/user/res/Training/step_30.bin"; - static const char *imagePath_calories = "/user/res/Training/calories_30.bin"; - static const char *imagePath_line1 = "/user/res/Training/Line 1.bin"; - static const char *imagePath_line2 = "/user/res/Training/Line 2.bin"; + + static TraingDetailView *g_pTraingDetailView{nullptr}; @@ -36,94 +32,7 @@ namespace OHOS return g_pTraingDetailView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingDetailView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingDetailView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingDetailPresenter 的实例 - button->SetOnClickListener(static_cast(TraingDetailPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingDetailView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingDetailView ::InitView() { @@ -135,13 +44,13 @@ namespace OHOS } // 初始化Image - InitImageView(image1_, 134, 58, 30, 30, "image1", HEARTRATE_30_IMAGE); - InitImageView(image2_, 44, 189, 30, 30, "image2", MILEAGE_30_IMAGE); - InitImageView(image3_, 297, 189, 30, 30, "image3", STEP_30_IMAGE); - InitImageView(image4_, 129, 335, 30, 30, "image4", CALORIES_30_IMAGE); - InitImageView(image5_, 0, 160, 10, 466, "image5", LINE_1_IMAGE); - InitImageView(image6_, 233, 193, 80, 20, "image5", LINE_2_IMAGE); - InitImageView(image7_, 0, 306, 10, 466, "image5", LINE_1_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 134, 58, 30, 30, "image1", HEARTRATE_30_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 44, 189, 30, 30, "image2", MILEAGE_30_IMAGE); + TraingModel::GetInstance()->InitImageView(image3_, 297, 189, 30, 30, "image3", STEP_30_IMAGE); + TraingModel::GetInstance()->InitImageView(image4_, 129, 335, 30, 30, "image4", CALORIES_30_IMAGE); + TraingModel::GetInstance()->InitImageView(image5_, 0, 160, 10, 466, "image5", LINE_1_IMAGE); + TraingModel::GetInstance()->InitImageView(image6_, 233, 193, 80, 20, "image5", LINE_2_IMAGE); + TraingModel::GetInstance()->InitImageView(image7_, 0, 306, 10, 466, "image5", LINE_1_IMAGE); container_->Add(image1_); container_->Add(image2_); container_->Add(image3_); @@ -150,14 +59,14 @@ namespace OHOS container_->Add(image6_); container_->Add(image7_); // 初始化Lable - InitLabel(label1_, 174, 60, 90, 35, "label1", "心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label2_, 80, 190, 60, 40, "label2", "距离(公里)", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label3_, 332, 189, 60, 40, "label3", "步数", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label4_, 167, 336, 60, 40, "label4", "卡路里(千卡)", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label5_, 202, 94, 60, 40, "label5", "144", DEFAULT_VECTOR_FONT_FILENAME, 40); - InitLabel(label6_, 76, 233, 60, 40, "label6", "13.21", DEFAULT_VECTOR_FONT_FILENAME, 40); - InitLabel(label7_, 300, 233, 60, 40, "label7", "28312", DEFAULT_VECTOR_FONT_FILENAME, 40); - InitLabel(label8_, 175, 376, 60, 40, "label8", "210.03", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label1_, 174, 60, 90, 35, "label1", "心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label2_, 80, 190, 60, 40, "label2", "距离(公里)", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label3_, 332, 189, 60, 40, "label3", "步数", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label4_, 167, 336, 60, 40, "label4", "卡路里(千卡)", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label5_, 202, 94, 60, 40, "label5", "144", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label6_, 76, 233, 60, 40, "label6", "13.21", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label7_, 300, 233, 60, 40, "label7", "28312", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label8_, 175, 376, 60, 40, "label8", "210.03", DEFAULT_VECTOR_FONT_FILENAME, 40); container_->Add(label1_); container_->Add(label2_); container_->Add(label3_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp index 19496b139..b4366e081 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEnddataView.cpp @@ -31,95 +31,6 @@ namespace OHOS return g_pTraingEnddataView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingEnddataView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetTextColor(Color::GetColorFromRGBA(0x22, 0x9d, 0xd3, 0xff)); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingEnddataView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingEnddataPresenter 的实例 - button->SetOnClickListener(static_cast(TraingEnddataPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingEnddataView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } /* InitView:初始化界面*/ void TraingEnddataView ::InitView() { @@ -146,16 +57,16 @@ namespace OHOS scrollView1_->SetVisible(true); // 初始化Image - InitImageView(image1_, 200, 131, 80, 48, "image1", BUBBLE_IMAGE); - InitImageView(image2_, 230, 183, 20, 20, "image2", PIONT_BUBBLE_IMAGE); - InitImageView(image3_, 96, 118, 271, 233, "image3", PATH_IMAGE); - InitImageView(image4_, 212, 402, 40, 40, "image4", INCO_UP_40_IMAGE); - InitImageView(image5_, 80, 470, 54, 80, "image5", WALKING_54_IMAGE); - InitImageView(image6_, 97, 552, 80, 20, "image6", LINE_IMAGE); - InitImageView(image8_, 97, 682, 80, 20, "image6", LINE_IMAGE); - InitImageView(image9_, 97, 812, 80, 20, "image6", LINE_IMAGE); - InitImageView(image10_, 97, 942, 80, 20, "image6", LINE_IMAGE); - InitImageView(image11_, 97, 1072, 80, 20, "image6", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 200, 131, 80, 48, "image1", BUBBLE_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 230, 183, 20, 20, "image2", PIONT_BUBBLE_IMAGE); + TraingModel::GetInstance()->InitImageView(image3_, 96, 118, 271, 233, "image3", PATH_IMAGE); + TraingModel::GetInstance()->InitImageView(image4_, 212, 402, 40, 40, "image4", INCO_UP_40_IMAGE); + TraingModel::GetInstance()->InitImageView(image5_, 80, 470, 54, 80, "image5", WALKING_54_IMAGE); + TraingModel::GetInstance()->InitImageView(image6_, 97, 552, 80, 20, "image6", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image8_, 97, 682, 80, 20, "image6", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image9_, 97, 812, 80, 20, "image6", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image10_, 97, 942, 80, 20, "image6", LINE_IMAGE); + TraingModel::GetInstance()->InitImageView(image11_, 97, 1072, 80, 20, "image6", LINE_IMAGE); scrollView1_->Add(image3_); scrollView1_->Add(image6_); @@ -169,24 +80,25 @@ namespace OHOS scrollView1_->Add(image5_); // 初始化button - InitButton(button1_, 42, 1319, 380, 100, BUTTONBACK); + TraingModel::GetInstance()->InitButton(button1_, 42, 1319, 380, 100, BUTTONBACK); + button1_->SetOnClickListener(static_cast(TraingEnddataPresenter::GetInstance())); scrollView1_->Add(button1_); // 初始化Lable - InitLabel(label1_, 188, 52, 90, 35, "label1", "健身类", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label2_, 220, 140, 60, 40, "label2", "达标", DEFAULT_VECTOR_FONT_FILENAME, 20); - InitLabel(label3_, 114, 252, 60, 40, "label3", "终", DEFAULT_VECTOR_FONT_FILENAME, 20); - InitLabel(label4_, 172, 284, 60, 40, "label4", "èµ·", DEFAULT_VECTOR_FONT_FILENAME, 20); - InitLabel(label5_, 155, 372, 60, 40, "label5", "距离:8.3KM", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label6_, 146, 478, 60, 40, "label6", "健走", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label7_, 146, 517, 60, 40, "label7", "13:00:22-15:00:12", DEFAULT_VECTOR_FONT_FILENAME, 28); - - InitLabel(label8_, 146, 590, 60, 40, "label8", "目标完成度", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label9_, 146, 720, 60, 40, "label9", "训练时长", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label10_, 146, 850, 60, 40, "label10", "距离(ç±³)", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label11_, 146, 980, 60, 40, "label11", "平均心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label12_, 146, 1110, 60, 40, "label2", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label18_, 155, 1232, 60, 40, "label8", "更多数据请前往手机\nAPP“小希爱玩”查看", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label1_, 188, 52, 90, 35, "label1", "健身类", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 220, 140, 60, 40, "label2", "达标", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label3_, 114, 252, 60, 40, "label3", "终", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label4_, 172, 284, 60, 40, "label4", "èµ·", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label5_, 155, 372, 60, 40, "label5", "距离:8.3KM", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label6_, 146, 478, 60, 40, "label6", "健走", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label7_, 146, 517, 60, 40, "label7", "13:00:22-15:00:12", DEFAULT_VECTOR_FONT_FILENAME, 28); + + TraingModel::GetInstance()->InitLabelExt(label8_, 146, 590, 60, 40, "label8", "目标完成度", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label9_, 146, 720, 60, 40, "label9", "训练时长", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label10_, 146, 850, 60, 40, "label10", "距离(ç±³)", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label11_, 146, 980, 60, 40, "label11", "平均心率(次/分)", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label12_, 146, 1110, 60, 40, "label2", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label18_, 155, 1232, 60, 40, "label8", "更多数据请前往手机\nAPP“小希爱玩”查看", DEFAULT_VECTOR_FONT_FILENAME, 26); label7_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); label8_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); @@ -196,17 +108,17 @@ namespace OHOS label12_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); label18_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); - InitLabel(label13_, 146, 626, 60, 40, "label18", "226%", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label13_, 146, 626, 60, 40, "label18", "226%", DEFAULT_VECTOR_FONT_FILENAME, 40); label13_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); - InitLabel(label14_, 146, 756, 60, 40, "label14", "05:45:46", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label14_, 146, 756, 60, 40, "label14", "05:45:46", DEFAULT_VECTOR_FONT_FILENAME, 40); label14_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); - InitLabel(label15_, 146, 886, 60, 40, "label15", "8,301", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label15_, 146, 886, 60, 40, "label15", "8,301", DEFAULT_VECTOR_FONT_FILENAME, 40); label15_->SetTextColor(Color::GetColorFromRGBA(0x36, 0x4a, 0xff, 0xff)); - InitLabel(label16_, 146, 1016, 60, 40, "label16", "144", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label16_, 146, 1016, 60, 40, "label16", "144", DEFAULT_VECTOR_FONT_FILENAME, 40); label16_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); - InitLabel(label17_, 146, 1146, 60, 40, "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 40); + TraingModel::GetInstance()->InitLabelExt(label17_, 146, 1146, 60, 40, "label17", "中等强度", DEFAULT_VECTOR_FONT_FILENAME, 40); label17_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff)); - InitLabel(label19_, 201, 1348, 60, 40, "label19", "关闭", DEFAULT_VECTOR_FONT_FILENAME, 31); + TraingModel::GetInstance()->InitLabelExt(label19_, 201, 1348, 60, 40, "label19", "关闭", DEFAULT_VECTOR_FONT_FILENAME, 31); scrollView1_->Add(label1_); scrollView1_->Add(label2_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2View.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2View.cpp index 6d2569217..47283cb64 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2View.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnote2View.cpp @@ -30,94 +30,7 @@ namespace OHOS return g_pTraingEndnote2View; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingEndnote2View::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingEndnote2View::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingEndnote2Presenter 的实例 - button->SetOnClickListener(static_cast(TraingEndnote2Presenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingEndnote2View::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingEndnote2View ::InitView() { @@ -129,17 +42,19 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 203, 52, 90, 35, "label1", "注意", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label2_, 56, 167, 60, 40, "label2", "当前运动量太小,无法记录\n是否结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 203, 52, 90, 35, "label1", "注意", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 56, 167, 60, 40, "label2", "当前运动量太小,无法记录\n是否结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label1_); container_->Add(label2_); - InitButton(button1_, 111, 299, 100, 100, BUTTONNO); + TraingModel::GetInstance()->InitButton(button1_, 111, 299, 100, 100, BUTTONNO); + button1_->SetOnClickListener(static_cast(TraingEndnote2Presenter::GetInstance())); // Set additional property button1_->SetImageSrc(NO_IMAGE, nullptr); - InitButton(button2_, 256, 299, 100, 100, BUTTONYES); + TraingModel::GetInstance()->InitButton(button2_, 256, 299, 100, 100, BUTTONYES); + button2_->SetOnClickListener(static_cast(TraingEndnote2Presenter::GetInstance())); // Set additional property button2_->SetImageSrc(YES_IMAGE, nullptr); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnoteView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnoteView.cpp index 44e93a6e3..bcd8051fb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnoteView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingEndnoteView.cpp @@ -11,8 +11,6 @@ namespace OHOS { - static const char *imagePath_no = "/user/res/Training/no.bin"; - static const char *imagePath_yes = "/user/res/Training/yes.bin"; static TraingEndnoteView *g_pTraingEndnoteView{nullptr}; @@ -32,94 +30,7 @@ namespace OHOS return g_pTraingEndnoteView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingEndnoteView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingEndnoteView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingEndnotePresenter 的实例 - button->SetOnClickListener(static_cast(TraingEndnotePresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingEndnoteView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingEndnoteView ::InitView() { @@ -131,17 +42,19 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 173, 52, 90, 35, "label1", "结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label2_, 116, 187, 60, 40, "label2", "是否结束本次运动", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label1_, 173, 52, 90, 35, "label1", "结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 116, 187, 60, 40, "label2", "是否结束本次运动", DEFAULT_VECTOR_FONT_FILENAME, 26); container_->Add(label1_); container_->Add(label2_); - InitButton(button1_, 111, 299, 100, 100, BUTTONNO); + TraingModel::GetInstance()->InitButton(button1_, 111, 299, 100, 100, BUTTONNO); + button1_->SetOnClickListener(static_cast(TraingEndnotePresenter::GetInstance())); // Set additional property button1_->SetImageSrc(NO_IMAGE, nullptr); - InitButton(button2_, 256, 299, 100, 100, BUTTONYES); + TraingModel::GetInstance()->InitButton(button2_, 256, 299, 100, 100, BUTTONYES); + button2_->SetOnClickListener(static_cast(TraingEndnotePresenter::GetInstance())); // Set additional property button2_->SetImageSrc(YES_IMAGE, nullptr); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSView.cpp index 5b05f353d..ce66f8030 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSView.cpp @@ -29,95 +29,7 @@ namespace OHOS return g_pTraingGPSView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingGPSView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingGPSView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingGPSPresenter 的实例 - button->SetOnClickListener(static_cast(TraingGPSPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingGPSView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } - + /* InitView:初始化界面*/ void TraingGPSView ::InitView() { @@ -129,25 +41,25 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 203, 52, 195, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 203, 52, 195, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label1_); - InitLabel(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label2_); - InitLabel(label3_, 41, 237, 54, 41, "lable3", "144", DEFAULT_VECTOR_FONT_FILENAME, 35); + TraingModel::GetInstance()->InitLabelExt(label3_, 41, 237, 54, 41, "lable3", "144", DEFAULT_VECTOR_FONT_FILENAME, 35); container_->Add(label3_); - InitLabel(label4_, 361, 237, 54, 41, "lable4", "GPS", DEFAULT_VECTOR_FONT_FILENAME, 35); + TraingModel::GetInstance()->InitLabelExt(label4_, 361, 237, 54, 41, "lable4", "GPS", DEFAULT_VECTOR_FONT_FILENAME, 35); container_->Add(label4_); // 初始化image - InitImageView(image1_, 48, 193, 40, 40, "image1", HEARTRATE_1_IMAGE); - InitImageView(image2_, 375, 193, 40, 40, "image2", GPS_1_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 48, 193, 40, 40, "image1", HEARTRATE_1_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 375, 193, 40, 40, "image2", GPS_1_IMAGE); container_->Add(image1_); container_->Add(image2_); // 初始化Button - InitButton(button1_, 133, 133, 200, 200, BUTTONGO); + TraingModel::GetInstance()->InitButton(button1_, 133, 133, 200, 200, BUTTONGO); button1_->SetImageSrc(GO_1_IMAGE, nullptr); - InitButton(button2_, 160, 370, 146, 35, BUTTONSET); + TraingModel::GetInstance()->InitButton(button2_, 160, 370, 146, 35, BUTTONSET); button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); // 设置为透明按键 button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x80, UIButton::PRESSED); // 设置按下时的透明度为半透明 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSbackView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSbackView.cpp index 4fc174464..8a68bb8ce 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSbackView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSbackView.cpp @@ -28,94 +28,6 @@ namespace OHOS return g_pTraingGPSbackView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingGPSbackView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingGPSbackView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingGPSbackPresenter 的实例 - button->SetOnClickListener(static_cast(TraingGPSbackPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingGPSbackView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } /* InitView:初始化界面*/ void TraingGPSbackView ::InitView() @@ -128,23 +40,21 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 175, 52, 195, 35, "label1", "GPS连接", DEFAULT_VECTOR_FONT_FILENAME, 35); + TraingModel::GetInstance()->InitLabelExt(label1_, 175, 52, 195, 35, "label1", "GPS连接", DEFAULT_VECTOR_FONT_FILENAME, 35); container_->Add(label1_); - InitLabel(label2_, 55, 253, 146, 35, "label2", "GPS已连接,当前信号正常", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 55, 253, 146, 35, "label2", "GPS已连接,当前信号正常", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label2_); - + // 初始化image - InitImageView(image1_, 193, 140, 40, 40, "image1", BACK_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 193, 140, 40, 40, "image1", BACK_IMAGE); container_->Add(image1_); // 初始化Button - InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + TraingModel::GetInstance()->InitButton(button1_, 0, 366, 466, 100, BUTTONOK); // Set additional property - char *button1defaultImgSrc = "/user/res/Training/buttonok.bin"; - char *button1triggeredImgSrc = nullptr; - button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + button1_->SetOnClickListener(static_cast(TraingGPSbackPresenter::GetInstance())); + button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr); container_->Add(button1_); - } /* DeInit:删除组件*/ void TraingGPSbackView::DeInit() diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSlackView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSlackView.cpp index f3b40e9ca..3fc512c69 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSlackView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSlackView.cpp @@ -30,95 +30,7 @@ namespace OHOS return g_pTraingGPSlackView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingGPSlackView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingGPSlackView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingGPSlackPresenter 的实例 - button->SetOnClickListener(static_cast(TraingGPSlackPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingGPSlackView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } - + /* InitView:初始化界面*/ void TraingGPSlackView ::InitView() { @@ -130,27 +42,27 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 203, 52, 195, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 203, 52, 195, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label1_); - InitLabel(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label2_); - InitLabel(label3_, 41, 237, 54, 41, "lable3", "--", DEFAULT_VECTOR_FONT_FILENAME, 35); + TraingModel::GetInstance()->InitLabelExt(label3_, 41, 237, 54, 41, "lable3", "--", DEFAULT_VECTOR_FONT_FILENAME, 35); container_->Add(label3_); - InitLabel(label4_, 361, 237, 54, 41, "lable4", "--", DEFAULT_VECTOR_FONT_FILENAME, 35); + TraingModel::GetInstance()->InitLabelExt(label4_, 361, 237, 54, 41, "lable4", "--", DEFAULT_VECTOR_FONT_FILENAME, 35); container_->Add(label4_); // 初始化image - InitImageView(image1_, 48, 193, 40, 40, "image1", HEARTRATE_2_IMAGE); - InitImageView(image2_, 375, 193, 40, 40, "image2", GPS_2_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 48, 193, 40, 40, "image1", HEARTRATE_2_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 375, 193, 40, 40, "image2", GPS_2_IMAGE); container_->Add(image1_); container_->Add(image2_); // 初始化Button - InitButton(button1_, 133, 133, 200, 200, BUTTONGO); + TraingModel::GetInstance()->InitButton(button1_, 133, 133, 200, 200, BUTTONGO); // Set additional property char *button1defaultImgSrc = "/user/res/Training/Go_2.bin"; char *button1triggeredImgSrc = nullptr; button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); - InitButton(button2_, 160, 370, 146, 35, BUTTONSET); + TraingModel::GetInstance()->InitButton(button2_, 160, 370, 146, 35, BUTTONSET); button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); // 设置为透明按键 button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x80, UIButton::PRESSED); // 设置按下时的透明度为半透明 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSlostView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSlostView.cpp index 76c8d1331..e1f63b622 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSlostView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSlostView.cpp @@ -29,94 +29,7 @@ namespace OHOS return g_pTraingGPSlostView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingGPSlostView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingGPSlostView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingGPSlostPresenter 的实例 - button->SetOnClickListener(static_cast(TraingGPSlostPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingGPSlostView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingGPSlostView ::InitView() @@ -129,17 +42,17 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 175, 52, 195, 35, "label1", "GPS丢失", DEFAULT_VECTOR_FONT_FILENAME, 35); + TraingModel::GetInstance()->InitLabelExt(label1_, 175, 52, 195, 35, "label1", "GPS丢失", DEFAULT_VECTOR_FONT_FILENAME, 35); container_->Add(label1_); - InitLabel(label2_, 55, 253, 146, 35, "label2", "当前位置搜索不到GPS信号", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 55, 253, 146, 35, "label2", "当前位置搜索不到GPS信号", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label2_); // 初始化image - InitImageView(image1_, 193, 140, 40, 40, "image1", WARNING_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 193, 140, 40, 40, "image1", WARNING_IMAGE); container_->Add(image1_); // 初始化Button - InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + TraingModel::GetInstance()->InitButton(button1_, 0, 366, 466, 100, BUTTONOK); // Set additional property button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr); container_->Add(button1_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSnoteView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSnoteView.cpp index b50ef5243..738773db5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSnoteView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSnoteView.cpp @@ -31,95 +31,7 @@ namespace OHOS return g_pTraingGPSnoteView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingGPSnoteView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetTextColor(Color::GetColorFromRGBA(0x22, 0x9d, 0xd3, 0xff)); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingGPSnoteView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingGPSnotePresenter 的实例 - button->SetOnClickListener(static_cast(TraingGPSnotePresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingGPSnoteView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingGPSnoteView ::InitView() { @@ -146,22 +58,22 @@ namespace OHOS scrollView1_->SetVisible(true); // 初始化Image - InitImageView(image1_, 193, 111, 80, 80, "image1", WARNING_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 193, 111, 80, 80, "image1", WARNING_IMAGE); scrollView1_->Add(image1_); // 初始化button - InitButton(button1_, 118, 334, 230, 80, BUTTONBACK); + TraingModel::GetInstance()->InitButton(button1_, 118, 334, 230, 80, BUTTONBACK); button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); scrollView1_->Add(button1_); - InitButton(button2_, 118, 434, 230, 80, BUTTONGO); + TraingModel::GetInstance()->InitButton(button2_, 118, 434, 230, 80, BUTTONGO); scrollView1_->Add(button2_); // 初始化Lable - InitLabel(label1_, 160, 52, 90, 35, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label2_, 33, 215, 60, 40, "label2", "GPS仍在定位,建议等待定位\n完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label3_, 181, 357, 60, 40, "label3", "继续等待", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label4_, 181, 457, 60, 40, "label4", "直接开始", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 160, 52, 90, 35, "label1", "GPS未准备", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 33, 215, 60, 40, "label2", "GPS仍在定位,建议等待定位\n完成后再开始训练", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label3_, 181, 357, 60, 40, "label3", "继续等待", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label4_, 181, 457, 60, 40, "label4", "直接开始", DEFAULT_VECTOR_FONT_FILENAME, 30); scrollView1_->Add(label1_); scrollView1_->Add(label2_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSsetView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSsetView.cpp index b1f85d85a..ef7c85958 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSsetView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingGPSsetView.cpp @@ -33,94 +33,7 @@ namespace OHOS return g_pTraingGPSsetView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingGPSsetView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingGPSsetView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingGPSsetPresenter 的实例 - button->SetOnClickListener(static_cast(TraingGPSsetPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingGPSsetView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* Traing:初始化list */ void TraingGPSsetView::InitList() { @@ -199,31 +112,31 @@ namespace OHOS scrollView1_->SetVisible(true); // 初始化Button - InitButton(button1_, 43, 120, 380, 100, BUTTONTIME); - InitButton(button2_, 43, 240, 380, 100, BUTTONMIL); - InitButton(button3_, 43, 360, 380, 100, BUTTONCALULI); - InitButton(button4_, 43, 480, 380, 100, BUTTONWALK); + TraingModel::GetInstance()->InitButton(button1_, 43, 120, 380, 100, BUTTONTIME); + TraingModel::GetInstance()->InitButton(button2_, 43, 240, 380, 100, BUTTONMIL); + TraingModel::GetInstance()->InitButton(button3_, 43, 360, 380, 100, BUTTONCALULI); + TraingModel::GetInstance()->InitButton(button4_, 43, 480, 380, 100, BUTTONWALK); scrollView1_->Add(button1_); scrollView1_->Add(button2_); scrollView1_->Add(button3_); scrollView1_->Add(button4_); // 初始化Image - InitImageView(image1_, 380, 160, 100, 100, "image1", ICON_IMAGE); - InitImageView(image2_, 380, 280, 100, 100, "image2", ICON_IMAGE); - InitImageView(image3_, 380, 400, 100, 100, "image3", ICON_IMAGE); - InitImageView(image4_, 380, 520, 100, 100, "image4", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 380, 160, 100, 100, "image1", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 380, 280, 100, 100, "image2", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image3_, 380, 400, 100, 100, "image3", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image4_, 380, 520, 100, 100, "image4", ICON_IMAGE); scrollView1_->Add(image1_); scrollView1_->Add(image2_); scrollView1_->Add(image3_); scrollView1_->Add(image4_); // 初始化Lable - InitLabel(label1_, 203, 52, 120, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label2_, 300, 160, 60, 35, "label2", "30 分钟", DEFAULT_VECTOR_FONT_FILENAME, 20); - InitLabel(label3_, 300, 280, 69, 23, "label3", "5 公里", DEFAULT_VECTOR_FONT_FILENAME, 20); - InitLabel(label4_, 300, 400, 60, 35, "label4", "500 千卡", DEFAULT_VECTOR_FONT_FILENAME, 20); - InitLabel(label5_, 300, 520, 60, 35, "label5", "2000 æ­¥", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label1_, 203, 52, 120, 35, "label1", "骑行", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 300, 160, 60, 35, "label2", "30 分钟", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label3_, 300, 280, 69, 23, "label3", "5 公里", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label4_, 300, 400, 60, 35, "label4", "500 千卡", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label5_, 300, 520, 60, 35, "label5", "2000 æ­¥", DEFAULT_VECTOR_FONT_FILENAME, 20); scrollView1_->Add(label1_); scrollView1_->Add(label2_); scrollView1_->Add(label3_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListAquaticPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListAquaticPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListAquaticView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListAquaticView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListBallPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListBallPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListBallView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListBallView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListDancePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListDancePresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListDanceView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListDanceView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListFitnessPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListFitnessPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListFitnessView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListFitnessView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListIcePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListIcePresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListIceView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListIceView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingLimitPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListLimitPresenter.cpp similarity index 63% rename from code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingLimitPresenter.cpp rename to code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListLimitPresenter.cpp index ea9e62540..cc7f125f3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingLimitPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListLimitPresenter.cpp @@ -3,7 +3,7 @@ * @Date: 2024-03-19 17:37:19 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-03-22 15:20:33 - * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/src/TraingLimitPresenter.cpp + * @FilePath: /sdk/application/wearable/fd230app/nativeui/traing/src/TraingListLimitPresenter.cpp * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ #include "AppViewIDs.h" @@ -12,61 +12,61 @@ #include #include #include -#include "traing/include/TraingLimitPresenter.h" -// #include "TraingLimitView.h" +#include "traing/include/TraingListLimitPresenter.h" +// #include "TraingListLimitView.h" namespace OHOS { // 当前Presenter属性实例化的内存指针 - static TraingLimitPresenter *g_pTraingLimitPresenter = nullptr; + static TraingListLimitPresenter *g_pTraingListLimitPresenter = nullptr; - TraingLimitPresenter::TraingLimitPresenter() + TraingListLimitPresenter::TraingListLimitPresenter() { - g_pTraingLimitPresenter = this; + g_pTraingListLimitPresenter = this; } - TraingLimitPresenter::~TraingLimitPresenter() + TraingListLimitPresenter::~TraingListLimitPresenter() { - g_pTraingLimitPresenter = nullptr; + g_pTraingListLimitPresenter = nullptr; } - TraingLimitPresenter *TraingLimitPresenter::GetInstance() + TraingListLimitPresenter *TraingListLimitPresenter::GetInstance() { - return g_pTraingLimitPresenter; + return g_pTraingListLimitPresenter; } - void TraingLimitPresenter::OnStart() + void TraingListLimitPresenter::OnStart() { - Presenter::OnStart(); + Presenter::OnStart(); } - void TraingLimitPresenter::OnPause(void) + void TraingListLimitPresenter::OnPause(void) { - Presenter::OnPause(); + Presenter::OnPause(); } - void TraingLimitPresenter::OnResume(void) + void TraingListLimitPresenter::OnResume(void) { - Presenter::OnResume(); + Presenter::OnResume(); } - void TraingLimitPresenter::OnStop(void) + void TraingListLimitPresenter::OnStop(void) { - Presenter::OnStop(); + Presenter::OnStop(); } - bool TraingLimitPresenter::OnDrag(UIView &view, const DragEvent &event) + bool TraingListLimitPresenter::OnDrag(UIView &view, const DragEvent &event) { return true; } - bool TraingLimitPresenter::OnDragEnd(UIView &view, const DragEvent &event) + bool TraingListLimitPresenter::OnDragEnd(UIView &view, const DragEvent &event) { if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) @@ -77,7 +77,7 @@ namespace OHOS return true; } - bool TraingLimitPresenter::OnClick(UIView &view, const ClickEvent &event) + bool TraingListLimitPresenter::OnClick(UIView &view, const ClickEvent &event) { // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), BUTTON1) == 0) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingLimitView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListLimitView.cpp similarity index 53% rename from code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingLimitView.cpp rename to code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListLimitView.cpp index a45e392ef..dd1e9de76 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingLimitView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListLimitView.cpp @@ -1,5 +1,5 @@ -#include "traing/include/TraingLimitView.h" +#include "traing/include/TraingListLimitView.h" #include "common/image_cache_manager.h" #include "UiConfig.h" @@ -12,118 +12,29 @@ namespace OHOS { - static char *text[] = {"一般极限运动", "滑板", "高空弹跳/蹦极", "跑酷", "BMX", "定向越野", "跳伞", "铁人三项运动"}; + static char *text[] = {"一般极限运动", "滑板", "攀岩", "高空弹跳/蹦极", "跑酷", "BMX", "定向越野", "跳伞", "赛车", "铁人三项运动"}; - static TraingLimitView *g_pTraingLimitView{nullptr}; + static TraingListLimitView *g_pTraingListLimitView{nullptr}; - TraingLimitView::TraingLimitView() + TraingListLimitView::TraingListLimitView() { - g_pTraingLimitView = this; + g_pTraingListLimitView = this; } - TraingLimitView::~TraingLimitView() + TraingListLimitView::~TraingListLimitView() { DeInit(); - g_pTraingLimitView = nullptr; + g_pTraingListLimitView = nullptr; } - TraingLimitView *TraingLimitView::GetInstance() + TraingListLimitView *TraingListLimitView::GetInstance() { - return g_pTraingLimitView; - } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingLimitView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingLimitView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingLimitPresenter 的实例 - button->SetOnClickListener(static_cast(TraingLimitPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingLimitView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); + return g_pTraingListLimitView; } /* Traing:初始化list */ - void TraingLimitView::InitList() + void TraingListLimitView::InitList() { // Add List to App if (list1_ == nullptr) @@ -166,7 +77,7 @@ namespace OHOS list1_->SetVisible(true); } /* InitView:初始化界面*/ - void TraingLimitView ::InitView() + void TraingListLimitView ::InitView() { if (container_ == nullptr) { @@ -187,18 +98,26 @@ namespace OHOS container_->Add(scrollView1_); scrollView1_->SetVisible(true); - // 初始化Lable - InitLabel(label1_, 173, 52, 200, 60, "label1", "极限训练", DEFAULT_VECTOR_FONT_FILENAME, 30); + // 初始化titLable + TraingModel::GetInstance()->InitLabelExt(label1_, 173, 52, 200, 60, "label1", "极限训练", DEFAULT_VECTOR_FONT_FILENAME, 30); scrollView1_->Add(label1_); // 初始化Button - InitButton(button1_, 43, 120, 380, 100, BUTTON1); - InitButton(button2_, 43, 240, 380, 100, BUTTON2); - InitButton(button3_, 43, 360, 380, 100, BUTTON3); - InitButton(button4_, 43, 480, 380, 100, BUTTON4); - InitButton(button5_, 43, 600, 380, 100, BUTTON5); - InitButton(button6_, 43, 720, 380, 100, BUTTON6); - InitButton(button7_, 43, 840, 380, 100, BUTTON7); - InitButton(button8_, 43, 960, 380, 100, BUTTON8); + TraingModel::GetInstance()->InitButton(button1_, 43, 120, 380, 100, BUTTON1); + TraingModel::GetInstance()->InitButton(button2_, 43, 240, 380, 100, BUTTON2); + TraingModel::GetInstance()->InitButton(button3_, 43, 360, 380, 100, BUTTON3); + TraingModel::GetInstance()->InitButton(button4_, 43, 480, 380, 100, BUTTON4); + TraingModel::GetInstance()->InitButton(button5_, 43, 600, 380, 100, BUTTON5); + TraingModel::GetInstance()->InitButton(button6_, 43, 720, 380, 100, BUTTON6); + TraingModel::GetInstance()->InitButton(button7_, 43, 840, 380, 100, BUTTON7); + TraingModel::GetInstance()->InitButton(button8_, 43, 960, 380, 100, BUTTON8); + button1_->SetOnClickListener(static_cast(TraingListLimitPresenter::GetInstance())); + button2_->SetOnClickListener(static_cast(TraingListLimitPresenter::GetInstance())); + button3_->SetOnClickListener(static_cast(TraingListLimitPresenter::GetInstance())); + button4_->SetOnClickListener(static_cast(TraingListLimitPresenter::GetInstance())); + button5_->SetOnClickListener(static_cast(TraingListLimitPresenter::GetInstance())); + button6_->SetOnClickListener(static_cast(TraingListLimitPresenter::GetInstance())); + button7_->SetOnClickListener(static_cast(TraingListLimitPresenter::GetInstance())); + button8_->SetOnClickListener(static_cast(TraingListLimitPresenter::GetInstance())); scrollView1_->Add(button1_); scrollView1_->Add(button2_); scrollView1_->Add(button3_); @@ -208,14 +127,14 @@ namespace OHOS scrollView1_->Add(button7_); scrollView1_->Add(button8_); // 初始化image - InitImageView(image1_, 360, 160, 100, 100, "image1", ICON_IMAGE); - InitImageView(image2_, 360, 280, 100, 100, "image2", ICON_IMAGE); - InitImageView(image3_, 360, 400, 100, 100, "image3", ICON_IMAGE); - InitImageView(image4_, 360, 520, 100, 100, "image4", ICON_IMAGE); - InitImageView(image5_, 360, 640, 100, 100, "image5", ICON_IMAGE); - InitImageView(image6_, 360, 760, 100, 100, "image6", ICON_IMAGE); - InitImageView(image7_, 360, 880, 100, 100, "image7", ICON_IMAGE); - InitImageView(image8_, 360, 1000, 100, 100, "image8", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 360, 160, 100, 100, "image1", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 360, 280, 100, 100, "image2", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image3_, 360, 400, 100, 100, "image3", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image4_, 360, 520, 100, 100, "image4", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image5_, 360, 640, 100, 100, "image5", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image6_, 360, 760, 100, 100, "image6", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image7_, 360, 880, 100, 100, "image7", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image8_, 360, 1000, 100, 100, "image8", ICON_IMAGE); scrollView1_->Add(image1_); scrollView1_->Add(image2_); scrollView1_->Add(image3_); @@ -229,7 +148,7 @@ namespace OHOS scrollView1_->Add(list1_); } /* DeInit:删除组件*/ - void TraingLimitView::DeInit() + void TraingListLimitView::DeInit() { container_->RemoveAll(); if (label1_ != nullptr) @@ -347,7 +266,7 @@ namespace OHOS } } - void TraingLimitView::PreLoad(void) + void TraingListLimitView::PreLoad(void) { if (!viewiInitStatus) { @@ -355,7 +274,7 @@ namespace OHOS viewiInitStatus = true; } } - void TraingLimitView::OnStart() + void TraingListLimitView::OnStart() { container_ = new UIViewGroup(); if (container_ == nullptr) @@ -367,7 +286,7 @@ namespace OHOS container_->SetHeight(Screen::GetInstance().GetHeight()); // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(TraingLimitPresenter::GetInstance()); + UIView::OnDragListener *draglistener = static_cast(TraingListLimitPresenter::GetInstance()); if (draglistener == nullptr) { return; @@ -381,23 +300,23 @@ namespace OHOS RootView::GetInstance()->Add(container_); } - void TraingLimitView::OnSetUpView() + void TraingListLimitView::OnSetUpView() { - View::OnSetUpView(); + View::OnSetUpView(); Draw(); } - void TraingLimitView::OnTearDownView() + void TraingListLimitView::OnTearDownView() { - View::OnTearDownView(); + View::OnTearDownView(); return; } - void TraingLimitView::OnStop() + void TraingListLimitView::OnStop() { - View::OnStop(); + View::OnStop(); RootView::GetInstance()->RemoveAll(); return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListOtherPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListOtherPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListOtherView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListOtherView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListRestPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListRestPresenter.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListRestView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingListRestView.h new file mode 100644 index 000000000..e69de29bb diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index dc36572bd..f68cb483a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -2,13 +2,36 @@ #include "wearable_log.h" #include #include +#include "custom_utils.h" +#include +#include +#include "thread_adapter.h" +#include +#include +#include +#include +#include "cmsis_os.h" +#define TIMER 0 +#define CHECK 0 namespace OHOS { + +#if TIMER + // 声明定时器变量 + static osTimerId_t g_timer = NULL; + static int g_trainingTimer = {0}; + static constexpr int32 NUM_TEN = 10; + static constexpr int16 ERROR = 0; + static constexpr int16 SUCCESS = 1; + static constexpr int16 NUM_TIME_MIN = 60; + static constexpr int16 NUM_TIME_HOUR = 3600; + static constexpr int32 NUM_TIME_DAY = 86400; +#endif TraingModel ::TraingModel() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::TraingModel()"); -#if 0 +#if CHECK printf(" quickTraining_--training1_Text: %s\n", quickTraining_->training1_Text.c_str()); printf(" quickTraining_--training1_Image: %s\n", quickTraining_->training1_Image.c_str()); printf(" quickTraining_--training2_Text: %s\n", quickTraining_->training2_Text.c_str()); @@ -86,10 +109,54 @@ namespace OHOS label->SetRollSpeed(0); // 设置标签可见 label->SetVisible(true); - // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitLabel is succeed"); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitLabelExt is succeed"); return true; } + /*** + * @description: + * @param {UILabelExt} * + * @param {int} left + * @param {int} top + * @param {int} width + * @param {int} height + * @param {char} *viewId + * @param {char} *text + * @param {char} *fontName + * @param {int} fontSize + * @return {*} + * @brief 初始化多国语言标签 + */ + bool TraingModel::InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) + { + // 检查标签指针是否为空 + if (label == nullptr) + { + label = new UILabelExt(); + } + if (label == nullptr) + { + return false; // 内存分配失败,返回false + } + // 设置标签的位置和大小 + label->SetPosition(left, top); + label->Resize(width, height); + // 设置标签的视图 ID + label->SetViewId(viewId); + // 设置标签的样式 + label->SetStyle(STYLE_TEXT_FONT, fontSize); + label->SetFont(fontName, fontSize); + // 设置标签的文本和其他属性 + label->SetText(text); + // label->SetFontId(); + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(0); + // 设置标签可见 + label->SetVisible(true); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::InitLabelExt is succeed"); + return true; + } /*** * @description: * @param {UIButton} * @@ -154,4 +221,105 @@ namespace OHOS return true; } +#if TIMER + /* + * @brief 在这里添加定时器到期后的处理逻辑 + */ + static void TimerCallbackProc(int data) + { + g_trainingTimer++; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_trainingTimer:%d\n", g_trainingTimer); + + if (ShowTimer() == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[Recording_TimerCallbackProc] DisplaytrainingTimer is NULL"); + return; + } + + // RecordGoingView::GetInstance()->GetRecordingDurationLabel()->SetText(RecordingModel::GetInstance()->DisplaytrainingTimer()); + } + + /* + * @brief 运动计时回调函数 + */ + static void TimerCallback(int data) + { + GraphicService::GetInstance()->PostGraphicEvent(std::bind(TimerCallbackProc, data)); + } + /** + * @brief 开启定时器函数 + * @param interval 时间间隔,单位ms + */ + void TraingModel::StartTimer(uint32_t interval) + { + // 检查定时器是否已经存在,如果存在则返回 + if (g_timer != NULL) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingModel::Recording_StartTimer Timer already exists!!"); + return; + } + + // 创建定时器 + g_timer = osTimerNew((osTimerFunc_t)TimerCallback, osTimerPeriodic, NULL, NULL); + if (g_timer == NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel Timer create failed!!"); + return; + } + + // 将毫秒转换为系统时钟节拍数 + int tick = osMs2Tick(interval); + + // 启动定时器 + osStatus_t ret = osTimerStart(g_timer, tick); + + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel osTimerStart failed, ret = %lx!!", ret); + if (g_timer != NULL) + { + osTimerDelete(g_timer); + g_timer = NULL; + } + return; + } + } + + /** + * @brief 停止定时器 + */ + void TraingModel::StopTimer() + { + // 检查定时器是否存在 + if (g_timer != NULL) + { + // 删除定时器并置为 NULL + osStatus_t ret = osTimerDelete(g_timer); + if (ret != osOK) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::Recording_StopTimer osTimerDelete failed, ret = %lx!!", ret); + } + g_timer = NULL; + g_trainingTimer = 0; + } + } + // 显示计时时间 + char *TraingModel::ShowTimer() + { + trainingTimer.erase(); + + int hour = g_trainingTimer / NUM_TIME_HOUR; + int min = (g_trainingTimer % NUM_TIME_HOUR) / NUM_TIME_MIN; + int sec = (g_trainingTimer % NUM_TIME_HOUR) % NUM_TIME_MIN; + + std::ostringstream oss; + oss << std::setw(2) << std::setfill('0') << hour << ":" + << std::setw(2) << std::setfill('0') << min << ":" + << std::setw(2) << std::setfill('0') << sec; + + trainingTimer = oss.str(); + + return (char *)trainingTimer.c_str(); + } +#endif } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMoreView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMoreView.cpp index 23da15b02..b6b6dfd9d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMoreView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingMoreView.cpp @@ -33,95 +33,6 @@ namespace OHOS return g_pTraingMoreView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingMoreView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingMoreView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingMorePresenter 的实例 - button->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingMoreView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } /* Traing:初始化list */ void TraingMoreView::InitList() @@ -198,19 +109,29 @@ namespace OHOS scrollView1_->SetVisible(true); // 初始化Lable - InitLabel(label1_, 203, 52, 200, 60, "label1", "训练", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 203, 52, 200, 60, "label1", "训练", DEFAULT_VECTOR_FONT_FILENAME, 30); scrollView1_->Add(label1_); // 初始化Button - InitButton(button1_, 43, 120, 380, 100, BUTTON_FITNESS); - InitButton(button2_, 43, 240, 380, 100, BUTTON_DANCE); - InitButton(button1_, 43, 120, 380, 100, BUTTON_FITNESS); - InitButton(button2_, 43, 240, 380, 100, BUTTON_DANCE); - InitButton(button3_, 43, 360, 380, 100, BUTTON_REST); - InitButton(button4_, 43, 480, 380, 100, BUTTON_BALL); - InitButton(button5_, 43, 600, 380, 100, BUTTON_SWIMMING); - InitButton(button6_, 43, 720, 380, 100, BUTTON_ICE); - InitButton(button7_, 43, 840, 380, 100, BUTTON_LIMIT); - InitButton(button8_, 43, 960, 380, 100, BUTTON_OTHER); + TraingModel::GetInstance()->InitButton(button1_, 43, 120, 380, 100, BUTTON_FITNESS); + TraingModel::GetInstance()->InitButton(button2_, 43, 240, 380, 100, BUTTON_DANCE); + TraingModel::GetInstance()->InitButton(button1_, 43, 120, 380, 100, BUTTON_FITNESS); + TraingModel::GetInstance()->InitButton(button2_, 43, 240, 380, 100, BUTTON_DANCE); + TraingModel::GetInstance()->InitButton(button3_, 43, 360, 380, 100, BUTTON_REST); + TraingModel::GetInstance()->InitButton(button4_, 43, 480, 380, 100, BUTTON_BALL); + TraingModel::GetInstance()->InitButton(button5_, 43, 600, 380, 100, BUTTON_SWIMMING); + TraingModel::GetInstance()->InitButton(button6_, 43, 720, 380, 100, BUTTON_ICE); + TraingModel::GetInstance()->InitButton(button7_, 43, 840, 380, 100, BUTTON_LIMIT); + TraingModel::GetInstance()->InitButton(button8_, 43, 960, 380, 100, BUTTON_OTHER); + button1_->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + button2_->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + button3_->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + button4_->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + button5_->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + button6_->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + button7_->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + button8_->SetOnClickListener(static_cast(TraingMorePresenter::GetInstance())); + + scrollView1_->Add(button1_); scrollView1_->Add(button2_); scrollView1_->Add(button3_); @@ -220,14 +141,14 @@ namespace OHOS scrollView1_->Add(button7_); scrollView1_->Add(button8_); // 初始化image - InitImageView(image1_, 360, 160, 100, 100, "image1", ICON_IMAGE); - InitImageView(image2_, 360, 280, 100, 100, "image2", ICON_IMAGE); - InitImageView(image3_, 360, 400, 100, 100, "image3", ICON_IMAGE); - InitImageView(image4_, 360, 520, 100, 100, "image4", ICON_IMAGE); - InitImageView(image5_, 360, 640, 100, 100, "image5", ICON_IMAGE); - InitImageView(image6_, 360, 760, 100, 100, "image6", ICON_IMAGE); - InitImageView(image7_, 360, 880, 100, 100, "image7", ICON_IMAGE); - InitImageView(image8_, 360, 1000, 100, 100, "image8", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 360, 160, 100, 100, "image1", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 360, 280, 100, 100, "image2", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image3_, 360, 400, 100, 100, "image3", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image4_, 360, 520, 100, 100, "image4", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image5_, 360, 640, 100, 100, "image5", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image6_, 360, 760, 100, 100, "image6", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image7_, 360, 880, 100, 100, "image7", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image8_, 360, 1000, 100, 100, "image8", ICON_IMAGE); scrollView1_->Add(image1_); scrollView1_->Add(image2_); scrollView1_->Add(image3_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp index 8f853ceb2..96988b85e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp @@ -30,72 +30,7 @@ namespace OHOS return g_pTraingNomalView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingNomalView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingNomalView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingNomalPresenter 的实例 - button->SetOnClickListener(static_cast(TraingNomalPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingNomalView ::InitView() { @@ -107,20 +42,22 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 137, 52, 195, 35, "label1", "高空弹跳/蹦极", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 137, 52, 195, 35, "label1", "高空弹跳/蹦极", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label1_); - InitLabel(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 160, 370, 146, 35, "label2", "设定目标 >", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label2_); // 初始化Button - InitButton(button1_, 133, 133, 200, 200, BUTTONGO); + TraingModel::GetInstance()->InitButton(button1_, 133, 133, 200, 200, BUTTONGO); // Set additional property button1_->SetImageSrc(GO_1_IMAGE, nullptr); - InitButton(button2_, 160, 370, 146, 35, BUTTONSET); + TraingModel::GetInstance()->InitButton(button2_, 160, 370, 146, 35, BUTTONSET); button2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);//设置为透明按键 button2_->SetStyle(STYLE_BACKGROUND_OPA, 0x00); button2_->SetStyleForState(STYLE_BACKGROUND_OPA, 0x80, UIButton::PRESSED); // 设置按下时的透明度为半透明 + button1_->SetOnClickListener(static_cast(TraingNomalPresenter::GetInstance())); + button2_->SetOnClickListener(static_cast(TraingNomalPresenter::GetInstance())); container_->Add(button1_); container_->Add(button2_); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetCaluliView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetCaluliView.cpp index c15f55647..31e05e9f7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetCaluliView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetCaluliView.cpp @@ -45,72 +45,7 @@ namespace OHOS return g_pTraingSetCaluliView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingSetCaluliView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingSetCaluliView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingSetCaluliPresenter 的实例 - button->SetOnClickListener(static_cast(TraingSetCaluliPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } + /* InitUIPicker: 初始化UIPicker组件 @param picker: 指向UIPicker的指针 @@ -172,16 +107,17 @@ namespace OHOS container_->SetStyle(STYLE_BACKGROUND_OPA, 0); } // 初始化Lable - InitLabel(label1_, 173, 52, 120, 35, "label1", "卡路里设定", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 173, 52, 120, 35, "label1", "卡路里设定", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label1_); // 初始化UIPicker InitUIPicker(uiPicker1_, 43, 106, 380, 240, "uiPicker1"); container_->Add(uiPicker1_); // 初始化Button - InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + TraingModel::GetInstance()->InitButton(button1_, 0, 366, 466, 100, BUTTONOK); // Set additional property button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr); + button1_->SetOnClickListener(static_cast(TraingSetCaluliPresenter::GetInstance())); container_->Add(button1_); } /* DeInit:删除组件 */ diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetDistView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetDistView.cpp index a979c3129..68e4a58c8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetDistView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetDistView.cpp @@ -46,72 +46,7 @@ namespace OHOS return g_pTraingSetDistView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingSetDistView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingSetDistView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingSetDistPresenter 的实例 - button->SetOnClickListener(static_cast(TraingSetDistPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } + /* InitUIPicker: 初始化UIPicker组件 @param picker: 指向UIPicker的指针 @@ -173,16 +108,16 @@ namespace OHOS container_->SetStyle(STYLE_BACKGROUND_OPA, 0); } // 初始化Lable - InitLabel(label1_, 173, 52, 120, 35, "label1", "步数设定", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 173, 52, 120, 35, "label1", "步数设定", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label1_); // 初始化UIPicker InitUIPicker(uiPicker1_, 43, 106, 380, 240, "uiPicker1"); container_->Add(uiPicker1_); // 初始化Button - InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + TraingModel::GetInstance()->InitButton(button1_, 0, 366, 466, 100, BUTTONOK); // Set additional property - + button1_->SetOnClickListener(static_cast(TraingSetDistPresenter::GetInstance())); button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr); container_->Add(button1_); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetSeptView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetSeptView.cpp index 5f5519e44..850f0903e 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetSeptView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetSeptView.cpp @@ -45,72 +45,7 @@ namespace OHOS return g_pTraingSetSeptView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingSetSeptView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingSetSeptView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingSetSeptPresenter 的实例 - button->SetOnClickListener(static_cast(TraingSetSeptPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } + /* InitUIPicker: 初始化UIPicker组件 @param picker: 指向UIPicker的指针 @@ -172,15 +107,16 @@ namespace OHOS container_->SetStyle(STYLE_BACKGROUND_OPA, 0); } // 初始化Lable - InitLabel(label1_, 173, 52, 120, 35, "label1", "步数设定", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 173, 52, 120, 35, "label1", "步数设定", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label1_); // 初始化UIPicker InitUIPicker(uiPicker1_, 43, 106, 380, 240, "uiPicker1"); container_->Add(uiPicker1_); // 初始化Button - InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + TraingModel::GetInstance()->InitButton(button1_, 0, 366, 466, 100, BUTTONOK); // Set additional property + button1_->SetOnClickListener(static_cast(TraingSetSeptPresenter::GetInstance())); button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr); container_->Add(button1_); } @@ -225,7 +161,7 @@ namespace OHOS { if (!viewiInitStatus) { - //printf("init TraingSetSeptview\n"); + // printf("init TraingSetSeptview\n"); InitView(); viewiInitStatus = true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetTimeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetTimeView.cpp index 158f55661..83a734391 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetTimeView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetTimeView.cpp @@ -45,72 +45,7 @@ namespace OHOS return g_pTraingSetTimeView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingSetTimeView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingSetTimeView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingSetTimePresenter 的实例 - button->SetOnClickListener(static_cast(TraingSetTimePresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } + /* InitUIPicker: 初始化UIPicker组件 @param picker: 指向UIPicker的指针 @@ -172,14 +107,15 @@ namespace OHOS container_->SetStyle(STYLE_BACKGROUND_OPA, 0); } // 初始化Lable - InitLabel(label1_, 173, 52, 120, 35, "label1", "时长设定", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label1_, 173, 52, 120, 35, "label1", "时长设定", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label1_); // 初始化UIPicker InitUIPicker(uiPicker1_, 43, 106, 380, 240, "uiPicker1"); container_->Add(uiPicker1_); // 初始化Button - InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + TraingModel::GetInstance()->InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + button1_->SetOnClickListener(static_cast(TraingSetTimePresenter::GetInstance())); // Set additional property button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr); container_->Add(button1_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetView.cpp index 5d01b3b2f..0ab028207 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingSetView.cpp @@ -30,94 +30,7 @@ namespace OHOS return g_pTraingSetView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingSetView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingSetView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingSetPresenter 的实例 - button->SetOnClickListener(static_cast(TraingSetPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingSetView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingSetView ::InitView() { @@ -129,17 +42,20 @@ namespace OHOS } // 初始化Button - InitButton(button1_, 43, 120, 380, 100, BUTTONTIME); - InitButton(button2_, 43, 240, 380, 100, BUTTONCALULI); + TraingModel::GetInstance()->InitButton(button1_, 43, 120, 380, 100, BUTTONTIME); + TraingModel::GetInstance()->InitButton(button2_, 43, 240, 380, 100, BUTTONCALULI); + button1_->SetOnClickListener(static_cast(TraingSetPresenter::GetInstance())); + button2_->SetOnClickListener(static_cast(TraingSetPresenter::GetInstance())); container_->Add(button1_); container_->Add(button2_); // 初始化Lable - InitLabel(label1_, 173, 52, 120, 35, "label1", "极限运动", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label2_, 130, 150, 60, 35, "label2", "时长", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label3_, 270, 155, 69, 23, "label3", "30 分钟", DEFAULT_VECTOR_FONT_FILENAME, 20); - InitLabel(label4_, 130, 270, 60, 35, "label4", "卡路里", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label5_, 270, 275, 60, 35, "label5", "1000 千卡", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label1_, 173, 52, 120, 35, "label1", "极限运动", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 130, 150, 60, 35, "label2", "时长", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label3_, 270, 155, 69, 23, "label3", "30 分钟", DEFAULT_VECTOR_FONT_FILENAME, 20); + TraingModel::GetInstance()->InitLabelExt(label4_, 130, 270, 60, 35, "label4", "卡路里", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label5_, 270, 275, 60, 35, "label5", "1000 千卡", DEFAULT_VECTOR_FONT_FILENAME, 20); + container_->Add(label1_); container_->Add(label2_); container_->Add(label3_); @@ -147,10 +63,10 @@ namespace OHOS container_->Add(label5_); // 初始化Image - InitImageView(image1_, 70, 150, 100, 100, "image1", TIME_IMAGE); - InitImageView(image2_, 70, 270, 100, 100, "image2", CALORIES_IMAGE); - InitImageView(image3_, 380, 160, 100, 100, "image3", ICON_IMAGE); - InitImageView(image4_, 380, 280, 100, 100, "image4", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 70, 150, 100, 100, "image1", TIME_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 70, 270, 100, 100, "image2", CALORIES_IMAGE); + TraingModel::GetInstance()->InitImageView(image3_, 380, 160, 100, 100, "image3", ICON_IMAGE); + TraingModel::GetInstance()->InitImageView(image4_, 380, 280, 100, 100, "image4", ICON_IMAGE); container_->Add(image1_); container_->Add(image2_); container_->Add(image3_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingStrongView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingStrongView.cpp index c805d9ef7..5f16244b0 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingStrongView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingStrongView.cpp @@ -31,96 +31,7 @@ namespace OHOS return g_pTraingStrongView; } - /* - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingStrongView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(top, left); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_LINE_HEIGHT, 40); - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - // 设置中心对齐,这里先屏蔽一下 - // label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /* - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingStrongView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingStrongPresenter 的实例 - button->SetOnClickListener(static_cast(TraingStrongPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - /* - InitImageView:初始化图片 - @param imageView 图片指针 - @param left 图片左边位置 - @param top 图片顶部位置 - @param width 图片宽度 - @param height 图片高度 - @param viewId 图片的视图 ID - @param imagePath 图片路径 - */ - void TraingStrongView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(top, left); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } + /* InitView:初始化界面*/ void TraingStrongView ::InitView() { @@ -148,12 +59,12 @@ namespace OHOS scrollView1_->SetVisible(true); // 初始化Lable - InitLabel(label1_, 52, 173, 120, 35, "label1", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabel(label2_, 133, 33, 60, 35, "label2", "训练强度用于判断是否训练不足或\n者训练太过,到底使心率增加多少\n的运动强度才是最合适的。", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label3_, 305, 33, 69, 23, "label3", "该强度区间是对应靶心率(由个人\n基本资料计算得出)强弱的实时状\n态显示,有助于提高训练质量。", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label4_, 465, 33, 60, 35, "label4", "训练状态代表的意义:", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label5_, 505, 97, 60, 35, "label5", "较低强度-热身运动\n中等强度-燃脂区\n高等强度-提升心肺机能\n超高强度-专业运动员", DEFAULT_VECTOR_FONT_FILENAME, 26); - InitLabel(label6_, 740, 51, 60, 35, "label5", "注:该训练强度并非专业运动评\n估,数据仅供参考。", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label1_, 52, 173, 120, 35, "label1", "训练强度", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label2_, 133, 33, 60, 35, "label2", "训练强度用于判断是否训练不足或\n者训练太过,到底使心率增加多少\n的运动强度才是最合适的。", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label3_, 305, 33, 69, 23, "label3", "该强度区间是对应靶心率(由个人\n基本资料计算得出)强弱的实时状\n态显示,有助于提高训练质量。", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label4_, 465, 33, 60, 35, "label4", "训练状态代表的意义:", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label5_, 505, 97, 60, 35, "label5", "较低强度-热身运动\n中等强度-燃脂区\n高等强度-提升心肺机能\n超高强度-专业运动员", DEFAULT_VECTOR_FONT_FILENAME, 26); + TraingModel::GetInstance()->InitLabelExt(label6_, 740, 51, 60, 35, "label5", "注:该训练强度并非专业运动评\n估,数据仅供参考。", DEFAULT_VECTOR_FONT_FILENAME, 26); label6_->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); scrollView1_->Add(label1_); scrollView1_->Add(label2_); @@ -163,10 +74,10 @@ namespace OHOS scrollView1_->Add(label6_); // 初始化Image - InitImageView(image1_, 510, 60, 100, 100, "image1", POINT_BLUE_IMAGE); - InitImageView(image2_, 550, 60, 100, 100, "image2", POINT_GREEN_IMAGE); - InitImageView(image3_, 590, 60, 100, 100, "image3", POINT_ORANGE_IMAGE); - InitImageView(image4_, 630, 60, 100, 100, "image4", POINT_YELLOW_IMAGE); + TraingModel::GetInstance()->InitImageView(image1_, 510, 60, 100, 100, "image1", POINT_BLUE_IMAGE); + TraingModel::GetInstance()->InitImageView(image2_, 550, 60, 100, 100, "image2", POINT_GREEN_IMAGE); + TraingModel::GetInstance()->InitImageView(image3_, 590, 60, 100, 100, "image3", POINT_ORANGE_IMAGE); + TraingModel::GetInstance()->InitImageView(image4_, 630, 60, 100, 100, "image4", POINT_YELLOW_IMAGE); scrollView1_->Add(image1_); scrollView1_->Add(image2_); scrollView1_->Add(image3_); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp index dd97ffbbb..f0d7a59ed 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingView.cpp @@ -71,13 +71,13 @@ namespace OHOS { // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::AddLabel"); // 初始化标签 - TraingModel::GetInstance()->InitLabel(title_label, TITLE_LABEL_X, TITLE_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "title_label", "快速训练", DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); + TraingModel::GetInstance()->InitLabelExt(title_label, TITLE_LABEL_X, TITLE_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "title_label", "快速训练", DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); const char *dataStr1 = (data->training1_Text).c_str(); const char *dataStr2 = (data->training2_Text).c_str(); const char *dataStr3 = (data->training3_Text).c_str(); - TraingModel::GetInstance()->InitLabel(btn1_label, BTN1_LABEL_X, BTN1_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu1_label", dataStr1, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); - TraingModel::GetInstance()->InitLabel(btn2_label, BTN2_LABEL_X, BTN2_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu2_label", dataStr2, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); - TraingModel::GetInstance()->InitLabel(btn3_label, BTN3_LABEL_X, BTN3_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu3_label", dataStr3, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); + TraingModel::GetInstance()->InitLabelExt(btn1_label, BTN1_LABEL_X, BTN1_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu1_label", dataStr1, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); + TraingModel::GetInstance()->InitLabelExt(btn2_label, BTN2_LABEL_X, BTN2_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu2_label", dataStr2, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); + TraingModel::GetInstance()->InitLabelExt(btn3_label, BTN3_LABEL_X, BTN3_LABEL_Y, LABEL_X_SIZE, LABEL_Y_SIZE, "btu3_label", dataStr3, DEFAULT_VECTOR_FONT_FILENAME, LABEL_FONT_SIZE); return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp index 70230577d..81105ecb2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingWinView.cpp @@ -61,97 +61,6 @@ namespace OHOS } delete[] imagePaths; } - /**************************************************/ - /** - InitLabel:初始化标签 - @param label 标签指针 - @param left 标签左边位置 - @param top 标签顶部位置 - @param width 标签宽度 - @param height 标签高度 - @param viewId 标签的视图 ID - @param text 标签显示的文本 - @param fontName 字体名称 - @param fontSize 字体大小 - */ - void TraingWinView::InitLabel(UILabel *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize) - { - // 检查标签指针是否为空 - if (label == nullptr) - { - label = new UILabel(); - } - // 设置标签的位置和大小 - label->SetPosition(left, top); - label->Resize(width, height); - // 设置标签的视图 ID - label->SetViewId(viewId); - // 设置标签的样式 - label->SetStyle(STYLE_TEXT_FONT, fontSize); - label->SetFont(fontName, fontSize); - // 设置标签的文本和其他属性 - label->SetText(text); - label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label->SetRollSpeed(0); - // 设置标签可见 - label->SetVisible(true); - } - /** - InitButton:初始化按钮 - @param button 按钮指针 - @param left 按钮左边位置 - @param top 按钮顶部位置 - @param width 按钮宽度 - @param height 按钮高度 - @param viewId 按钮的视图 ID - */ - void TraingWinView::InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId) - { - // 设置按钮的背景颜色 - uint32_t backgroundColor = 0xff191919; // 默认背景颜色 - uint32_t pressedBackgroundColor = 0xff249115; // 按下时的背景颜色 - uint32_t pressedBorderColor = 0xff0b1928; // 按下时的边框颜色 - // 创建新按钮(如果当前按钮为空) - if (button == nullptr) - { - button = new UIButton(); - } - button->SetPosition(left, top); - button->Resize(width, height); - button->SetViewId(viewId); - button->SetStyle(STYLE_BACKGROUND_COLOR, backgroundColor); - button->SetStyleForState(STYLE_BACKGROUND_COLOR, pressedBackgroundColor, UIButton::PRESSED); - button->SetStyleForState(STYLE_BORDER_COLOR, pressedBorderColor, UIButton::PRESSED); - // 设置按钮的点击事件监听器为 TraingWinPresenter 的实例 - button->SetOnClickListener(static_cast(TraingWinPresenter::GetInstance())); - // 设置按钮可见 - button->SetVisible(true); - } - - /** - * 初始化图片视图 - * @param imageView 图片视图指针 - * @param left 图片左边位置 - * @param top 图片顶部位置 - * @param width 图片宽度 - * @param height 图片高度 - * @param viewId 图片的视图 ID - * @param imagePath 图片路径 - */ - void TraingWinView::InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath) - { - if (imageView == nullptr) - { - imageView = new UIImageView(); - } - imageView->SetPosition(left, top); - imageView->Resize(width, height); - imageView->SetViewId(viewId); - imageView->SetSrc(imagePath); - imageView->SetVisible(true); - } - /** * @brief 初始化UIImageAnimatorView,并设置为GIF动画。 * @@ -208,20 +117,20 @@ namespace OHOS } // 初始化Lable - InitLabel(label1_, 155, 52, 195, 35, "label1", "目标已达成", DEFAULT_VECTOR_FONT_FILENAME, 35); + TraingModel::GetInstance()->InitLabelExt(label1_, 155, 52, 195, 35, "label1", "目标已达成", DEFAULT_VECTOR_FONT_FILENAME, 35); container_->Add(label1_); - InitLabel(label2_, 108, 215, 146, 35, "label2", "10,000", DEFAULT_VECTOR_FONT_FILENAME, 80); + TraingModel::GetInstance()->InitLabelExt(label2_, 108, 215, 146, 35, "label2", "10,000", DEFAULT_VECTOR_FONT_FILENAME, 80); label2_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); container_->Add(label2_); - InitLabel(label3_, 132, 307, 146, 35, "label3", "完成目标", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label3_, 132, 307, 146, 35, "label3", "完成目标", DEFAULT_VECTOR_FONT_FILENAME, 30); container_->Add(label3_); - InitLabel(label4_, 280, 307, 146, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); + TraingModel::GetInstance()->InitLabelExt(label4_, 280, 307, 146, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); label4_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); container_->Add(label4_); /* 初始化image - InitImageView(image1_, 173, 100, 120, 120, "image1", imagePath_win); + TraingModel::GetInstance()->InitImageView(image1_, 173, 100, 120, 120, "image1", imagePath_win); container_->Add(image1_); */ @@ -234,10 +143,11 @@ namespace OHOS // FreeImagePathsArray(imagePaths, 94); //删除数组,释放内存 // 初始化Button - InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + TraingModel::GetInstance()->InitButton(button1_, 0, 366, 466, 100, BUTTONOK); // Set additional property button1_->SetImageSrc(BUTTONOK_IMAGE, nullptr); + button1_->SetOnClickListener(static_cast(TraingWinPresenter::GetInstance())); container_->Add(button1_); }