From: Caisking <3449750381@qq.com> Date: Tue, 23 Apr 2024 07:03:56 +0000 (+0800) Subject: 无训练记录UI X-Git-Tag: release_V1.2.70_20241020_135402~1145 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=a267176b17ccb068de2fe5cf69c9e626225c39c8;p=mirrors%2FFD230.git 无训练记录UI --- diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index c40e47e27..fbea038f3 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -104,10 +104,11 @@ typedef enum : uint16_t #ifdef SUPPORT_ALIPAY_SEC VIEW_MAIN_ALIPAY, #endif - VIEW_SET_DESKTOP, - VIEW_SET_CARD, - VIEW_ADD_CARD, - VIEW_SET_DIAL, + VIEW_SET_DESKTOP, // 主题样式 + VIEW_SET_CARD, // 卡片管理 + VIEW_ADD_CARD, // 添加卡片 + VIEW_SET_DIAL, // 切换表盘 + VIEW_MAX_INTER_APP, // 在此之前添加native应用ID. VIEW_EXTERN_APP = 0xFFFE, // 三方应用 VIEW_INVALIDE_APP = 0xFFFF, diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h b/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h index 04d125e90..190cb4b00 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/Training_UiConfig.h @@ -107,9 +107,10 @@ namespace OHOS static constexpr const char *STEP_30_IMAGE = MODULES "/Step_30.bin"; static constexpr const char *SPORT_HEARTRATE_IMAGE = MODULES "/sport_heartrate.bin"; static constexpr const char *TIME_IMAGE = MODULES "/Time.bin"; - //static constexpr const char *WALKING_54_IMAGE = MODULES "/Walking_54.bin"; + // static constexpr const char *WALKING_54_IMAGE = MODULES "/Walking_54.bin"; static constexpr const char *WARNING_IMAGE = MODULES "/Warning.bin"; static constexpr const char *YES_IMAGE = MODULES "/Yes.bin"; + static constexpr const char *RECOED_IMAGE = MODULES "/Norecord.bin"; // Training GIF static constexpr const char *TRAINING_GIF_IMAGE_1 = TRAINING_GIF "/win/1.bin"; 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 d56ad2def..be23114e6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -36,7 +36,7 @@ #include #include -#include +#include #define GILROY_REGULAR_FONT "./font_library/gilroy-regular-3.ttf" #define GILROY_BOLD_FONT "./font_library/gilroy-bold-4.ttf" @@ -99,7 +99,7 @@ extern "C" // 最高海拔高度 uint32_t alt; }; - Trainingdata *read_Trainingdata_data(char* timedata, uint16_t offset); + Trainingdata *read_Trainingdata_data(char *timedata, uint16_t offset); int write_Trainingdata_data(Trainingdata data); @@ -217,15 +217,27 @@ namespace OHOS static TraingModel *GetInstance(void); void Init(); - /*训练组件初始化*/ + /* --------------------------------- 训练组件初始化 -------------------------------- */ + /*初始化label[可使用text]*/ bool InitLabel(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, const char *text, const char *fontName, int fontSize); + /*初始化labelExt*/ bool InitLabelExt(UILabelExt *&label, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, const char *fontName, int fontSize); + /*初始化button*/ bool InitButton(UIButton *&button, int left, int top, int width, int height, const char *viewId); + /*初始化buttonExt*/ bool InitButtonExt(UILabelButtonExt *&button, int left, int top, int width, int height, const char *viewId, UIResourceTextId id, int fontSize); + /*初始化image*/ bool InitImageView(UIImageView *&imageView, int left, int top, int width, int height, const char *viewId, const char *imagePath); + /*生成动画资源数组*/ const char **CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages); + /*初始化动画资源*/ void InitImageAnimatorSource(UIImageAnimatorView *&imageAnimator, const char **imagePaths, int numFrames, int left, int top, int width, int height, const char *viewId, int time); - void InitList(); + /*InitLabel[默认参数]*/ + void InitLabelDefault(UILabelExt *&label, int x, int y, int width, int height, const char *viewId, const char *text, int fontSize = 30, const char *fontName = DEFAULT_VECTOR_FONT_FILENAME) + { + InitLabel(label, x, y, width, height, viewId, text, fontName, fontSize); + } + /* -------------------------------------------------------------------------- */ /*定时器 */ std::string DisplayMotionDuration(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h index a8e0bf083..1193902d2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-04-15 11:46:23 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-04-23 11:00:11 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingCardView.h + */ #ifndef _TraingCard_VIEW_H #define _TraingCard_VIEW_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingWinView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingWinView.h deleted file mode 100644 index 4bb465ceb..000000000 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingWinView.h +++ /dev/null @@ -1,64 +0,0 @@ -/*** - * @Date: 2024-04-17 16:32:02 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-04-19 10:20:35 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingWinView.h - */ -#ifndef _TrainingWin_VIEW_H -#define _TrainingWin_VIEW_H - -#include "BaseView.h" -#include "View.h" -#include -#include "components/ui_view_group.h" -#include "components/ui_label.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" -#include "components/ui_button.h" -#include "components/ui_image_animator.h" -#include "components/ui_label_button_ext.h" -#include "components/ui_chart.h" -#include "components/ui_list.h" -#include "components/icon_adapter.h" -#include "wearable_log.h" -#include "ohos_types.h" -#include "components/ui_card_page.h" -#include "traing/include/TraingModel.h" -#include "traing/Training_UiConfig.h" - -namespace OHOS -{ -#define BUTTONWINOK "buttonwin" - - class TrainingWinPresenter; - class TrainingWinView : public View - { - - public: - TrainingWinView(); - virtual ~TrainingWinView(); - static TrainingWinView *GetInstance(void); - - - void InitView(); - 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 PreLoad(void); - - private: - UIView::OnDragListener *draglistener{nullptr}; - TrainingWinView(TrainingWinView &&) = delete; - TrainingWinView &operator=(TrainingWinView &&) = delete; - UIViewGroup *container_ = nullptr; - UILabelExt *labeltitle = nullptr; - UILabelExt *labeltag = nullptr; - UILabelExt *labelgettag = nullptr; - UILabelExt *labelpre = nullptr; - UIButton *buttonok_ = nullptr; - UIImageView *image1_ = nullptr; - UIImageAnimatorView *imageAnimator; - bool viewiInitStatus{false}; - }; - -} // namespace OHOS -#endif // TrainingWin_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingWinView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingWinView.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/include/TraingRecordView.h b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/include/TraingRecordView.h index e2cfe4b2d..90b0a71f2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/include/TraingRecordView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/include/TraingRecordView.h @@ -18,15 +18,22 @@ #include "ohos_types.h" #include "components/ui_card_page.h" +#include "traing/include/TraingModel.h" +#include "traing/Training_UiConfig.h" #include "TraingRecordPresenter.h" namespace OHOS { -#define BUTTONNOTE "button1" +#define BUTTONGO "button_go" + + enum class PopupView + { + LackPopup, + RecordPopup + }; class TraingRecordPresenter; class TraingRecordView : public View { - public: TraingRecordView(); virtual ~TraingRecordView(); @@ -38,24 +45,27 @@ 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); - // 通过函数改变 - void SetLabel(); - void SetButton(); + void ShowLackView(); + void ShowRecordView(); + void SetPopupViewStatus(PopupView view, bool status); private: UIView::OnDragListener *draglistener{nullptr}; TraingRecordView(TraingRecordView &&) = delete; TraingRecordView &operator=(TraingRecordView &&) = delete; + UIScrollView *container_ = nullptr; + + /*无训练记录界面*/ + UIScrollView *lackView{nullptr}; + UILabelExt *labeltitle_ = nullptr; + UILabelExt *labelrecord_ = nullptr; + UILabelButtonExt *buttongo = nullptr; + UIImageView *imagerecord = nullptr; - UIViewGroup *container_ = nullptr; - UILabel *label1_ = nullptr; - UILabel *label2_ = nullptr; + /*训练列表界面*/ + UIScrollView *recordView{nullptr}; bool viewiInitStatus{false}; }; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp index 22a0c8b9d..61de10292 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordPresenter.cpp @@ -1,6 +1,6 @@ #include "AppViewIDs.h" #include "components/ui_label_ext.h" -#include"language/font/ui_resource_string.h" +#include "language/font/ui_resource_string.h" #include "NativeAbility.h" #include @@ -53,12 +53,18 @@ namespace OHOS { if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + NativeAbility::GetInstance().Back(); } return true; } bool TraingRecordPresenter::OnClick(UIView &view, const ClickEvent &event) { + // 返回按键 + if (strcmp(view.GetViewId(), BUTTONGO) == 0) + { + NativeAbility::GetInstance().EnterSlice(VIEW_TRAININGMORE); + } + return true; } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp index 9375a7c8d..875c3b6e1 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traingrecord/src/TraingRecordView.cpp @@ -8,6 +8,7 @@ #include "components/ui_button.h" namespace OHOS { + static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; static TraingRecordView *g_pTraingRecordView{nullptr}; @@ -24,80 +25,69 @@ namespace OHOS TraingRecordView *TraingRecordView::GetInstance() { - return g_pTraingRecordView; } - + /* InitView:初始化界面*/ void TraingRecordView ::InitView() { if (container_ == nullptr) { - container_ = new UIViewGroup(); + container_ = new UIScrollView(); container_->SetPosition(0, 0, 466, 466); container_->SetStyle(STYLE_BACKGROUND_OPA, 0); } - // 初始化Lable - // Add Label to App - if (label1_ == nullptr) - { - label1_ = new UILabel(); - } - label1_->SetPosition(181, 52); // widget's left position and top position - label1_->Resize(200, 60); // widget's width and height - label1_->SetViewId("label1"); // Set style - label1_->SetStyle(STYLE_TEXT_FONT, 26); - - // Set additional property - label1_->SetText("训练记录"); - label1_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label1_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label1_->SetRollSpeed(0); - label1_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 26); - - // Add to rootView - container_->Add(label1_); - label1_->SetVisible(true); - - // Add Label to App - if (label2_ == nullptr) - { - label2_ = new UILabel(); - } - label2_->SetPosition(188, 217); // widget's left position and top position - label2_->Resize(200, 60); // widget's width and height - label2_->SetViewId("label2"); // Set style - label2_->SetStyle(STYLE_TEXT_FONT, 30); - - // Set additional property - label2_->SetText("无记录"); - label2_->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); - label2_->SetTextColor(Color::GetColorFromRGBA(0x28, 0xbc, 0x0c, 0xff)); - label2_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - label2_->SetRollSpeed(0); - label2_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - - // Add to rootView - container_->Add(label2_); - label2_->SetVisible(true); + // 展示无记录界面。后续需要加入函数判断 + SetPopupViewStatus(PopupView::LackPopup, true); } /* DeInit:删除组件 */ void TraingRecordView::DeInit() { container_->RemoveAll(); - if (label1_ != nullptr) + if (labeltitle_ != nullptr) + { + lackView->Remove(labeltitle_); + delete labeltitle_; + labeltitle_ = nullptr; + } + if (labelrecord_ != nullptr) + { + lackView->Remove(labelrecord_); + delete labelrecord_; + labelrecord_ = nullptr; + } + if (buttongo != nullptr) + { + lackView->Remove(buttongo); + delete buttongo; + buttongo = nullptr; + } + if (imagerecord != nullptr) + { + lackView->Remove(imagerecord); + delete imagerecord; + imagerecord = nullptr; + } + + if (lackView != nullptr) { - delete label1_; - label1_ = nullptr; + lackView->RemoveAll(); + delete lackView; + lackView = nullptr; } - if (label2_ != nullptr) + if (recordView != nullptr) { - delete label2_; - label2_ = nullptr; + recordView->RemoveAll(); + delete recordView; + recordView = nullptr; + } + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; } - delete container_; - container_ = nullptr; } void TraingRecordView::PreLoad(void) @@ -108,17 +98,90 @@ namespace OHOS viewiInitStatus = true; } } + /*显示无记录界面*/ + void TraingRecordView::ShowLackView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowLackView start"); + lackView = new UIScrollView(); + if (lackView == nullptr) + { + return; + } + lackView->SetPosition(0, 0); + lackView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + lackView->SetScrollBlankSize(20); + lackView->SetReboundSize(50); + lackView->SetDirection(1); + /*初始化label*/ + TraingModel::GetInstance()->InitLabelDefault(labeltitle_, 83, 50, 300, 35, "labletitle", "训练记录"); + TraingModel::GetInstance()->InitLabelDefault(labelrecord_, 53, 260, 360, 40, "labelrecord", "无记录"); + /*初始化image*/ + TraingModel::GetInstance()->InitImageView(imagerecord, 174, 120, 118, 120, "image", RECOED_IMAGE); + /*初始化按键*/ + TraingModel::GetInstance()->InitButtonExt(buttongo, 93, 330, 280, 90, BUTTONGO, STR_TRAINING, 26); + buttongo->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); // 设置按键颜色 + buttongo->SetOnClickListener(static_cast(TraingRecordPresenter::GetInstance())); + + lackView->Add(labeltitle_); + lackView->Add(labelrecord_); + lackView->Add(imagerecord); + lackView->Add(buttongo); + + RootView::GetInstance()->Add(lackView); + lackView->SetDraggable(true); + lackView->SetTouchable(true); + + UIView::OnDragListener *draglistener = static_cast(TraingRecordPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + lackView->SetOnDragListener(draglistener); + + lackView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShowLackView end"); + } + /*记录列表界面*/ + void TraingRecordView::ShowRecordView() + { + } + /*控制显示界面*/ + void TraingRecordView::SetPopupViewStatus(PopupView view, bool status) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", view); + UIView *popupView = nullptr; + if (view == PopupView::LackPopup) + { + popupView = lackView; + } + else if (view == PopupView::RecordPopup) + { + popupView = recordView; + } + + if (popupView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); + return; + } + + if (container_ != nullptr) + { + container_->SetVisible(!status); + } + + popupView->SetVisible(status); + } + void TraingRecordView::OnStart() { - container_ = new UIViewGroup(); + container_ = new UIScrollView(); if (container_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "container_ new fail"); return; } - container_->SetPosition(0, 0); - container_->SetWidth(Screen::GetInstance().GetWidth()); - container_->SetHeight(Screen::GetInstance().GetHeight()); - + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); // 创建 draglistener 实例并设置为拖动监听器 UIView::OnDragListener *draglistener = static_cast(TraingRecordPresenter::GetInstance()); if (draglistener == nullptr) @@ -126,10 +189,12 @@ namespace OHOS return; } container_->SetOnDragListener(draglistener); - container_->SetTouchable(true); container_->SetDraggable(true); + container_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); + container_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + ShowLackView(); PreLoad(); RootView::GetInstance()->Add(container_); } diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Norecord.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Norecord.bin new file mode 100644 index 000000000..efc960e12 Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Norecord.bin differ diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Walking_54.bin b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Walking_54.bin new file mode 100644 index 000000000..0c977057b Binary files /dev/null and b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/Training/modules/Walking_54.bin differ