From: Caisking <3449750381@qq.com> Date: Fri, 15 Dec 2023 03:06:04 +0000 (+0800) Subject: 增加GPS断开提醒;GPS回连提醒;训练目标达成提醒;训练时间过短结束提醒 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=41855c145fc67b9aec258491aa8156a7009a5a9c;p=mirrors%2FFD230.git 增加GPS断开提醒;GPS回连提醒;训练目标达成提醒;训练时间过短结束提醒 --- diff --git a/Resource/res/Training/back.bin b/Resource/res/Training/back.bin new file mode 100644 index 000000000..489261160 Binary files /dev/null and b/Resource/res/Training/back.bin differ diff --git a/Resource/res/Training/win.bin b/Resource/res/Training/win.bin new file mode 100644 index 000000000..4ed2da99c Binary files /dev/null and b/Resource/res/Training/win.bin differ diff --git a/code/sdk/application/wearable/nativeapp/CMakeLists.txt b/code/sdk/application/wearable/nativeapp/CMakeLists.txt index de4b55d9f..a68039842 100755 --- a/code/sdk/application/wearable/nativeapp/CMakeLists.txt +++ b/code/sdk/application/wearable/nativeapp/CMakeLists.txt @@ -272,6 +272,8 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingDetailPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEndnoteView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEndnotePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEndnote2View.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEndnote2Presenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEnddataView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingEnddataPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSView.cpp @@ -282,6 +284,12 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSnotePresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingStrongView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingStrongPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSlostPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSlostView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSbackPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingGPSbackView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingWinView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/src/TraingWinPresenter.cpp #ָ���� ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/compass/src/CompassControlView.cpp diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h index c382a1124..bdca4b662 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/AppViewIDs.h @@ -44,23 +44,23 @@ typedef enum : uint16_t VIEW_MAIN_TEMP, VIEW_INDOORWALK, VIEW_REBOOT, - VIEW_UISAMPLE, // 实例 - VIEW_GETPIC, // 手势拍照 - VIEW_TAKEPIC, // 拍照 + VIEW_UISAMPLE, // 实例 + VIEW_GETPIC, // 手势拍照 + VIEW_TAKEPIC, // 拍照 - VIEW_BLOOD, // 血氧 - VIEW_BLOODSHOW, // 血氧说明 - VIEW_BLOODCHECK, // 血氧检查 - VIEW_BLOODERROR, // 血氧监测错误 - VIEW_BLOODNOTE, // 血氧过低提醒 + VIEW_BLOOD, // 血氧 + VIEW_BLOODSHOW, // 血氧说明 + VIEW_BLOODCHECK, // 血氧检查 + VIEW_BLOODERROR, // 血氧监测错误 + VIEW_BLOODNOTE, // 血氧过低提醒 - VIEW_DIAL, // 表盘 - VIEW_DIALSETUP, // 表盘安装 - VIEW_DIALSUCCES, // 表盘安装成功 + VIEW_DIAL, // 表盘 + VIEW_DIALSETUP, // 表盘安装 + VIEW_DIALSUCCES, // 表盘安装成功 + + VIEW_SAVEELE, // 省电模式 + VIEW_SAVEBAT, // 省电模式界面 - VIEW_SAVEELE, // 省电模式 - VIEW_SAVEBAT, // 省电模式界面 - VIEW_COMPASS, // 指南针 VIEW_COMPASS_PLACE_MAKER, // 指南针:放置标记点 VIEW_COMPASS_MAKER_POINT, // 指南针:标记点介绍 @@ -74,60 +74,65 @@ typedef enum : uint16_t VIEW_COMPASS_END_BACK_TRACKING_EARLY, // 指南针:提前结束路径回溯 VIEW_SPORT, // 活动 - VIEW_HEARTRATEREMIND, // 心率提醒 + VIEW_HEARTRATEREMIND, // 心率提醒 - VIEW_TRAINING, // 训练 - VIEW_TRAININGMORE, // 更多训练 - VIEW_TRAININGLIMIT, // 极限运动子列表 - VIEW_TRAININGNOMAL, // 正常训练开始界面(除骑行,健走,跑步外) - VIEW_TRAININGSET, // 训练目标(时长,卡路里) - VIEW_TRAININGGPSSET, // GPS训练目标(时长,距离,卡路里,步数) - VIEW_TRAININGSETTIME, // 设置训练时长 - VIEW_TRAININGSETCALULI, // 设置训练卡路里 - VIEW_TRAININGSETDIST, // 设置训练路程 - VIEW_TRAININGSETSTEP, // 设置训练步数 - VIEW_TRAININGCRAD, // 训练卡片 - VIEW_TRAININGCONTROL, // 训练控制(包括结束,暂停,继续训练) - VIEW_TRAININGDATA, // 训练数据 - VIEW_TRAININGDETAIL, // 详细训练数据 - VIEW_TRAININGENDNOTE, // 结束训练提醒 - VIEW_TRAININGENDDATA, // 训练结束详细数据 - VIEW_TRAININGGPS, // GPS训练 - VIEW_TRAININGGPSLACK, // 缺少GPS - VIEW_TRAININGGPSNOTE, // 连接GPS提醒 - VIEW_TRAININGSTRONG, // 训练强度介绍 - - VIEW_TRAINING_RECORD, // 训练记录 - - VIEW_BLOODPRESSURE, // 昨日睡眠时间 - VIEW_SLEEPTIME, // 睡眠详细数据 - VIEW_SLEEPACT, // 睡眠事项说明 - VIEW_MUSIC, // 音乐 - VIEW_WEATHER, // 天气 - VIEW_WEATHER_REPORT, // 气象报告 - VIEW_FUTURE_WEATHER, // 未来天气 - VIEW_GET_WEATHER_DATA_ERROR, // 获取天气数据失败 - VIEW_RECORD, // 录音 + VIEW_TRAINING, // 训练 + VIEW_TRAININGMORE, // 更多训练 + VIEW_TRAININGLIMIT, // 极限运动子列表 + VIEW_TRAININGNOMAL, // 正常训练开始界面(除骑行,健走,跑步外) + VIEW_TRAININGSET, // 训练目标(时长,卡路里) + VIEW_TRAININGGPSSET, // GPS训练目标(时长,距离,卡路里,步数) + VIEW_TRAININGSETTIME, // 设置训练时长 + VIEW_TRAININGSETCALULI, // 设置训练卡路里 + VIEW_TRAININGSETDIST, // 设置训练路程 + VIEW_TRAININGSETSTEP, // 设置训练步数 + VIEW_TRAININGCRAD, // 训练卡片 + VIEW_TRAININGCONTROL, // 训练控制(包括结束,暂停,继续训练) + VIEW_TRAININGDATA, // 训练数据 + VIEW_TRAININGDETAIL, // 详细训练数据 + VIEW_TRAININGENDNOTE, // 结束训练提醒 + VIEW_TRAININGENDNOTE2, // 结束训练时间太短 + VIEW_TRAININGENDDATA, // 训练结束详细数据 + VIEW_TRAININGGPS, // GPS训练 + VIEW_TRAININGGPSLACK, // 缺少GPS + VIEW_TRAININGGPSNOTE, // 连接GPS提醒 + VIEW_TRAININGSTRONG, // 训练强度介绍 + VIEW_TRAININGGPSLOST, // GPS断联 + VIEW_TRAININGGPSBACK, // GPS回连 + VIEW_TRAININGWIN, // 目标达成 + + VIEW_TRAINING_RECORD, // 训练记录 + + VIEW_BLOODPRESSURE, // 昨日睡眠时间 + VIEW_SLEEPTIME, // 睡眠详细数据 + VIEW_SLEEPACT, // 睡眠事项说明 + VIEW_MUSIC, // 音乐 + VIEW_WEATHER, // 天气 + VIEW_WEATHER_REPORT, // 气象报告 + VIEW_FUTURE_WEATHER, // 未来天气 + VIEW_GET_WEATHER_DATA_ERROR, // 获取天气数据失败 + VIEW_RECORD, // 录音 // 录音 VIEW_RECORD_LIST, VIEW_RECORD_PLAY, VIEW_RECORD_DELETE, VIEW_RECORD_GOING, // 电话 - VIEW_PHONE, // 电话 - VIEW_PHONECALL, // 拨号 - VIEW_PHONERING, // 拨号界面 - VIEW_PHONECALLING, // 来电 - VIEW_PHONECALLUP, // 通话界面 - VIEW_PHONEDIR, // 电话簿 - VIEW_MAIN_STOPWATCH,// 秒表主视图 - VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT, //秒表记录圈速到达上限 - VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT, //秒表记录时间到达上限 - VIEW_MAIN_COUNTDOWN,// 倒计时主视图 - VIEW_COUNTDOWN_TIME_CONFIG,//倒计时时间配置 - VIEW_START_COUNTDOWN,//开始倒计时 - VIEW_COUNTDOWN_TIME_NOT_NULL,//倒计时时间不能为0 - VIEW_BLUETOOTH, // 蓝牙 + VIEW_PHONE, // 电话 + VIEW_PHONECALL, // 拨号 + VIEW_PHONERING, // 拨号界面 + VIEW_PHONECALLING, // 来电 + VIEW_PHONECALLUP, // 通话界面 + VIEW_PHONEDIR, // 电话簿 + + VIEW_MAIN_STOPWATCH, // 秒表主视图 + VIEW_STOPWATCH_RECORD_CYCLE_TO_LIMIT, // 秒表记录圈速到达上限 + VIEW_STOPWATCH_RECORD_TIME_TO_LIMIT, // 秒表记录时间到达上限 + VIEW_MAIN_COUNTDOWN, // 倒计时主视图 + VIEW_COUNTDOWN_TIME_CONFIG, // 倒计时时间配置 + VIEW_START_COUNTDOWN, // 开始倒计时 + VIEW_COUNTDOWN_TIME_NOT_NULL, // 倒计时时间不能为0 + VIEW_BLUETOOTH, // 蓝牙 // 设置 VIEW_DISPLAY_BRIGHTNESS, // 屏幕与亮度 VIEW_CONNECT_BLUETOOTH, // 蓝牙 @@ -135,7 +140,7 @@ typedef enum : uint16_t VIEW_SYSTEM_VOLUME, // 系统音量 VIEW_CALL_VOLUME, // 通话音量 VIEW_MEDIA_VOLUME, // 媒体音量 - VIEW_SECONDARY_FUNCTION, //辅助功能 + VIEW_SECONDARY_FUNCTION, // 辅助功能 VIEW_SYSTEM, // 系统 // 系统 VIEW_SYSTEM_ABOUT_WATCH, // 系统:关于手表 @@ -146,12 +151,12 @@ typedef enum : uint16_t VIEW_SYSTEM_FACTORY_RESET, // 系统:恢复出厂设置 VIEW_BRIGHTNESS_CONTROL, // 亮度调节 VIEW_SCREEN_DURATION, // 亮屏时长 - //按键按下进入的视图 - VIEW_QUICK_ACCESS, // 快速访问 - VIEW_FAST_TRAINING, //快速训练 - VIEW_FAST_TRAINING_ATTENTION,//快速训练项目选择超出提示 - VIEW_MAX_INTER_APP, // 在此之前添加native应用ID - VIEW_EXTERN_APP = 0xFFFE, // 三方应用 + // 按键按下进入的视图 + VIEW_QUICK_ACCESS, // 快速访问 + VIEW_FAST_TRAINING, // 快速训练 + VIEW_FAST_TRAINING_ATTENTION, // 快速训练项目选择超出提示 + VIEW_MAX_INTER_APP, // 在此之前添加native应用ID + VIEW_EXTERN_APP = 0xFFFE, // 三方应用 VIEW_INVALIDE_APP = 0xFFFF, } AppViewId; diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h index 642d43c53..25a9e0d90 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/include/NativeLauncher.h @@ -78,10 +78,14 @@ public: void InitTraingDataSlice(void); void InitTraingDetailSlice(void); void InitTraingEndnoteSlice(void); + void InitTraingEndnote2Slice(void); void InitTraingEnddataSlice(void); void InitTraingGPSSlice(void); void InitTraingGPSlackSlice(void); void InitTraingGPSnoteSlice(void); + void InitTraingGPSlostSlice(void); + void InitTraingGPSbackSlice(void); + void InitTraingWinSlice(void); void InitUIDisplayBrightnessSlice(void); void InitBlueToothSettingSlice(void); void InitBrightnessControlSlice(void); diff --git a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp index d80655c47..0f4007c02 100755 --- a/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/nativeapp/nativelauncher/src/NativeLauncher.cpp @@ -131,6 +131,8 @@ #include "traing/include/TraingDetailView.h" #include "traing/include/TraingEndnotePresenter.h" #include "traing/include/TraingEndnoteView.h" +#include "traing/include/TraingEndnote2Presenter.h" +#include "traing/include/TraingEndnote2View.h" #include "traing/include/TraingEnddataPresenter.h" #include "traing/include/TraingEnddataView.h" #include "traing/include/TraingGPSPresenter.h" @@ -141,6 +143,12 @@ #include "traing/include/TraingGPSnoteView.h" #include "traing/include/TraingStrongPresenter.h" #include "traing/include/TraingStrongView.h" +#include "traing/include/TraingGPSlostPresenter.h" +#include "traing/include/TraingGPSlostView.h" +#include "traing/include/TraingGPSbackPresenter.h" +#include "traing/include/TraingGPSbackView.h" +#include "traing/include/TraingWinPresenter.h" +#include "traing/include/TraingWinView.h" #include "displaybrightness/include/DisplayBrightnessPresenter.h" #include "displaybrightness/include/DisplayBrightnessView.h" #include "bluetoothofsetting/include/BlueToothOfSettingPresenter.h" @@ -299,11 +307,15 @@ static const AppViewMapper SLICE_MAPPER[] = { {VIEW_TRAININGDATA, &NativeLauncher::InitTraingDataSlice}, //训练数据 {VIEW_TRAININGDETAIL, &NativeLauncher::InitTraingDetailSlice}, //详细训练数据 {VIEW_TRAININGENDNOTE, &NativeLauncher::InitTraingEndnoteSlice}, //训练结束提醒 + {VIEW_TRAININGENDNOTE2, &NativeLauncher::InitTraingEndnote2Slice}, //训练结束时间太短提醒 {VIEW_TRAININGENDDATA, &NativeLauncher::InitTraingEnddataSlice}, //训练结束详细数据 {VIEW_TRAININGGPS, &NativeLauncher::InitTraingGPSSlice}, //GPS训练 {VIEW_TRAININGGPSLACK, &NativeLauncher::InitTraingGPSlackSlice}, //GPS缺少 {VIEW_TRAININGGPSNOTE, &NativeLauncher::InitTraingGPSnoteSlice}, //提醒连接GPS - {VIEW_TRAININGSTRONG, &NativeLauncher::InitTraingStrongSlice}, //训练强度介绍 + {VIEW_TRAININGSTRONG, &NativeLauncher::InitTraingStrongSlice}, //训练强度介绍 + {VIEW_TRAININGGPSLOST, &NativeLauncher::InitTraingGPSlostSlice}, //GPS断联 + {VIEW_TRAININGGPSBACK, &NativeLauncher::InitTraingGPSbackSlice}, //GPS回连 + {VIEW_TRAININGWIN, &NativeLauncher::InitTraingWinSlice}, //训练目标达成 {VIEW_DISPLAY_BRIGHTNESS,&NativeLauncher::InitUIDisplayBrightnessSlice}, //显示与亮度的实例化地址 @@ -961,6 +973,11 @@ void NativeLauncher::InitTraingEndnoteSlice(void) SliceProxy *traingendnoteview = new AbilitySliceProxy; NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGENDNOTE, traingendnoteview); } +void NativeLauncher::InitTraingEndnote2Slice(void) +{ + SliceProxy *traingendnote2view = new AbilitySliceProxy; + NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGENDNOTE2, traingendnote2view); +} void NativeLauncher::InitTraingEnddataSlice(void) { SliceProxy *traingenddataview = new AbilitySliceProxy; @@ -986,6 +1003,21 @@ void NativeLauncher::InitTraingStrongSlice(void) SliceProxy *traingStrongview = new AbilitySliceProxy; NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGSTRONG, traingStrongview); } +void NativeLauncher::InitTraingGPSlostSlice(void) +{ + SliceProxy *traingGPSlostview = new AbilitySliceProxy; + NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGGPSLOST, traingGPSlostview); +} +void NativeLauncher::InitTraingGPSbackSlice(void) +{ + SliceProxy *traingGPSbackview = new AbilitySliceProxy; + NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGGPSBACK, traingGPSbackview); +} +void NativeLauncher::InitTraingWinSlice(void) +{ + SliceProxy *traingwinview = new AbilitySliceProxy; + NativeAbility::GetInstance().AddSliceProxy(VIEW_TRAININGWIN, traingwinview); +} //DisplayBrightness的实例化 void NativeLauncher::InitUIDisplayBrightnessSlice(void) { diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingEndnote2Presenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingEndnote2Presenter.h new file mode 100644 index 000000000..4b4ef7bff --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingEndnote2Presenter.h @@ -0,0 +1,32 @@ +#ifndef _TraingEndnote2_PRESENTER_H +#define _TraingEndnote2_PRESENTER_H + +#include "Presenter.h" +#include "TraingEndnote2View.h" + +namespace OHOS +{ + class TraingEndnote2View; + + class TraingEndnote2Presenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + TraingEndnote2Presenter(); + virtual ~TraingEndnote2Presenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + static TraingEndnote2Presenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingEndnote2View.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingEndnote2View.h new file mode 100644 index 000000000..baee7a423 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingEndnote2View.h @@ -0,0 +1,66 @@ +#ifndef _TraingEndnote2_VIEW_H +#define _TraingEndnote2_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.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 "TraingEndnote2Presenter.h" +namespace OHOS +{ +#define BUTTONNO "button1" +#define BUTTONYES "button2" + + class TraingEndnote2Presenter; + class TraingEndnote2View : public View + { + + public: + TraingEndnote2View(); + virtual ~TraingEndnote2View(); + static TraingEndnote2View *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + 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(); + + private: + UIView::OnDragListener *draglistener{nullptr}; + TraingEndnote2View(TraingEndnote2View &&) = delete; + TraingEndnote2View &operator=(TraingEndnote2View &&) = delete; + + UIViewGroup *container_ = nullptr; + + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + + UIButton *button1_ = nullptr; + UIButton *button2_ = nullptr; + bool viewiInitStatus{false}; + }; +} // namespace OHOS +#endif // TraingEndnote2_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSbackPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSbackPresenter.h new file mode 100644 index 000000000..306df225a --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSbackPresenter.h @@ -0,0 +1,33 @@ +#ifndef _TraingGPSback_PRESENTER_H +#define _TraingGPSback_PRESENTER_H + +#include "Presenter.h" +#include "TraingGPSbackView.h" + +namespace OHOS +{ + class TraingGPSbackView; + + class TraingGPSbackPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + TraingGPSbackPresenter(); + virtual ~TraingGPSbackPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static TraingGPSbackPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSbackView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSbackView.h new file mode 100644 index 000000000..cf28aa9a8 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSbackView.h @@ -0,0 +1,59 @@ +#ifndef _TraingGPSback_VIEW_H +#define _TraingGPSback_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.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 "TraingGPSbackPresenter.h" +namespace OHOS +{ +#define BUTTONOK "button1" + + + class TraingGPSbackPresenter; + class TraingGPSbackView : public View + { + + public: + TraingGPSbackView(); + virtual ~TraingGPSbackView(); + static TraingGPSbackView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + 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}; + TraingGPSbackView(TraingGPSbackView &&) = delete; + TraingGPSbackView &operator=(TraingGPSbackView &&) = delete; + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UIButton *button1_ = nullptr; + UIImageView *image1_ = nullptr; + bool viewiInitStatus{false}; + }; +} // namespace OHOS +#endif // TraingGPSback_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSlostPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSlostPresenter.h new file mode 100644 index 000000000..c757e23cb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSlostPresenter.h @@ -0,0 +1,33 @@ +#ifndef _TraingGPSlost_PRESENTER_H +#define _TraingGPSlost_PRESENTER_H + +#include "Presenter.h" +#include "TraingGPSlostView.h" + +namespace OHOS +{ + class TraingGPSlostView; + + class TraingGPSlostPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + TraingGPSlostPresenter(); + virtual ~TraingGPSlostPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static TraingGPSlostPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSlostView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSlostView.h new file mode 100644 index 000000000..d61e398eb --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingGPSlostView.h @@ -0,0 +1,59 @@ +#ifndef _TraingGPSlost_VIEW_H +#define _TraingGPSlost_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.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 "TraingGPSlostPresenter.h" +namespace OHOS +{ +#define BUTTONOK "button1" + + + class TraingGPSlostPresenter; + class TraingGPSlostView : public View + { + + public: + TraingGPSlostView(); + virtual ~TraingGPSlostView(); + static TraingGPSlostView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + 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}; + TraingGPSlostView(TraingGPSlostView &&) = delete; + TraingGPSlostView &operator=(TraingGPSlostView &&) = delete; + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UIButton *button1_ = nullptr; + UIImageView *image1_ = nullptr; + bool viewiInitStatus{false}; + }; +} // namespace OHOS +#endif // TraingGPSlost_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingWinPresenter.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingWinPresenter.h new file mode 100644 index 000000000..a034c77fa --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingWinPresenter.h @@ -0,0 +1,33 @@ +#ifndef _TraingWin_PRESENTER_H +#define _TraingWin_PRESENTER_H + +#include "Presenter.h" +#include "TraingWinView.h" + +namespace OHOS +{ + class TraingWinView; + + class TraingWinPresenter : public Presenter, + public UIView::OnClickListener, + public UIView::OnDragListener + { + public: + TraingWinPresenter(); + virtual ~TraingWinPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static TraingWinPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + }; +} // namespace OHOS + +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingWinView.h b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingWinView.h new file mode 100644 index 000000000..f832ed1b2 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/include/TraingWinView.h @@ -0,0 +1,60 @@ +#ifndef _TraingWin_VIEW_H +#define _TraingWin_VIEW_H + +#include "BaseView.h" +#include "View.h" +#include +#include "components/ui_view_group.h" +#include "components/ui_label.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 "TraingWinPresenter.h" +namespace OHOS +{ +#define BUTTONOK "button1" + + class TraingWinPresenter; + class TraingWinView : public View + { + + public: + TraingWinView(); + virtual ~TraingWinView(); + static TraingWinView *GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + 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}; + TraingWinView(TraingWinView &&) = delete; + TraingWinView &operator=(TraingWinView &&) = delete; + UIViewGroup *container_ = nullptr; + UILabel *label1_ = nullptr; + UILabel *label2_ = nullptr; + UILabel *label3_ = nullptr; + UILabel *label4_ = nullptr; + UIButton *button1_ = nullptr; + UIImageView *image1_ = nullptr; + bool viewiInitStatus{false}; + }; +} // namespace OHOS +#endif // TraingWin_PRESENTER_H diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingControlPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingControlPresenter.cpp index f6e3394c9..a499f437d 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingControlPresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingControlPresenter.cpp @@ -71,7 +71,16 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), BUTTONSTOP) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDNOTE); + // 模拟训练 + int random = rand() % 100; // 生成一个0~99的随机数 + if (random < 70) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDNOTE2); + } + else + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDNOTE); + } } printf("********* test:%s\n", test.c_str()); diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2Presenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2Presenter.cpp new file mode 100644 index 000000000..7fd64f605 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2Presenter.cpp @@ -0,0 +1,83 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include +#include +#include +#include "traing/include/TraingEndnote2Presenter.h" +// #include "TraingEndnote2View.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static TraingEndnote2Presenter *g_pTraingEndnote2Presenter = nullptr; + + TraingEndnote2Presenter::TraingEndnote2Presenter() + { + + g_pTraingEndnote2Presenter = this; + } + + TraingEndnote2Presenter::~TraingEndnote2Presenter() + { + + g_pTraingEndnote2Presenter = nullptr; + } + + TraingEndnote2Presenter *TraingEndnote2Presenter::GetInstance() + { + + return g_pTraingEndnote2Presenter; + } + + void TraingEndnote2Presenter::OnStart() + { + + Presenter::OnStart(); + } + + void TraingEndnote2Presenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void TraingEndnote2Presenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void TraingEndnote2Presenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool TraingEndnote2Presenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGDATA); + // } + UNUSED(view); + return true; + } + + bool TraingEndnote2Presenter::OnClick(UIView &view, const ClickEvent &event) + { + + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), BUTTONNO) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL); + } + if (strcmp(view.GetViewId(), BUTTONYES) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAINING); + } + return true; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2View.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2View.cpp new file mode 100644 index 000000000..07a3a471c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnote2View.cpp @@ -0,0 +1,225 @@ + +#include "traing/include/TraingEndnote2View.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static const char *imagePath_no = "/user/res/Training/no.bin"; + static const char *imagePath_yes = "/user/res/Training/yes.bin"; + + static TraingEndnote2View *g_pTraingEndnote2View{nullptr}; + + TraingEndnote2View::TraingEndnote2View() + { + g_pTraingEndnote2View = this; + } + + TraingEndnote2View::~TraingEndnote2View() + { + DeInit(); + g_pTraingEndnote2View = nullptr; + } + + TraingEndnote2View *TraingEndnote2View::GetInstance() + { + + 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() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // 初始化Lable + InitLabel(label1_, 173, 52, 90, 35, "label1", "注意", DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabel(label2_, 116, 187, 60, 40, "label2", "当前运动量太小,无法记录\n是否结束运动", DEFAULT_VECTOR_FONT_FILENAME, 30); + + container_->Add(label1_); + container_->Add(label2_); + + InitButton(button1_, 111, 299, 100, 100, BUTTONNO); + // Set additional property + const char *button1defaultImgSrc = imagePath_no; + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + + InitButton(button2_, 256, 299, 100, 100, BUTTONYES); + // Set additional property + const char *button2defaultImgSrc = imagePath_yes; + char *button2triggeredImgSrc = nullptr; + button2_->SetImageSrc(button2defaultImgSrc, button2triggeredImgSrc); + + container_->Add(button1_); + container_->Add(button2_); + } + + /* DeInit:删除组件 */ + void TraingEndnote2View::DeInit() + { + UIView *view = static_cast(container_)->GetChildrenHead(); + while (view != nullptr) + { + UIView *tempView = view; + view = view->GetNextSibling(); + if (tempView->GetParent()) + { + static_cast(tempView->GetParent())->Remove(tempView); + } + delete tempView; + } + delete container_; + container_ = nullptr; + } + + void TraingEndnote2View::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + void TraingEndnote2View::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(TraingEndnote2Presenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void TraingEndnote2View::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void TraingEndnote2View::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void TraingEndnote2View::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnotePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnotePresenter.cpp index 2c4920bc0..80c7f151d 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnotePresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingEndnotePresenter.cpp @@ -76,7 +76,7 @@ namespace OHOS } if (strcmp(view.GetViewId(), BUTTONYES) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGWIN); } return true; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSbackPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSbackPresenter.cpp new file mode 100644 index 000000000..06be1922c --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSbackPresenter.cpp @@ -0,0 +1,80 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include +#include +#include +#include "traing/include/TraingGPSbackPresenter.h" +// #include "TraingGPSbackView.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static TraingGPSbackPresenter *g_pTraingGPSbackPresenter = nullptr; + + TraingGPSbackPresenter::TraingGPSbackPresenter() + { + + g_pTraingGPSbackPresenter = this; + } + + TraingGPSbackPresenter::~TraingGPSbackPresenter() + { + + g_pTraingGPSbackPresenter = nullptr; + } + + TraingGPSbackPresenter *TraingGPSbackPresenter::GetInstance() + { + + return g_pTraingGPSbackPresenter; + } + + void TraingGPSbackPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void TraingGPSbackPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void TraingGPSbackPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void TraingGPSbackPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool TraingGPSbackPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + // (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + // { + // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + // NativeAbility::GetInstance().ChangeSlice(preSlice); + // } + UNUSED(view); + return true; + } + + bool TraingGPSbackPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), BUTTONOK) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL); + } + return true; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSbackView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSbackView.cpp new file mode 100644 index 000000000..2244133b6 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSbackView.cpp @@ -0,0 +1,220 @@ + +#include "traing/include/TraingGPSbackView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static const char *imagePath_warning = "/user/res/Training/back.bin"; + static TraingGPSbackView *g_pTraingGPSbackView{nullptr}; + + TraingGPSbackView::TraingGPSbackView() + { + g_pTraingGPSbackView = this; + } + + TraingGPSbackView::~TraingGPSbackView() + { + DeInit(); + g_pTraingGPSbackView = nullptr; + } + + TraingGPSbackView *TraingGPSbackView::GetInstance() + { + + 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() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // 初始化Lable + InitLabel(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); + container_->Add(label2_); + + // 初始化image + InitImageView(image1_, 193, 140, 40, 40, "image1", imagePath_warning); + container_->Add(image1_); + + // 初始化Button + InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + // Set additional property + char *button1defaultImgSrc = "/user/res/Training/buttonok.bin"; + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + container_->Add(button1_); + + } + /* DeInit:删除组件*/ + void TraingGPSbackView::DeInit() + { + UIView *view = static_cast(container_)->GetChildrenHead(); + while (view != nullptr) + { + UIView *tempView = view; + view = view->GetNextSibling(); + if (tempView->GetParent()) + { + static_cast(tempView->GetParent())->Remove(tempView); + } + delete tempView; + } + delete container_; + container_ = nullptr; + } + + void TraingGPSbackView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + void TraingGPSbackView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(TraingGPSbackPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void TraingGPSbackView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void TraingGPSbackView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void TraingGPSbackView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlostPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlostPresenter.cpp new file mode 100644 index 000000000..1f895c790 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlostPresenter.cpp @@ -0,0 +1,80 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include +#include +#include +#include "traing/include/TraingGPSlostPresenter.h" +// #include "TraingGPSlostView.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static TraingGPSlostPresenter *g_pTraingGPSlostPresenter = nullptr; + + TraingGPSlostPresenter::TraingGPSlostPresenter() + { + + g_pTraingGPSlostPresenter = this; + } + + TraingGPSlostPresenter::~TraingGPSlostPresenter() + { + + g_pTraingGPSlostPresenter = nullptr; + } + + TraingGPSlostPresenter *TraingGPSlostPresenter::GetInstance() + { + + return g_pTraingGPSlostPresenter; + } + + void TraingGPSlostPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void TraingGPSlostPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void TraingGPSlostPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void TraingGPSlostPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool TraingGPSlostPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + // (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + // { + // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + // NativeAbility::GetInstance().ChangeSlice(preSlice); + // } + UNUSED(view); + return true; + } + + bool TraingGPSlostPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), BUTTONOK) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSBACK); + } + return true; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlostView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlostView.cpp new file mode 100644 index 000000000..aa275c63d --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSlostView.cpp @@ -0,0 +1,220 @@ + +#include "traing/include/TraingGPSlostView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static const char *imagePath_warning = "/user/res/Training/warning.bin"; + static TraingGPSlostView *g_pTraingGPSlostView{nullptr}; + + TraingGPSlostView::TraingGPSlostView() + { + g_pTraingGPSlostView = this; + } + + TraingGPSlostView::~TraingGPSlostView() + { + DeInit(); + g_pTraingGPSlostView = nullptr; + } + + TraingGPSlostView *TraingGPSlostView::GetInstance() + { + + 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() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // 初始化Lable + InitLabel(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); + container_->Add(label2_); + + // 初始化image + InitImageView(image1_, 193, 140, 40, 40, "image1", imagePath_warning); + container_->Add(image1_); + + // 初始化Button + InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + // Set additional property + char *button1defaultImgSrc = "/user/res/Training/buttonok.bin"; + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + container_->Add(button1_); + + } + /* DeInit:删除组件*/ + void TraingGPSlostView::DeInit() + { + UIView *view = static_cast(container_)->GetChildrenHead(); + while (view != nullptr) + { + UIView *tempView = view; + view = view->GetNextSibling(); + if (tempView->GetParent()) + { + static_cast(tempView->GetParent())->Remove(tempView); + } + delete tempView; + } + delete container_; + container_ = nullptr; + } + + void TraingGPSlostView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + void TraingGPSlostView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(TraingGPSlostPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void TraingGPSlostView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void TraingGPSlostView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void TraingGPSlostView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnotePresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnotePresenter.cpp index 26d705b6f..dc9666373 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnotePresenter.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnotePresenter.cpp @@ -73,11 +73,11 @@ namespace OHOS // 根据控件id查找是哪个控件触发了点击回调 if (strcmp(view.GetViewId(), BUTTONBACK) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPS); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSLACK); } if (strcmp(view.GetViewId(), BUTTONGO) == 0) { - NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGCONTROL); + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGGPSLOST); } return true; } diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnoteView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnoteView.cpp index 4be1e949a..34c4f75fa 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnoteView.cpp +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingGPSnoteView.cpp @@ -152,7 +152,7 @@ namespace OHOS button1_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff4fc34c); scrollView1_->Add(button1_); - InitButton(button2_, 118, 434, 230, 80, BUTTONBACK); + InitButton(button2_, 118, 434, 230, 80, BUTTONGO); scrollView1_->Add(button2_); // 初始化Lable diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingWinPresenter.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingWinPresenter.cpp new file mode 100644 index 000000000..20cd235b0 --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingWinPresenter.cpp @@ -0,0 +1,80 @@ +#include "AppViewIDs.h" +#include "NativeAbility.h" + +#include +#include +#include +#include "traing/include/TraingWinPresenter.h" +// #include "TraingWinView.h" + +namespace OHOS +{ + + // 当前Presenter属性实例化的内存指针 + static TraingWinPresenter *g_pTraingWinPresenter = nullptr; + + TraingWinPresenter::TraingWinPresenter() + { + + g_pTraingWinPresenter = this; + } + + TraingWinPresenter::~TraingWinPresenter() + { + + g_pTraingWinPresenter = nullptr; + } + + TraingWinPresenter *TraingWinPresenter::GetInstance() + { + + return g_pTraingWinPresenter; + } + + void TraingWinPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void TraingWinPresenter::OnPause(void) + { + + Presenter::OnPause(); + } + + void TraingWinPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void TraingWinPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + bool TraingWinPresenter::OnDrag(UIView &view, const DragEvent &event) + { + + // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && + // (event.GetDeltaX() > 40) && (event.GetDeltaX() > (2 * MATH_ABS(event.GetDeltaY())))) + // { + // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + // NativeAbility::GetInstance().ChangeSlice(preSlice); + // } + UNUSED(view); + return true; + } + + bool TraingWinPresenter::OnClick(UIView &view, const ClickEvent &event) + { + // 根据控件id查找是哪个控件触发了点击回调 + if (strcmp(view.GetViewId(), BUTTONOK) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA); + } + return true; + } +} diff --git a/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingWinView.cpp b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingWinView.cpp new file mode 100644 index 000000000..b1cf9094f --- /dev/null +++ b/code/sdk/application/wearable/nativeapp/nativeui/traing/src/TraingWinView.cpp @@ -0,0 +1,225 @@ + +#include "traing/include/TraingWinView.h" + +#include "common/image_cache_manager.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +namespace OHOS +{ + static const char *imagePath_win = "/user/res/Training/win.bin"; + static TraingWinView *g_pTraingWinView{nullptr}; + + TraingWinView::TraingWinView() + { + g_pTraingWinView = this; + } + + TraingWinView::~TraingWinView() + { + DeInit(); + g_pTraingWinView = nullptr; + } + + TraingWinView *TraingWinView::GetInstance() + { + + return g_pTraingWinView; + } + /* + 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); + } + /* + InitImageView:初始化图片 + @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); + } + + /* InitView:初始化界面*/ + void TraingWinView ::InitView() + { + if (container_ == nullptr) + { + container_ = new UIViewGroup(); + container_->SetPosition(0, 0, 466, 466); + container_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + // 初始化Lable + InitLabel(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); + label2_->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + container_->Add(label2_); + InitLabel(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); + label4_->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x7f)); + container_->Add(label4_); + + // 初始化image + InitImageView(image1_, 173, 100, 120, 120, "image1", imagePath_win); + container_->Add(image1_); + + // 初始化Button + InitButton(button1_, 0, 366, 466, 100, BUTTONOK); + // Set additional property + char *button1defaultImgSrc = "/user/res/Training/buttonok.bin"; + char *button1triggeredImgSrc = nullptr; + button1_->SetImageSrc(button1defaultImgSrc, button1triggeredImgSrc); + container_->Add(button1_); + } + /* DeInit:删除组件*/ + void TraingWinView::DeInit() + { + UIView *view = static_cast(container_)->GetChildrenHead(); + while (view != nullptr) + { + UIView *tempView = view; + view = view->GetNextSibling(); + if (tempView->GetParent()) + { + static_cast(tempView->GetParent())->Remove(tempView); + } + delete tempView; + } + delete container_; + container_ = nullptr; + } + + void TraingWinView::PreLoad(void) + { + if (!viewiInitStatus) + { + InitView(); + viewiInitStatus = true; + } + } + void TraingWinView::OnStart() + { + container_ = new UIViewGroup(); + if (container_ == nullptr) + { + return; + } + container_->SetPosition(0, 0); + container_->SetWidth(Screen::GetInstance().GetWidth()); + container_->SetHeight(Screen::GetInstance().GetHeight()); + + // 创建 draglistener 实例并设置为拖动监听器 + UIView::OnDragListener *draglistener = static_cast(TraingWinPresenter::GetInstance()); + if (draglistener == nullptr) + { + return; + } + container_->SetOnDragListener(draglistener); + + container_->SetTouchable(true); + container_->SetDraggable(true); + + PreLoad(); + RootView::GetInstance()->Add(container_); + } + + void TraingWinView::OnSetUpView() + { + + View::OnSetUpView(); + Draw(); + } + + void TraingWinView::OnTearDownView() + { + + View::OnTearDownView(); + return; + } + + void TraingWinView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; + } +}