From: Caisking <3449750381@qq.com> Date: Mon, 23 Sep 2024 12:54:49 +0000 (+0800) Subject: #446 运动界面,上下滑,下界面是覆盖式的,优化为U6那种滑动式界面 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=35c50d180d7892d3a275d45564c9f240c3a1de5d;p=mirrors%2FFD230.git #446 运动界面,上下滑,下界面是覆盖式的,优化为U6那种滑动式界面 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 849754813..7372ec01f 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -612,6 +612,7 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingControlView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingDataView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TrainingDetailView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traing/training_card/src/TraingDataAllView.cpp #训练记录 ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/traingrecord/src/TraingRecordView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h index 3837b511d..2fcb1eaad 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h +++ b/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h @@ -3,114 +3,127 @@ * @Date: 2024-03-01 15:10:34 * @LastEditors: luozheng 1732036298@qq.com * @LastEditTime: 2024-09-03 17:53:43 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/MainPresenterSample.h */ #ifndef MAIN_PRESENTER_SAMPLE_H #define MAIN_PRESENTER_SAMPLE_H -#include "Presenter.h" -#include "ModelListenerSample.h" -#include "components/root_view.h" +#include "HeartRateView.h" #include "KeyInputListener.h" -#include "drag_event.h" -#include "MainViewSample.h" +#include "MainCompassPresenter.h" +#include "MainCompassView.h" #include "MainModel.h" +#include "MainViewSample.h" +#include "ModelListenerSample.h" +#include "PlayersView.h" +#include "Presenter.h" +#include "components/root_view.h" #include "components/ui_swipe_view.h" #include "components/ui_view.h" -#include "MainCompassView.h" -#include "MainCompassPresenter.h" -#include "PlayersView.h" -#include "HeartRateView.h" +#include "drag_event.h" #include "swipe_effect/zoom_effect.h" -namespace OHOS -{ - static constexpr const char *MAIN_CLICK_WEATHER = "mainclickweather"; - static constexpr const char *MAIN_CLICK_ACTIVITY = "mainclickactivity"; - static constexpr const char *MAIN_CLICK_MESSAGE = "mainclickmessage"; - static constexpr const char *MAIN_CLICK_HEARTRATE = "mainclickheartrate"; - static constexpr const char *MAIN_CLICK_BLOOD = "mainclickblood"; // 血氧检测 - static constexpr const char *MAIN_CLICK_SETCARD = "mainclicksetcard"; // 设置卡片 +namespace OHOS { +static constexpr const char *MAIN_CLICK_WEATHER = "mainclickweather"; +static constexpr const char *MAIN_CLICK_ACTIVITY = "mainclickactivity"; +static constexpr const char *MAIN_CLICK_MESSAGE = "mainclickmessage"; +static constexpr const char *MAIN_CLICK_HEARTRATE = "mainclickheartrate"; +static constexpr const char *MAIN_CLICK_BLOOD = "mainclickblood"; // 血氧检测 +static constexpr const char *MAIN_CLICK_SETCARD = + "mainclicksetcard"; // 设置卡片 - static constexpr const char *DROPDOWN_CLICK_DONOTDISTURB = "dropdownclickdonotdisturb"; - static constexpr const char *DROPDOWN_CLICK_BRIGHTENSCREEN = "dropdownclickbrightscreen"; +static constexpr const char *DROPDOWN_CLICK_DONOTDISTURB = + "dropdownclickdonotdisturb"; +static constexpr const char *DROPDOWN_CLICK_BRIGHTENSCREEN = + "dropdownclickbrightscreen"; - static constexpr const char *DROPDOWN_CLICK_SETTING = "dropdownclicksetting"; // 设置 - static constexpr const char *DROPDOWN_CLICK_BLUETOOTH = "dropdownclickbluetooth"; // 蓝牙 - static constexpr const char *DROPDOWN_CLICK_DNOTDISTURB = "dropdownclickdnotdisturb"; // 勿扰 - static constexpr const char *DROPDOWN_CLICK_SAVEELE = "dropdownclicksaveele"; // 省电 - static constexpr const char *DROPDOWN_CLICK_FINDMYPHONE = "dropdownclickfindmyphone"; // 找手机 +static constexpr const char *DROPDOWN_CLICK_SETTING = + "dropdownclicksetting"; // 设置 +static constexpr const char *DROPDOWN_CLICK_BLUETOOTH = + "dropdownclickbluetooth"; // 蓝牙 +static constexpr const char *DROPDOWN_CLICK_DNOTDISTURB = + "dropdownclickdnotdisturb"; // 勿扰 +static constexpr const char *DROPDOWN_CLICK_SAVEELE = + "dropdownclicksaveele"; // 省电 +static constexpr const char *DROPDOWN_CLICK_FINDMYPHONE = + "dropdownclickfindmyphone"; // 找手机 - static constexpr const char *CONNECTEDSTATUSBACKGROUNDBUTTON = "connectedstatusbackgroundbutton"; // 连接状态按钮 - static constexpr const char *CONNECTEDSTATUSVIEWCLOSEBUTTON = "connectedstatusviewclosebutton"; // 连接状态视图的关闭按钮 +static constexpr const char *CONNECTEDSTATUSBACKGROUNDBUTTON = + "connectedstatusbackgroundbutton"; // 连接状态按钮 +static constexpr const char *CONNECTEDSTATUSVIEWCLOSEBUTTON = + "connectedstatusviewclosebutton"; // 连接状态视图的关闭按钮 - constexpr uint16_t VERTICAL_STATUS = 1; - constexpr uint16_t HORIZONTAL_STATUS = 0; +constexpr uint16_t VERTICAL_STATUS = 1; +constexpr uint16_t HORIZONTAL_STATUS = 0; - class MainViewSample; - class MainPresenterSample : public Presenter, public ModelListenerSample, public UIView::OnClickListener, public UIView::OnDragListener, public UISwipeView::OnSwipeListener, public UIView::OnLongPressListener, public UISwipeView, public CompassPresenter - { - public: - MainPresenterSample(); - ~MainPresenterSample() override; - static MainPresenterSample *GetInstance(void); +class MainViewSample; +class MainPresenterSample : public Presenter, + public ModelListenerSample, + public UIView::OnClickListener, + public UIView::OnDragListener, + public UISwipeView::OnSwipeListener, + public UIView::OnLongPressListener, + public UISwipeView, + public CompassPresenter { +public: + MainPresenterSample(); + ~MainPresenterSample() override; + static MainPresenterSample *GetInstance(void); - void OnStart() override; - void OnPause() override; - void OnResume() override; - void OnStop() override; - void Notify() override; - bool OnClick(UIView &view, const ClickEvent &event) override; - bool OnDrag(UIView &view, const DragEvent &event) override; - bool OnLongPress(UIView &view, const LongPressEvent &event) override; - void OnSwipe(UISwipeView &view) override; - void SetPage(int8_t id); - void SetTaskPeroid(CardId cardId); - void setCallback(ZoomEffect *callback) - { - callback_ = callback; - } + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + void Notify() override; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnLongPress(UIView &view, const LongPressEvent &event) override; + void OnSwipe(UISwipeView &view) override; + void SetPage(int8_t id); + void SetTaskPeroid(CardId cardId); + void setCallback(ZoomEffect *callback) { callback_ = callback; } - void InitCardSettings(void); - uint8_t GetCardSettingCount(void); - CardId *GetCardSettings(void); - void InitDialSettings(void); - DialSetting &GetDialSetting(); - void UpdataTime(); - uint32_t GetWeekStr(char *p_week); - void UpdataBaseData(); - void PullUpDown_StartTimer(uint32_t interval); - void PullUpDown_StopTimer(void); - static uint8_t g_PullUpDownTimes; + void InitCardSettings(void); + uint8_t GetCardSettingCount(void); + CardId *GetCardSettings(void); + void InitDialSettings(void); + DialSetting &GetDialSetting(); + void UpdataTime(); + uint32_t GetWeekStr(char *p_week); + void UpdataBaseData(); + void PullUpDown_StartTimer(uint32_t interval); + void PullUpDown_StopTimer(void); + static uint8_t g_PullUpDownTimes; - void get_memcheck(); + void get_memcheck(); - bool IsFromSetCardView(void) const; - void SetFromSetCardView(bool isFrom); - uint8_t GetFromCardId(void); + bool IsFromSetCardView(void) const; + void SetFromSetCardView(bool isFrom); + uint8_t GetFromCardId(void); - private: - void LogCardTransition(CardId previous, CardId current); - void ResetSleepCardView(); - void ResetWeatherCardView(); - void ResetgoalCardView(); - void StartHeartRateDetection(); - void UpdateWatchFace(); - void UpdateWeather(); - void Updategoal(); - void ProcessDataNotify(void); - void SetCircleProgress(void); - void SetCompassRotate(void); - KeyInputListener *keyActListener_{nullptr}; - ZoomEffect *callback_{nullptr}; - uint8_t state_ = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; - int64_t playerCurrentTime_{0}; - int64_t playerMusicDuration_{0}; - int64_t playerProgressValue_{0}; - bool isCompassSensorOpened_{false}; - CardId previousCardId{WATCH_FACE}; - }; +private: + void LogCardTransition(CardId previous, CardId current); + void ResetSleepCardView(); + void ResetWeatherCardView(); + void ResetgoalCardView(); + void StartHeartRateDetection(); + void UpdateWatchFace(); + void UpdateWeather(); + void Updategoal(); + void ProcessDataNotify(void); + void SetCircleProgress(void); + void SetCompassRotate(void); + KeyInputListener *keyActListener_{nullptr}; + ZoomEffect *callback_{nullptr}; + uint8_t state_ = UICheckBox::UICheckBoxState::MAX_STATUS_NUM; + int64_t playerCurrentTime_{0}; + int64_t playerMusicDuration_{0}; + int64_t playerProgressValue_{0}; + bool isCompassSensorOpened_{false}; + CardId previousCardId{WATCH_FACE}; +}; } #endif // MAIN_PRESENTER_H 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 704b05912..38126469a 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 @@ -35,6 +35,7 @@ #include "traing/training_card/include/TraingCardPresenter.h" #include "PlayersView.h" +#include "traing/training_card/include/TraingDataAllView.h" #include "traing/training_card/include/TrainingControlView.h" #include "traing/training_card/include/TrainingDataView.h" #include "traing/training_card/include/TrainingDetailView.h" @@ -80,6 +81,7 @@ namespace OHOS UICardPage *InitControlPage(void); UICardPage *InitDataPage(void); UICardPage *InitMusicPage(void); + UICardPage *InitDetailPage(void); void InitView(); @@ -106,10 +108,10 @@ namespace OHOS UIScrollView *endView{nullptr}; UIScrollView *getView{nullptr}; UIScrollView *heartView{nullptr}; - TrainingControlView *ControlView{nullptr}; // 控制卡片 - TrainingDataView *DataVIew{nullptr}; // 数据卡片 + TrainingControlView *controlview_{nullptr}; // 控制卡片 + TraingDataAllView *dataallview_{nullptr}; // 数据卡片 TrainingDetailView *DetailView{nullptr}; // 详细数据卡片 - PlayersView *MusicView{nullptr}; // 音乐卡片 + PlayersView *musicview_{nullptr}; // 音乐卡片 /*结束弹窗*/ UILabelExt *endtitle{nullptr}; // 结束弹窗title diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingDataAllView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingDataAllView.h new file mode 100644 index 000000000..ee8312d06 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TraingDataAllView.h @@ -0,0 +1,75 @@ +/*** + * @Date: 2024-06-25 10:41:08 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-09-02 09:22:33 + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/TraingDataAll/include/TraingDataAllView.h + */ + +#ifndef TRAING_DATA_ALL__VIEW_H +#define TRAING_DATA_ALL__VIEW_H + +#include "BaseView.h" +#include "View.h" +#include "components/ui_swipe_view.h" +#include "traing/training_card/include/TraingCardPresenter.h" +#include "traing/training_card/include/TrainingDataView.h" +#include "traing/training_card/include/TrainingDetailView.h" + +#include "components/ui_card_page.h" +namespace OHOS { + +typedef enum { + TRAING_DATA_ALL_MAIN_VIEW = 0, // Heart rate time data chart + TRAING_DATA_ALL_DETAIL_VIEW, // Detailed view + TRAING_DATA_ALL_MAX_VIEW, +} TraingDataAllPageId; + +#define TRAING_DATA_ALL_VIEW "TraingDataAllView" + +class TraingCardPresenter; +class TrainingDataView; +class TrainingDetailView; + +class TraingDataAllView : public UICardPage { +public: + TraingDataAllView(); + virtual ~TraingDataAllView(); + + static TraingDataAllView *GetInstance(void); + + UISwipeView *TraingDataAllViewInit(void); + void ClearAll(void); + + AppGroupView *TraingDataPageInit(void); + AppGroupView *TraingDetailPageInit(void); + + TrainingDataView *GetTrainingDataView(void); + TrainingDetailView *GetTrainingDetailView(void); + + UISwipeView *GetTraingDataAllPageView(void); + void ChangeView(int16_t hideView, int16_t showView); + + void InitPage(void); + + void PreLoad(void) override; + void UnLoad(void) override; + bool InitView(void); + +private: + TrainingDataView *trainingDataView{nullptr}; + TrainingDetailView *trainingDetailView{nullptr}; + TraingDataAllView *trainingDataAllView{nullptr}; + UISwipeView *traingDataAllPageView{nullptr}; + + int16_t maxPage = TRAING_DATA_ALL_MAX_VIEW; + UISwipeView *TraingDataAllSwipeViewList{nullptr}; + AppGroupView *recordCard[TRAING_DATA_ALL_MAX_VIEW]{nullptr}; + + AppGroupView *CreatePage(uint8_t pageId); + bool viewiInitStatus{false}; +}; + +} // namespace OHOS + +#endif // TRAING_DATA_ALL__VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h index 82dd76e5d..593c89835 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDataView.h @@ -22,12 +22,13 @@ #include "components/icon_adapter.h" #include "components/ui_circle_progress.h" -#include "wearable_log.h" -#include "ohos_types.h" +#include "AppGroupView.h" #include "components/ui_card_page.h" +#include "ohos_types.h" +#include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" #include "uicomponents/UIComponents.h" -#include "traing/Training_UiConfig.h" +#include "wearable_log.h" #include "traing/include/TraingModel.h" #include "uicomponents/UIComponents.h" @@ -39,51 +40,48 @@ namespace OHOS { #define BUTTONNOTE "button1" - class TrainingDataView : public UICardPage - { - public: - TrainingDataView(); - virtual ~TrainingDataView(); - static TrainingDataView *GetInstance(void); - - void InitView(); - void DeInit(); +class TrainingDataView : public AppGroupView { +public: + TrainingDataView(); + virtual ~TrainingDataView(); + static TrainingDataView *GetInstance(void); + bool InitPage(void); + virtual bool InitView(void *caller) override; + void DeInit(); - void PreLoad(void) override; - void UnLoad(void) override; - UILabelExt *GetTimeLabel(); - UILabelExt *GetHeartLabel(); - UICircleProgress*GetProgress(); + UILabelExt *GetTimeLabel(); + UILabelExt *GetHeartLabel(); + UICircleProgress *GetProgress(); - void UpdataTime(); + void UpdataTime(); - private: - UIView::OnDragListener *draglistener{nullptr}; - TrainingDataView(TrainingDataView &&) = delete; - TrainingDataView &operator=(TrainingDataView &&) = delete; +private: + UIView::OnDragListener *draglistener{nullptr}; + TrainingDataView(TrainingDataView &&) = delete; + TrainingDataView &operator=(TrainingDataView &&) = delete; - UIViewGroup *container_ = nullptr; + UIViewGroup *container_ = nullptr; - UILabelExt *curtimelabel = nullptr; // 当前时间 - UILabelExt *sportlabel = nullptr; // 运动项目名称 - UILabelExt *timerlabel = nullptr; // 计时 - UILabelExt *heartlabel = nullptr; // 运动实时心率 - UILabelExt *ubpmlabel = nullptr; // 运动强度 + UILabelExt *curtimelabel = nullptr; // 当前时间 + UILabelExt *sportlabel = nullptr; // 运动项目名称 + UILabelExt *timerlabel = nullptr; // 计时 + UILabelExt *heartlabel = nullptr; // 运动实时心率 + UILabelExt *ubpmlabel = nullptr; // 运动强度 - UIImageView *image_progress = nullptr; - UIImageView *image_heart = nullptr; - UIImageView *image_lowIntensity = nullptr; // 低等强度 - UIImageView *image_mediumIntensity = nullptr; // 中等强度 - UIImageView *image_highIntensity = nullptr; // 高等强度 - UIImageView *image_superHighIntensity = nullptr; // 超高等强度 + UIImageView *image_progress = nullptr; + UIImageView *image_heart = nullptr; + UIImageView *image_lowIntensity = nullptr; // 低等强度 + UIImageView *image_mediumIntensity = nullptr; // 中等强度 + UIImageView *image_highIntensity = nullptr; // 高等强度 + UIImageView *image_superHighIntensity = nullptr; // 超高等强度 - UICircleProgress *circleProgress = nullptr; + UICircleProgress *circleProgress = nullptr; - UIImageView *image_iconup = nullptr; - UIImageView *image_iconpoint = nullptr; + UIImageView *image_iconup = nullptr; + UIImageView *image_iconpoint = nullptr; - UIButton *buttonNote = nullptr; // 注意事项按键 - bool viewiInitStatus{false}; - }; + UIButton *buttonNote = nullptr; // 注意事项按键 + bool viewiInitStatus{false}; +}; } // namespace OHOS #endif // TraingData_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h index 84566bf99..7f32c43a7 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/include/TrainingDetailView.h @@ -36,44 +36,42 @@ namespace OHOS { - class TrainingDetailView : public UICardPage - { - public: - TrainingDetailView(); - virtual ~TrainingDetailView(); - static TrainingDetailView *GetInstance(void); +class TrainingDetailView : public AppGroupView { +public: + TrainingDetailView(); + virtual ~TrainingDetailView(); + static TrainingDetailView *GetInstance(void); - void InitView(); - void DeInit(); + void DeInit(); - void PreLoad(void) override; - void UnLoad(void) override; + bool InitPage(void); + virtual bool InitView(void *caller) override; - UILabelExt *GetMileLabel(); - UILabelExt *GetStepLabel(); - UILabelExt *GetCalorieLabel(); - UILabelButtonExt *Get_Intensity_Button(); + UILabelExt *GetMileLabel(); + UILabelExt *GetStepLabel(); + UILabelExt *GetCalorieLabel(); + UILabelButtonExt *Get_Intensity_Button(); - private: - UIView::OnDragListener *draglistener{nullptr}; - TrainingDetailView(TrainingDetailView &&) = delete; - TrainingDetailView &operator=(TrainingDetailView &&) = delete; +private: + UIView::OnDragListener *draglistener{nullptr}; + TrainingDetailView(TrainingDetailView &&) = delete; + TrainingDetailView &operator=(TrainingDetailView &&) = delete; - UIViewGroup *container_ = nullptr; + UIViewGroup *container_ = nullptr; - UILabelButtonExt *intensity_button{nullptr}; + UILabelButtonExt *intensity_button{nullptr}; - UILabelExt *u_milelabel = nullptr; - UILabelExt *u_stepslabel = nullptr; - UILabelExt *u_calorielabel = nullptr; - UILabelExt *milelabel = nullptr; - UILabelExt *steplabel = nullptr; - UILabelExt *calorielabel = nullptr; + UILabelExt *u_milelabel = nullptr; + UILabelExt *u_stepslabel = nullptr; + UILabelExt *u_calorielabel = nullptr; + UILabelExt *milelabel = nullptr; + UILabelExt *steplabel = nullptr; + UILabelExt *calorielabel = nullptr; - UIImageView *progress_image = nullptr; - UIImageView *lineimage2_ = nullptr; + UIImageView *progress_image = nullptr; + UIImageView *lineimage2_ = nullptr; - bool viewiInitStatus{false}; - }; + bool viewiInitStatus{false}; +}; } // namespace OHOS #endif // TraingDetail_PRESENTER_H diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp index 860980b7a..29a583e35 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp @@ -1,12 +1,12 @@ #include "traing/training_card/include/TraingCardView.h" +#include "UiConfig.h" #include "common/image_cache_manager.h" +#include "components/ui_button.h" #include "components/ui_label_ext.h" -#include "ui_resource_string.h" -#include "UiConfig.h" #include "ui_resource_image.h" +#include "ui_resource_string.h" #include -#include "components/ui_button.h" #include "common/screen.h" #include "components/ui_digital_clock.h" @@ -14,525 +14,504 @@ #include "components/ui_label_ext.h" #include "font/ui_font.h" -#include "traing/include/TraingModel.h" -#include "uicomponents/UIComponents.h" #include "ConfigModel.h" #include "custom_utils.h" +#include "traing/include/TraingModel.h" +#include "uicomponents/UIComponents.h" -extern "C" -{ - void InitTimer(); - void DisableTimer(); +extern "C" { +void InitTimer(); +void DisableTimer(); } -namespace OHOS -{ +namespace OHOS { #ifdef __cplusplus - extern "C" - { +extern "C" { #endif -#include "pm_veto.h" #include "pm.h" - /*移除睡眠否决投票*/ - void uapi_remove_sport_vote(void) - { - uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); - if (cnt == 1) - { - uapi_pm_remove_sleep_veto(PM_ID_HEART); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU has delete pm_id_Sport vote"); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU SLEEP SUCCESS"); - } - - /*添加睡眠否决投票*/ - void uapi_add_sport_vote(void) - { - uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); - if (cnt == 0) - { - uapi_pm_add_sleep_veto(PM_ID_HEART); - } - else - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU has got pm_id_Sport vote"); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, "Sport SERVICE MCU WAKEUP SUCCESS"); - } +#include "pm_veto.h" +/*移除睡眠否决投票*/ +void uapi_remove_sport_vote(void) { + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); + if (cnt == 1) { + uapi_pm_remove_sleep_veto(PM_ID_HEART); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, + "Sport SERVICE MCU has delete pm_id_Sport vote"); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, + "Sport SERVICE MCU SLEEP SUCCESS"); +} + +/*添加睡眠否决投票*/ +void uapi_add_sport_vote(void) { + uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); + if (cnt == 0) { + uapi_pm_add_sleep_veto(PM_ID_HEART); + } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE, + "Sport SERVICE MCU has got pm_id_Sport vote"); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_MAIN_SERVICE, + "Sport SERVICE MCU WAKEUP SUCCESS"); +} #ifdef __cplusplus - } +} #endif - static const uint16_t LABEL_FONT_SIZE = 200; - static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; - static const uint32_t CARD_PAGE_COLOR = 0xffd0d0d0; - - static TraingCardView *g_pTraingCardView{nullptr}; - - TraingCardView::TraingCardView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::TraingCardView"); - InitTimer(); // 开启计时器 - TraingModel::GetInstance()->SetSportState(ExerciseState::Start); // 设置运动状态为开始 - TraingModel::GetInstance()->SetTimestamp(); - uapi_add_sport_vote(); // 保护进程 - g_pTraingCardView = this; - } - - TraingCardView::~TraingCardView() - { - imageAnimator->Stop(); - FreeImageInfoArray(winimageInfos, winbasePath.c_str(), 94); - ReleaseImageAnimatorSource(winimageAnimatorInfo, 94); - DeInit(); - - g_pTraingCardView = nullptr; - DisableTimer(); // 关闭计时器 - TraingModel::GetInstance()->SetTimestamp(); - uapi_remove_sport_vote(); // 移除 - } - - TraingCardView *TraingCardView::GetInstance() - { - return g_pTraingCardView; - } - - /* InitView:初始化界面*/ - void TraingCardView ::InitView() - { - UISwipeView::OnSwipeListener *listener = nullptr; - - if (swipe_ == nullptr) - { - swipe_ = new UICrossView(); - swipe_->SetPosition(0, 0, 466, 466); - swipe_->SetStyle(STYLE_BACKGROUND_OPA, 0); - } - - InitControlPage(); - InitDataPage(); - InitMusicPage(); - InitDetailPage(); - - swipe_->HorAdd(ControlView); - swipe_->HorAdd(DataVIew); - swipe_->HorAdd(MusicView); - - ShowEndView(); - ShowGetTagView(); - ShowHeartView(); - // swipe_->HorAdd(DetailView); - - swipe_->VerAdd(DetailView, UICrossView::VPage::DOWN_PAGE); - swipe_->SetHorCurrentPage(Control_Card::DATA); // 设置进入索引 [数据] - - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::InitPage over"); - } - - /* DeInit:删除组件 */ - void TraingCardView::DeInit() - { - swipe_->RemoveAll(); - - /*界面*/ - ControlView->RemoveAll(); - DataVIew->RemoveAll(); - DetailView->RemoveAll(); - MusicView->RemoveAll(); - endView->RemoveAll(); - getView->RemoveAll(); - heartView->RemoveAll(); - - /*标签*/ - delete endtitle; - endtitle = nullptr; - delete notelabel; - notelabel = nullptr; - delete endnotelabel; - endnotelabel = nullptr; - delete endnote; - endnote = nullptr; - delete labeltitle; - labeltitle = nullptr; - delete labeltag; - labeltag = nullptr; - delete labelgettag; - labelgettag = nullptr; - delete labelpre; - labelpre = nullptr; - delete hearttitle; - hearttitle = nullptr; - delete labelnote; - labelnote = nullptr; - /*图片*/ - delete heartiamge; - heartiamge = nullptr; - - /*按键*/ - delete exit; - exit = nullptr; - delete back; - back = nullptr; - delete buttonok_; - buttonok_ = nullptr; - delete buttonnote_; - buttonnote_ = nullptr; - - /*动画*/ - delete imageAnimator; - imageAnimator = nullptr; - - /*卡片*/ - delete ControlView; - ControlView = nullptr; - delete DataVIew; - DataVIew = nullptr; - delete DetailView; - DetailView = nullptr; - delete swipe_; - delete MusicView; - MusicView = nullptr; - /*弹窗*/ - delete endView; - endView = nullptr; - delete getView; - getView = nullptr; - delete heartView; - heartView = nullptr; - - swipe_ = nullptr; - } - UICardPage *TraingCardView::InitControlPage(void) - { - ControlView = new TrainingControlView(); - ControlView->PreLoad(); - if (ControlView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ControlView new fail"); - return nullptr; - } - return ControlView; - } - UICardPage *TraingCardView::InitDataPage(void) - { - DataVIew = new TrainingDataView(); - DataVIew->PreLoad(); - if (DataVIew == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DataVIew new fail"); - return nullptr; - } - return DataVIew; - } - UICardPage *TraingCardView::InitMusicPage(void) - { - MusicView = new PlayersView(); - MusicView->PreLoad(); - if (MusicView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MusicView new fail"); - return nullptr; - } - return MusicView; - } - UICardPage *TraingCardView::InitDetailPage() - { - DetailView = new TrainingDetailView(); - DetailView->PreLoad(); - DetailView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - DetailView->SetStyle(STYLE_BORDER_RADIUS, 466); // 设置为圆形 - if (DetailView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DetailView new fail"); - return nullptr; - } - return DetailView; - } - void TraingCardView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView PreLoad"); - } - void TraingCardView::OnStart() - { - swipe_ = new UICrossView(); - if (swipe_ == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new fail"); - return; - } - swipe_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); - // 创建 draglistener 实例并设置为拖动监听器 - UIView::OnDragListener *draglistener = static_cast(TraingCardPresenter::GetInstance()); - if (draglistener == nullptr) - { - return; - } - swipe_->SetOnDragListener(draglistener); - swipe_->SetTouchable(true); - swipe_->SetDraggable(true); - swipe_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); - swipe_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); - // swipe_->EnableScreenCap(true); - PreLoad(); - SetContainerView(swipe_); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new ok"); - } - /*设置弹窗状态*/ - void TraingCardView::SetPopupViewStatus(PopupType type, bool status) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", type); - UIView *popupView = nullptr; - if (type == EndPopup) - { - popupView = endView; - } - else if (type == GetTagPopup) - { - popupView = getView; - } - else if (type == HeartPopup) - { - popupView = heartView; - } - - if (popupView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); - return; - } - - UIView *cardview = TraingCardView::GetInstance()->GetTraingCrad(); - if (cardview != nullptr) - { - cardview->SetVisible(!status); - } - - popupView->SetVisible(status); - } - /*结束弹窗界面*/ - void TraingCardView::ShowEndView() - { - // momentumFlag = false; // 标志位还原 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView"); - endView = new UIScrollView(); - if (endView == nullptr) - { - return; - } - endView->SetPosition(0, 0); - endView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - endView->SetScrollBlankSize(20); - endView->SetReboundSize(50); - endView->SetDirection(1); - - InitRollLabel(endtitle, 83, 50, 300, 35, "label1", STR_LOOK_OUT, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitRollLabel(notelabel, 56, 167, 360, 80, "label2", STR_INSUFFICIENT_EXERCISE_AMOUNT, DEFAULT_VECTOR_FONT_FILENAME, 30); - /*隐藏是否结束运动title*/ - InitRollLabel(endnote, 56, 207, 360, 80, "label3", STR_END_THIS_MOVEMENT, DEFAULT_VECTOR_FONT_FILENAME, 30); - endnote->SetVisible(false); - - endView->Add(endnote); - endView->Add(endtitle); - endView->Add(notelabel); - - InitButton(exit, 111, 299, 100, 100, BUTTONBACK); - exit->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - exit->SetImageSrc(NO_IMAGE, NO_IMAGE); - InitButton(back, 256, 299, 100, 100, BUTTONEXIT); - back->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - back->SetImageSrc(YES_IMAGE, YES_IMAGE); - endView->Add(exit); - endView->Add(back); - RootView::GetInstance()->Add(endView); - endView->SetDraggable(false); - endView->SetTouchable(true); - endView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView end"); - } - /*目标达成界面*/ - void TraingCardView::ShowGetTagView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView"); - getView = new UIScrollView(); - if (getView == nullptr) - { - return; - } - getView->SetPosition(0, 0); - getView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - getView->SetScrollBlankSize(20); - getView->SetReboundSize(50); - getView->SetDirection(1); - - // 初始化Lable - InitRollLabel(labeltitle, 83, 50, 300, 35, "label1", STR_GOAL_ACHIEVED, DEFAULT_VECTOR_FONT_FILENAME, 35); - getView->Add(labeltitle); - InitRollLabel(labelgettag, 103, 307, 200, 35, "label3", STR_ACCOMPLISH_GOAL, DEFAULT_VECTOR_FONT_FILENAME, 30); - getView->Add(labelgettag); - InitLabel(labelpre, 233, 307, 160, 35, "label3", "100%", DEFAULT_VECTOR_FONT_FILENAME, 30); - getView->Add(labelpre); - - // 初始化按键 - InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONWINOK, STR_OK, 30); - buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); - buttonok_->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - getView->Add(buttonok_); - - InitImageAnimator(); - RootView::GetInstance()->Add(getView); - getView->SetDraggable(false); - getView->SetTouchable(true); - getView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView end"); - } - /*最高心率提醒弹窗*/ - void TraingCardView::ShowHeartView() - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView"); - heartView = new UIScrollView(); - if (heartView == nullptr) - { - return; - } - heartView->SetPosition(0, 0); - heartView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); - heartView->SetScrollBlankSize(20); - heartView->SetReboundSize(50); - heartView->SetDirection(1); - - // 初始化Lable - InitRollLabel(hearttitle, 83, 50, 300, 35, "label1", STR_HEARTTITLE, DEFAULT_VECTOR_FONT_FILENAME, 35); - heartView->Add(hearttitle); - - int maxheart = ConfigModel::GetInstance()->get_configData_int(ConfigModel::CONFIGMODEL_ITEM_TRAINING_HEART_MAX); - std::string heartStr = "当前心率高于" + std::to_string(maxheart) + "次/分钟"; - InitLabel(labelnote, 53, 269, 360, 35, "label3", heartStr.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 30); - heartView->Add(labelnote); - - InitImageView(heartiamge, 193, 149, 80, 80, "note", WARNING_IMAGE); - heartView->Add(heartiamge); - - // 初始化按键 - InitButtonExt(buttonnote_, 0, 366, 466, 100, BUTTONNOTE, STR_OK, 30); - buttonnote_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); - buttonnote_->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); - heartView->Add(buttonnote_); - - RootView::GetInstance()->Add(heartView); - heartView->SetDraggable(false); - heartView->SetTouchable(true); - heartView->SetVisible(false); // 界面隐藏 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView end"); - } - /*获取运动量结束弹窗界面刷新*/ - bool TraingCardView::RefreshEndView() - { - // 获取训练卡路里判断运动量 - momentumFlag = TraingModel::GetInstance()->GetMomentum(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "momentumFlag %d", momentumFlag); - - if (momentumFlag) - { - // 正常结束 - endnote->SetVisible(false); - endtitle->SetTextId(STR_END_MOVEMENT); - notelabel->SetTextId(STR_END_THIS_MOVEMENT); - } - else - { - endtitle->SetTextId(STR_LOOK_OUT); - notelabel->SetTextId(STR_INSUFFICIENT_EXERCISE_AMOUNT); - endnote->SetVisible(true); - } - return momentumFlag; - } - /*初始化动画以及Taglabel*/ - void TraingCardView::InitImageAnimator() - { - int tag = TraingModel::GetInstance()->GetSportTag(); - ExerciseTag tagType = TraingModel::GetInstance()->GetSportTagtype(); - std::string tagString = std::to_string(tag); - switch (tagType) - { - case ExerciseTag::Duration: - { - int hours = tag / 60; - int minutes = tag % 60; - int seconds = 0; - // 将小时、分钟、秒转换为字符串,并在小于10时补零 - std::string hoursStr = (hours < 10) ? "0" + std::to_string(hours) : std::to_string(hours); - std::string minutesStr = (minutes < 10) ? "0" + std::to_string(minutes) : std::to_string(minutes); - std::string secondsStr = (seconds < 10) ? "0" + std::to_string(seconds) : std::to_string(seconds); - tagString = hoursStr + ":" + minutesStr + ":" + secondsStr; - break; - } - case ExerciseTag::Calories: - { - tagString = tagString + "kcal"; - break; - } - case ExerciseTag::Distance: - { - tagString = tagString + "km"; - break; - } - case ExerciseTag::Steps: - break; - default: - break; - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "tag[%d]-tagType[%d]-tagString[%s]\r\n", tag, tagType, tagString.c_str()); - InitLabel(labeltag, 70, 215, 326, 97, "label2", tagString.c_str(), DEFAULT_VECTOR_FONT_FILENAME, 80); - labeltag->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); - getView->Add(labeltag); - - // 初始化图片数组以及动画 - winimageInfos = CreateImageInfoArray(winbasePath.c_str(), 94); - InitImageAnimatorSource(imageAnimator, winimageAnimatorInfo, winimageInfos, 94, 173, 100, 120, 120, "imageAnimator1", 10); - getView->Add(imageAnimator); - } - - /*获取卡片View单例*/ - UICrossView *TraingCardView::GetTraingCrad() - { - return swipe_; - } - void TraingCardView::OnSetUpView() - { - View::OnSetUpView(); - Draw(); - } - - void TraingCardView::OnTearDownView() - { - View::OnTearDownView(); - return; - } - - void TraingCardView::OnStop() - { - View::OnStop(); - RootView::GetInstance()->RemoveAll(); - return; - } - - int TraingCardView::GetCurrentPage() - { - return swipe_->GetCurrentPageId(0); // 获取水平页面 - } - UIImageAnimatorView *TraingCardView::GetAnimator() - { - return imageAnimator; - } +static const uint16_t LABEL_FONT_SIZE = 200; +static const uint32_t BACK_GROUND_COLOR = 0xfff6f6f6; +static const uint32_t CARD_PAGE_COLOR = 0xffd0d0d0; + +static TraingCardView *g_pTraingCardView{nullptr}; + +TraingCardView::TraingCardView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::TraingCardView"); + InitTimer(); // 开启计时器 + TraingModel::GetInstance()->SetSportState( + ExerciseState::Start); // 设置运动状态为开始 + TraingModel::GetInstance()->SetTimestamp(); + uapi_add_sport_vote(); // 保护进程 + g_pTraingCardView = this; +} + +TraingCardView::~TraingCardView() { + imageAnimator->Stop(); + FreeImageInfoArray(winimageInfos, winbasePath.c_str(), 94); + ReleaseImageAnimatorSource(winimageAnimatorInfo, 94); + DeInit(); + + g_pTraingCardView = nullptr; + DisableTimer(); // 关闭计时器 + TraingModel::GetInstance()->SetTimestamp(); + uapi_remove_sport_vote(); // 移除 +} + +TraingCardView *TraingCardView::GetInstance() { return g_pTraingCardView; } + +/* InitView:初始化界面*/ +void TraingCardView ::InitView() { + + if (swipe_ == nullptr) { + swipe_ = new UICrossView(); + swipe_->SetPosition(0, 0, 466, 466); + swipe_->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + InitControlPage(); + InitDataPage(); + InitMusicPage(); + InitDetailPage(); + + swipe_->HorAdd(controlview_); + swipe_->HorAdd(dataallview_); + swipe_->HorAdd(musicview_); + + ShowEndView(); + ShowGetTagView(); + ShowHeartView(); + + // swipe_->HorAdd(DetailView); + swipe_->VerAdd(DetailView, UICrossView::VPage::DOWN_PAGE); + + swipe_->SetHorCurrentPage(Control_Card::DATA); // 设置进入索引 [数据] + + UISwipeView::OnSwipeListener *onSwipeListener = + static_cast( + OHOS::TraingCardPresenter::GetInstance()); + if (onSwipeListener == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "onSwipeListener is null"); + return; + } + swipe_->SetOnSwipeListener(onSwipeListener); + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView::InitPage over"); +} + +/* DeInit:删除组件 */ +void TraingCardView::DeInit() { + swipe_->RemoveAll(); + + /*界面*/ + controlview_->RemoveAll(); + dataallview_->RemoveAll(); + // DetailView->RemoveAll(); + musicview_->RemoveAll(); + endView->RemoveAll(); + getView->RemoveAll(); + heartView->RemoveAll(); + + /*标签*/ + delete endtitle; + endtitle = nullptr; + delete notelabel; + notelabel = nullptr; + delete endnotelabel; + endnotelabel = nullptr; + delete endnote; + endnote = nullptr; + delete labeltitle; + labeltitle = nullptr; + delete labeltag; + labeltag = nullptr; + delete labelgettag; + labelgettag = nullptr; + delete labelpre; + labelpre = nullptr; + delete hearttitle; + hearttitle = nullptr; + delete labelnote; + labelnote = nullptr; + /*图片*/ + delete heartiamge; + heartiamge = nullptr; + + /*按键*/ + delete exit; + exit = nullptr; + delete back; + back = nullptr; + delete buttonok_; + buttonok_ = nullptr; + delete buttonnote_; + buttonnote_ = nullptr; + + /*动画*/ + delete imageAnimator; + imageAnimator = nullptr; + + /*卡片*/ + delete controlview_; + controlview_ = nullptr; + delete dataallview_; + dataallview_ = nullptr; + // delete DetailView; + // DetailView = nullptr; + delete swipe_; + delete musicview_; + musicview_ = nullptr; + /*弹窗*/ + delete endView; + endView = nullptr; + delete getView; + getView = nullptr; + delete heartView; + heartView = nullptr; + + swipe_ = nullptr; +} +UICardPage *TraingCardView::InitControlPage(void) { + controlview_ = new TrainingControlView(); + // controlview_->PreLoad(); + if (controlview_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "controlview_ new fail"); + return nullptr; + } + return controlview_; +} +UICardPage *TraingCardView::InitDataPage(void) { + dataallview_ = new TraingDataAllView(); + // dataallview_->PreLoad(); + if (dataallview_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dataallview_ new fail"); + return nullptr; + } + return dataallview_; +} +UICardPage *TraingCardView::InitMusicPage(void) { + musicview_ = new PlayersView(); + // musicview_->PreLoad(); + if (musicview_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "musicview_ new fail"); + return nullptr; + } + return musicview_; +} +UICardPage *TraingCardView::InitDetailPage() { + DetailView = new TrainingDetailView(); + // DetailView->PreLoad(); + DetailView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + DetailView->SetStyle(STYLE_BORDER_RADIUS, 466); // 设置为圆形 + if (DetailView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DetailView new fail"); + return nullptr; + } + return DetailView; +} +void TraingCardView::PreLoad(void) { + if (!viewiInitStatus) { + InitView(); + viewiInitStatus = true; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardView PreLoad"); +} +void TraingCardView::OnStart() { + View::OnStart(); + + swipe_ = new UICrossView(); + if (swipe_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new fail"); + return; + } + UIView::OnDragListener *listener = + static_cast(TraingCardPresenter::GetInstance()); + if (listener == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "AlarmSetWeekView:: new alarmDragListener fail"); + return; + } + swipe_->SetOnDragListener(listener); + + PreLoad(); + swipe_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), + Screen::GetInstance().GetHeight()); + swipe_->SetTouchable(true); + swipe_->SetDraggable(true); + swipe_->SetStyle(STYLE_BACKGROUND_COLOR, BACK_GROUND_COLOR); + swipe_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + swipe_->EnableScreenCap(true); + swipe_->SetAnimatorTime(50); + + SetContainerView(swipe_); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "swipe_ new ok"); +} +/*设置弹窗状态*/ +void TraingCardView::SetPopupViewStatus(PopupType type, bool status) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SetPopupViewStatus %d", type); + UIView *popupView = nullptr; + if (type == EndPopup) { + popupView = endView; + } else if (type == GetTagPopup) { + popupView = getView; + } else if (type == HeartPopup) { + popupView = heartView; + } + + if (popupView == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PopupView is NULL"); + return; + } + + UIView *cardview = TraingCardView::GetInstance()->GetTraingCrad(); + if (cardview != nullptr) { + cardview->SetVisible(!status); + } + + popupView->SetVisible(status); +} +/*结束弹窗界面*/ +void TraingCardView::ShowEndView() { + // momentumFlag = false; // 标志位还原 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView"); + endView = new UIScrollView(); + if (endView == nullptr) { + return; + } + endView->SetPosition(0, 0); + endView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + endView->SetScrollBlankSize(20); + endView->SetReboundSize(50); + endView->SetDirection(1); + + InitRollLabel(endtitle, 83, 50, 300, 35, "label1", STR_LOOK_OUT, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitRollLabel(notelabel, 56, 167, 360, 80, "label2", + STR_INSUFFICIENT_EXERCISE_AMOUNT, DEFAULT_VECTOR_FONT_FILENAME, + 30); + /*隐藏是否结束运动title*/ + InitRollLabel(endnote, 56, 207, 360, 80, "label3", STR_END_THIS_MOVEMENT, + DEFAULT_VECTOR_FONT_FILENAME, 30); + endnote->SetVisible(false); + + endView->Add(endnote); + endView->Add(endtitle); + endView->Add(notelabel); + + InitButton(exit, 111, 299, 100, 100, BUTTONBACK); + exit->SetOnClickListener(static_cast( + TraingCardPresenter::GetInstance())); + exit->SetImageSrc(NO_IMAGE, NO_IMAGE); + InitButton(back, 256, 299, 100, 100, BUTTONEXIT); + back->SetOnClickListener(static_cast( + TraingCardPresenter::GetInstance())); + back->SetImageSrc(YES_IMAGE, YES_IMAGE); + endView->Add(exit); + endView->Add(back); + RootView::GetInstance()->Add(endView); + endView->SetDraggable(false); + endView->SetTouchable(true); + endView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowEndView end"); +} +/*目标达成界面*/ +void TraingCardView::ShowGetTagView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView"); + getView = new UIScrollView(); + if (getView == nullptr) { + return; + } + getView->SetPosition(0, 0); + getView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + getView->SetScrollBlankSize(20); + getView->SetReboundSize(50); + getView->SetDirection(1); + + // 初始化Lable + InitRollLabel(labeltitle, 83, 50, 300, 35, "label1", STR_GOAL_ACHIEVED, + DEFAULT_VECTOR_FONT_FILENAME, 35); + getView->Add(labeltitle); + InitRollLabel(labelgettag, 103, 307, 200, 35, "label3", STR_ACCOMPLISH_GOAL, + DEFAULT_VECTOR_FONT_FILENAME, 30); + getView->Add(labelgettag); + InitLabel(labelpre, 233, 307, 160, 35, "label3", "100%", + DEFAULT_VECTOR_FONT_FILENAME, 30); + getView->Add(labelpre); + + // 初始化按键 + InitButtonExt(buttonok_, 0, 366, 466, 100, BUTTONWINOK, STR_OK, 30); + buttonok_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); + buttonok_->SetOnClickListener(static_cast( + TraingCardPresenter::GetInstance())); + getView->Add(buttonok_); + + InitImageAnimator(); + RootView::GetInstance()->Add(getView); + getView->SetDraggable(false); + getView->SetTouchable(true); + getView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowGetTagView end"); +} +/*最高心率提醒弹窗*/ +void TraingCardView::ShowHeartView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView"); + heartView = new UIScrollView(); + if (heartView == nullptr) { + return; + } + heartView->SetPosition(0, 0); + heartView->Resize(VERTICAL_RESOLUTION, HORIZONTAL_RESOLUTION); + heartView->SetScrollBlankSize(20); + heartView->SetReboundSize(50); + heartView->SetDirection(1); + + // 初始化Lable + InitRollLabel(hearttitle, 83, 50, 300, 35, "label1", STR_HEARTTITLE, + DEFAULT_VECTOR_FONT_FILENAME, 35); + heartView->Add(hearttitle); + + int maxheart = ConfigModel::GetInstance()->get_configData_int( + ConfigModel::CONFIGMODEL_ITEM_TRAINING_HEART_MAX); + std::string heartStr = "当前心率高于" + std::to_string(maxheart) + "次/分钟"; + InitLabel(labelnote, 53, 269, 360, 35, "label3", heartStr.c_str(), + DEFAULT_VECTOR_FONT_FILENAME, 30); + heartView->Add(labelnote); + + InitImageView(heartiamge, 193, 149, 80, 80, "note", WARNING_IMAGE); + heartView->Add(heartiamge); + + // 初始化按键 + InitButtonExt(buttonnote_, 0, 366, 466, 100, BUTTONNOTE, STR_OK, 30); + buttonnote_->SetImageSrc(BUTTONOK_IMAGE, BUTTONOK_IMAGE); + buttonnote_->SetOnClickListener(static_cast( + TraingCardPresenter::GetInstance())); + heartView->Add(buttonnote_); + + RootView::GetInstance()->Add(heartView); + heartView->SetDraggable(false); + heartView->SetTouchable(true); + heartView->SetVisible(false); // 界面隐藏 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShowHeartView end"); +} +/*获取运动量结束弹窗界面刷新*/ +bool TraingCardView::RefreshEndView() { + // 获取训练卡路里判断运动量 + momentumFlag = TraingModel::GetInstance()->GetMomentum(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "momentumFlag %d", momentumFlag); + + if (momentumFlag) { + // 正常结束 + endnote->SetVisible(false); + endtitle->SetTextId(STR_END_MOVEMENT); + notelabel->SetTextId(STR_END_THIS_MOVEMENT); + } else { + endtitle->SetTextId(STR_LOOK_OUT); + notelabel->SetTextId(STR_INSUFFICIENT_EXERCISE_AMOUNT); + endnote->SetVisible(true); + } + return momentumFlag; +} +/*初始化动画以及Taglabel*/ +void TraingCardView::InitImageAnimator() { + int tag = TraingModel::GetInstance()->GetSportTag(); + ExerciseTag tagType = TraingModel::GetInstance()->GetSportTagtype(); + std::string tagString = std::to_string(tag); + switch (tagType) { + case ExerciseTag::Duration: { + int hours = tag / 60; + int minutes = tag % 60; + int seconds = 0; + // 将小时、分钟、秒转换为字符串,并在小于10时补零 + std::string hoursStr = + (hours < 10) ? "0" + std::to_string(hours) : std::to_string(hours); + std::string minutesStr = (minutes < 10) ? "0" + std::to_string(minutes) + : std::to_string(minutes); + std::string secondsStr = (seconds < 10) ? "0" + std::to_string(seconds) + : std::to_string(seconds); + tagString = hoursStr + ":" + minutesStr + ":" + secondsStr; + break; + } + case ExerciseTag::Calories: { + tagString = tagString + "kcal"; + break; + } + case ExerciseTag::Distance: { + tagString = tagString + "km"; + break; + } + case ExerciseTag::Steps: + break; + default: + break; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, + "tag[%d]-tagType[%d]-tagString[%s]\r\n", tag, tagType, + tagString.c_str()); + InitLabel(labeltag, 70, 215, 326, 97, "label2", tagString.c_str(), + DEFAULT_VECTOR_FONT_FILENAME, 80); + labeltag->SetTextColor(Color::GetColorFromRGBA(0x4f, 0xc3, 0x4c, 0xff)); + getView->Add(labeltag); + + // 初始化图片数组以及动画 + winimageInfos = CreateImageInfoArray(winbasePath.c_str(), 94); + InitImageAnimatorSource(imageAnimator, winimageAnimatorInfo, winimageInfos, + 94, 173, 100, 120, 120, "imageAnimator1", 10); + getView->Add(imageAnimator); +} + +/*获取卡片View单例*/ +UICrossView *TraingCardView::GetTraingCrad() { return swipe_; } +void TraingCardView::OnSetUpView() { + View::OnSetUpView(); + Draw(); +} + +void TraingCardView::OnTearDownView() { + View::OnTearDownView(); + return; +} + +void TraingCardView::OnStop() { + View::OnStop(); + RootView::GetInstance()->RemoveAll(); + return; +} + +int TraingCardView::GetCurrentPage() { + return swipe_->GetCurrentPageId(0); // 获取水平页面 } +UIImageAnimatorView *TraingCardView::GetAnimator() { return imageAnimator; } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingDataAllView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingDataAllView.cpp new file mode 100644 index 000000000..1579cf2dd --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingDataAllView.cpp @@ -0,0 +1,169 @@ +#include "traing/include/TraingModel.h" +#include "traing/training_card/include/TrainingControlView.h" +#include "traing/training_card/include/TrainingDataView.h" +#include "traing/training_card/include/TrainingDetailView.h" +#include "wearable_log.h" + +namespace OHOS { + +static TraingDataAllView *g_pTraingDataAllView{nullptr}; + +TraingDataAllView::TraingDataAllView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, + "TraingDataAllView::TraingDataAllView"); + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pTraingDataAllView = this; +} + +TraingDataAllView::~TraingDataAllView() { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, + "TraingDataAllView::~TraingDataAllView"); + ClearAll(); + g_pTraingDataAllView = nullptr; +} + +TraingDataAllView *TraingDataAllView::GetInstance(void) { + return g_pTraingDataAllView; +} + +void TraingDataAllView::ClearAll(void) { + for (int32_t i = 0; i < maxPage; i++) { + recordCard[i] = nullptr; + } + + if (TraingDataAllSwipeViewList) { + TraingDataAllSwipeViewList->RemoveAll(); + delete TraingDataAllSwipeViewList; + TraingDataAllSwipeViewList = nullptr; + } + + delete trainingDataView; + trainingDataView = nullptr; + + delete trainingDetailView; + trainingDetailView = nullptr; +} + +UISwipeView *TraingDataAllView::TraingDataAllViewInit(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "TraingDataAllView::TraingDataAllViewInit"); + + TraingDataAllSwipeViewList = new UISwipeView(UISwipeView::VERTICAL); + if (!TraingDataAllSwipeViewList) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to create TraingDataAllSwipeViewList"); + return nullptr; + } + + TraingDataAllSwipeViewList->SetStyle(STYLE_BACKGROUND_COLOR, + Color::Black().full); + TraingDataAllSwipeViewList->SetPosition(0, 0, HORIZONTAL_RESOLUTION, + VERTICAL_RESOLUTION); + TraingDataAllSwipeViewList->SetDraggable(true); + TraingDataAllSwipeViewList->SetTouchable(true); + + for (uint16_t i = 0; i < maxPage; i++) { + recordCard[i] = CreatePage(i); + if (!recordCard[i]) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "recordCard[%d] is nullptr", i); + return nullptr; + } + recordCard[i]->InitView(this); + TraingDataAllSwipeViewList->Add(recordCard[i]); + } + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingDataAllView InitPage complete"); + return TraingDataAllSwipeViewList; +} + +UISwipeView *TraingDataAllView::GetTraingDataAllPageView() { + return TraingDataAllViewInit(); +} + +TrainingDataView *TraingDataAllView::GetTrainingDataView(void) { + return trainingDataView; +} + +TrainingDetailView *TraingDataAllView::GetTrainingDetailView(void) { + return trainingDetailView; +} + +AppGroupView *TraingDataAllView::TraingDataPageInit(void) { + trainingDataView = new TrainingDataView(); + if (!trainingDataView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to create TrainingDataView"); + return nullptr; + } + return trainingDataView; +} + +AppGroupView *TraingDataAllView::TraingDetailPageInit(void) { + trainingDetailView = new TrainingDetailView(); + if (!trainingDetailView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to create TrainingDetailView"); + return nullptr; + } + return trainingDetailView; +} + +struct TraingDataAllViewMapper { + const int16_t viewId; + AppGroupView *(TraingDataAllView::*func)(void); +}; + +static const TraingDataAllViewMapper g_pageMapper[] = { + {TRAING_DATA_ALL_MAIN_VIEW, &TraingDataAllView::TraingDataPageInit}, + {TRAING_DATA_ALL_DETAIL_VIEW, &TraingDataAllView::TraingDetailPageInit}, +}; + +AppGroupView *TraingDataAllView::CreatePage(uint8_t TraingDataAllPageId) { + for (const auto &mapper : g_pageMapper) { + if (mapper.viewId == TraingDataAllPageId) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Creating page for TraingDataAllPageId: %d", + TraingDataAllPageId); + return (this->*(mapper.func))(); + } + } + return nullptr; +} + +bool TraingDataAllView::InitView(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Initializing TraingDataAllView"); + + if (!trainingDataAllView) { + trainingDataAllView = new TraingDataAllView(); + if (!trainingDataAllView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to create TraingDataAllView"); + return false; + } + } + + traingDataAllPageView = dynamic_cast( + trainingDataAllView->GetTraingDataAllPageView()); + if (!traingDataAllPageView) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "GetTraingDataAllPageView returned nullptr"); + return false; + } + traingDataAllPageView->SetDraggable(true); + traingDataAllPageView->SetTouchable(true); + Add(traingDataAllPageView); + + return true; +} + +void TraingDataAllView::PreLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Preloading TraingDataAllView"); + if (!viewiInitStatus && InitView()) { + viewiInitStatus = true; + } +} + +void TraingDataAllView::UnLoad(void) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Unloading TraingDataAllView"); +} + +} // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp index f8a919421..d91ce2294 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp @@ -2,95 +2,98 @@ * @Date: 2024-04-15 10:55:58 * @LastEditors: Caisking 3449750381@qq.com * @LastEditTime: 2024-08-02 09:35:58 - * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp + * @FilePath: + * /FD230/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp */ #include "traing/training_card/include/TrainingDataView.h" #include "traing/training_card/include/TraingCardView.h" -#include "common/image_cache_manager.h" -#include "components/ui_label_ext.h" -#include "ui_resource_string.h" #include "UiConfig.h" -#include "ui_resource_image.h" -#include +#include "common/image_cache_manager.h" #include "components/ui_button.h" +#include "components/ui_label_ext.h" +#include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" +#include "ui_resource_image.h" +#include "ui_resource_string.h" #include "uicomponents/UIComponents.h" -#include "traing/Training_UiConfig.h" +#include + +namespace OHOS { -namespace OHOS -{ - - static TrainingDataView *g_pTrainingDataView{nullptr}; - - TrainingDataView::TrainingDataView() - { - SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); - g_pTrainingDataView = this; - } - - TrainingDataView::~TrainingDataView() - { - RemoveAll(); - DeInit(); - g_pTrainingDataView = nullptr; - } - - TrainingDataView *TrainingDataView::GetInstance() - { - return g_pTrainingDataView; - } - - /* InitView:初始化界面*/ - void TrainingDataView ::InitView() - { - // 初始化Image - InitImageView(image_progress, 13, 13, 440, 386, "image1", PROGRESS_IMAGE); - InitImageView(image_heart, 88, 295, 50, 50, "image2", SPORT_HEARTRATE_IMAGE); - InitImageView(image_iconup, 225, 396, 16, 10, "image4", INCO_UP_IMAGE); - InitImageView(image_iconpoint, 193, 421, 80, 20, "image5", DATA_POINT_IMAGE); - Add(image_progress); - Add(image_heart); - Add(image_iconup); - Add(image_iconpoint); - - // 初始化进度条 - circleProgress = new UICircleProgress(); - circleProgress->SetPosition(0, 0); - circleProgress->Resize(466, 466); - circleProgress->SetViewId("circleProgress"); - circleProgress->SetStyle(STYLE_BACKGROUND_OPA, 0x00); - circleProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000); - circleProgress->SetBackgroundStyle(STYLE_LINE_WIDTH, 12); - circleProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6); - circleProgress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); - circleProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff4fC34C); - circleProgress->SetForegroundStyle(STYLE_LINE_WIDTH, 10); - circleProgress->SetCenterPosition(235, 235); - circleProgress->SetRadius(215); - circleProgress->SetStartAngle(215); - circleProgress->SetEndAngle(505); - circleProgress->SetCapType(CAP_ROUND); - circleProgress->SetValue(0); - Add(circleProgress); - - // 初始化Lable - UIResourceTextId sport_id = TraingModel::GetInstance()->GetSportEvent(); - InitLabelExt(sportlabel, 83, 120, 300, 35, "label2", sport_id, DEFAULT_VECTOR_FONT_FILENAME, 30); - sportlabel->SetTextColor(Color::Gray()); - - InitLabel(curtimelabel, 155, 60, 150, 50, "label1", "23:54", DEFAULT_VECTOR_FONT_FILENAME, 40); - - InitLabel(timerlabel, 0, 163, 466, 150, "label3", "00:00:00", DEFAULT_VECTOR_FONT_FILENAME, 80); - InitLabel(heartlabel, 85, 284, 230, 80, "label4", "--", DEFAULT_VECTOR_FONT_FILENAME, 60); - InitLabel(ubpmlabel, 218, 284, 230, 80, "label5", "bpm", DEFAULT_VECTOR_FONT_FILENAME, 60); - ubpmlabel->SetTextColor(Color::Gray()); - Add(curtimelabel); - Add(sportlabel); - Add(timerlabel); - Add(heartlabel); - Add(ubpmlabel); +static TrainingDataView *g_pTrainingDataView{nullptr}; + +TrainingDataView::TrainingDataView() { + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + g_pTrainingDataView = this; +} + +TrainingDataView::~TrainingDataView() { + RemoveAll(); + DeInit(); + g_pTrainingDataView = nullptr; +} + +TrainingDataView *TrainingDataView::GetInstance() { + return g_pTrainingDataView; +} + +/* InitView:初始化界面*/ +bool TrainingDataView ::InitPage() { + // 初始化Image + InitImageView(image_progress, 13, 13, 440, 386, "image1", PROGRESS_IMAGE); + InitImageView(image_heart, 88, 295, 50, 50, "image2", SPORT_HEARTRATE_IMAGE); + InitImageView(image_iconup, 225, 396, 16, 10, "image4", INCO_UP_IMAGE); + InitImageView(image_iconpoint, 193, 421, 80, 20, "image5", DATA_POINT_IMAGE); + Add(image_progress); + Add(image_heart); + Add(image_iconup); + Add(image_iconpoint); + + // 初始化进度条 + circleProgress = new UICircleProgress(); + circleProgress->SetPosition(0, 0); + circleProgress->Resize(466, 466); + circleProgress->SetViewId("circleProgress"); + circleProgress->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + circleProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + circleProgress->SetBackgroundStyle(STYLE_LINE_WIDTH, 12); + circleProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff2195F6); + circleProgress->SetForegroundStyle(STYLE_BORDER_COLOR, 0xff000000); + circleProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff4fC34C); + circleProgress->SetForegroundStyle(STYLE_LINE_WIDTH, 10); + circleProgress->SetCenterPosition(235, 235); + circleProgress->SetRadius(215); + circleProgress->SetStartAngle(215); + circleProgress->SetEndAngle(505); + circleProgress->SetCapType(CAP_ROUND); + circleProgress->SetValue(0); + Add(circleProgress); + + // 初始化Lable + UIResourceTextId sport_id = TraingModel::GetInstance()->GetSportEvent(); + InitLabelExt(sportlabel, 83, 120, 300, 35, "label2", sport_id, + DEFAULT_VECTOR_FONT_FILENAME, 30); + sportlabel->SetTextColor(Color::Gray()); + + InitLabel(curtimelabel, 155, 60, 150, 50, "label1", "23:54", + DEFAULT_VECTOR_FONT_FILENAME, 40); + + InitLabel(timerlabel, 0, 163, 466, 150, "label3", "00:00:00", + DEFAULT_VECTOR_FONT_FILENAME, 80); + InitLabel(heartlabel, 85, 284, 230, 80, "label4", "--", + DEFAULT_VECTOR_FONT_FILENAME, 60); + InitLabel(ubpmlabel, 218, 284, 230, 80, "label5", "bpm", + DEFAULT_VECTOR_FONT_FILENAME, 60); + ubpmlabel->SetTextColor(Color::Gray()); + Add(curtimelabel); + Add(sportlabel); + Add(timerlabel); + Add(heartlabel); + Add(ubpmlabel); + + return true; #if 0 // 初始化Button @@ -100,108 +103,91 @@ namespace OHOS buttonNote->SetOnClickListener(static_cast(TraingCardPresenter::GetInstance())); Add(buttonNote); #endif - // 增加上拉卡片 - SetCoverable(true); - } - - /* DeInit:删除组件 */ - void TrainingDataView::DeInit() - { - RemoveAll(); - if (curtimelabel != nullptr) - { - curtimelabel = nullptr; - } - if (sportlabel != nullptr) - { - delete sportlabel; - sportlabel = nullptr; - } - if (timerlabel != nullptr) - { - delete timerlabel; - timerlabel = nullptr; - } - if (heartlabel != nullptr) - { - delete heartlabel; - heartlabel = nullptr; - } - if (ubpmlabel != nullptr) - { - delete ubpmlabel; - ubpmlabel = nullptr; - } - // 删除button - if (buttonNote != nullptr) - { - delete buttonNote; - buttonNote = nullptr; - } - - // 删除Image - if (image_lowIntensity != nullptr) - { - delete image_lowIntensity; - image_lowIntensity = nullptr; - } - if (image_iconup != nullptr) - { - delete image_iconup; - image_iconup = nullptr; - } - if (image_iconpoint != nullptr) - { - delete image_iconpoint; - image_iconpoint = nullptr; - } - if (circleProgress != nullptr) - { - delete circleProgress; - circleProgress = nullptr; - } - } - - void TrainingDataView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - } - - void TrainingDataView::UnLoad(void) {} - UILabelExt *TrainingDataView::GetTimeLabel() - { - return timerlabel; - } - UILabelExt *TrainingDataView::GetHeartLabel() - { - return heartlabel; - } - UICircleProgress *TrainingDataView::GetProgress() - { - return circleProgress; - } - /*更新当前时间*/ - void TrainingDataView::UpdataTime() - { - if (curtimelabel == nullptr) // 防止刷新空组件 - return; - - // 获取当前时间 - struct tm pTM; - time_t seconds; - time(&seconds); - localtime_r(&seconds, &pTM); - - // 解析时间 - int hour = pTM.tm_hour; - int minute = pTM.tm_min; - - // 将时间和日期转换为字符串 - std::string stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + (minute < 10 ? "0" : "") + std::to_string(minute); - curtimelabel->SetText(stringtime.c_str()); - } + // 增加上拉卡片 + // SetCoverable(true); +} + +/* DeInit:删除组件 */ +void TrainingDataView::DeInit() { + RemoveAll(); + if (curtimelabel != nullptr) { + curtimelabel = nullptr; + } + if (sportlabel != nullptr) { + delete sportlabel; + sportlabel = nullptr; + } + if (timerlabel != nullptr) { + delete timerlabel; + timerlabel = nullptr; + } + if (heartlabel != nullptr) { + delete heartlabel; + heartlabel = nullptr; + } + if (ubpmlabel != nullptr) { + delete ubpmlabel; + ubpmlabel = nullptr; + } + // 删除button + if (buttonNote != nullptr) { + delete buttonNote; + buttonNote = nullptr; + } + + // 删除Image + if (image_lowIntensity != nullptr) { + delete image_lowIntensity; + image_lowIntensity = nullptr; + } + if (image_iconup != nullptr) { + delete image_iconup; + image_iconup = nullptr; + } + if (image_iconpoint != nullptr) { + delete image_iconpoint; + image_iconpoint = nullptr; + } + if (circleProgress != nullptr) { + delete circleProgress; + circleProgress = nullptr; + } +} + +UILabelExt *TrainingDataView::GetTimeLabel() { return timerlabel; } +UILabelExt *TrainingDataView::GetHeartLabel() { return heartlabel; } +UICircleProgress *TrainingDataView::GetProgress() { return circleProgress; } +/*更新当前时间*/ +void TrainingDataView::UpdataTime() { + if (curtimelabel == nullptr) // 防止刷新空组件 + return; + + // 获取当前时间 + struct tm pTM; + time_t seconds; + time(&seconds); + localtime_r(&seconds, &pTM); + + // 解析时间 + int hour = pTM.tm_hour; + int minute = pTM.tm_min; + + // 将时间和日期转换为字符串 + std::string stringtime = (hour < 10 ? "0" : "") + std::to_string(hour) + ":" + + (minute < 10 ? "0" : "") + std::to_string(minute); + curtimelabel->SetText(stringtime.c_str()); +} + +bool TrainingDataView::InitView(void *caller) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingDataView InitView %p", + caller); + if (InitPage() == false) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDataView::InitPage fail"); + return false; + } + SetDraggable(true); + SetTouchable(true); + // SleepDataRefresh(); + return true; } +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp index a4518a683..cc77a9012 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp @@ -2,164 +2,145 @@ #include "traing/training_card/include/TrainingDetailView.h" #include "traing/training_card/include/TraingCardView.h" -#include "common/image_cache_manager.h" -#include "components/ui_label_ext.h" -#include "ui_resource_string.h" #include "UiConfig.h" -#include "ui_resource_image.h" -#include +#include "common/image_cache_manager.h" #include "components/ui_button.h" +#include "components/ui_label_ext.h" +#include "traing/Training_UiConfig.h" #include "traing/include/TraingModel.h" +#include "ui_resource_image.h" +#include "ui_resource_string.h" #include "uicomponents/UIComponents.h" -#include "traing/Training_UiConfig.h" - -namespace OHOS -{ - - static TrainingDetailView *g_pTrainingDetailView{nullptr}; - - TrainingDetailView::TrainingDetailView() - { - SetPosition(0, 0, 466, 466); - // SetStyle(STYLE_BACKGROUND_OPA, 0); - // SetStyle(STYLE_BORDER_RADIUS, 466); - g_pTrainingDetailView = this; - } - TrainingDetailView::~TrainingDetailView() - { - RemoveAll(); - DeInit(); - g_pTrainingDetailView = nullptr; - } - - TrainingDetailView *TrainingDetailView::GetInstance() - { - return g_pTrainingDetailView; - } - - /* InitView:初始化界面*/ - void TrainingDetailView ::InitView() - { - // 初始化Image - - InitImageView(progress_image, 0, 0, 100, 100, "image5", COLOR_PROGRESS_IMAGE); - // InitImageView(lineimage2_, 225, 190, 0, 0, "image", LINE_2_IMAGE); - if (lineimage2_ == nullptr) - { - lineimage2_ = new UIImageView(); - } - lineimage2_->SetPosition(232, 191); - lineimage2_->Resize(2, 82); - lineimage2_->SetViewId("image2"); - lineimage2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff333333); - lineimage2_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - lineimage2_->SetVisible(true); - - Add(progress_image); - Add(lineimage2_); - - // 初始化Lable - InitLabelExt(u_milelabel, 16, 234, 220, 35, "label2", STR_RANGE_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabelExt(u_stepslabel, 73, 362, 320, 35, "label3", STR_STEP_NUMBER, DEFAULT_VECTOR_FONT_FILENAME, 30); - InitLabelExt(u_calorielabel, 225, 235, 230, 35, "label4", STR_CALORIE_SETTING, DEFAULT_VECTOR_FONT_FILENAME, 30); - u_milelabel->SetTextColor(Color::Gray()); - u_stepslabel->SetTextColor(Color::Gray()); - u_calorielabel->SetTextColor(Color::Gray()); - - InitLabel(milelabel, 17, 160, 200, 80, "label6", "13.21", DEFAULT_VECTOR_FONT_FILENAME, 65); - InitLabel(calorielabel, 230, 160, 200, 80, "label7", "28312", DEFAULT_VECTOR_FONT_FILENAME, 65); - InitLabel(steplabel, 133, 285, 200, 80, "label8", "210.03", DEFAULT_VECTOR_FONT_FILENAME, 65); - Add(u_milelabel); - Add(u_stepslabel); - Add(u_calorielabel); - Add(milelabel); - Add(steplabel); - Add(calorielabel); +#include - InitButtonExt(intensity_button, 103, 70, 260, 80, "button", STR_LOWER_STRENGTH, 30); - Add(intensity_button); +namespace OHOS { - SetTouchable(true); - // SetIntercept(true); - } - /* DeInit:删除组件 */ - void TrainingDetailView::DeInit() - { - RemoveAll(); - if (u_milelabel != nullptr) - { - delete u_milelabel; - u_milelabel = nullptr; - } - if (u_stepslabel != nullptr) - { - delete u_stepslabel; - u_stepslabel = nullptr; - } - if (u_calorielabel != nullptr) - { - delete u_calorielabel; - u_calorielabel = nullptr; - } - if (milelabel != nullptr) - { - delete milelabel; - milelabel = nullptr; - } - if (steplabel != nullptr) - { - delete steplabel; - steplabel = nullptr; - } - if (calorielabel != nullptr) - { - delete calorielabel; - calorielabel = nullptr; - } +static TrainingDetailView *g_pTrainingDetailView{nullptr}; - if (progress_image != nullptr) - { - delete progress_image; - progress_image = nullptr; - } - if (lineimage2_ != nullptr) - { - delete lineimage2_; - lineimage2_ = nullptr; - } - if (intensity_button != nullptr) - { - delete intensity_button; - intensity_button = nullptr; - } - } +TrainingDetailView::TrainingDetailView() { + SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + // SetStyle(STYLE_BACKGROUND_OPA, 0); + // SetStyle(STYLE_BORDER_RADIUS, 466); + g_pTrainingDetailView = this; +} +TrainingDetailView::~TrainingDetailView() { + RemoveAll(); + DeInit(); + g_pTrainingDetailView = nullptr; +} - void TrainingDetailView::PreLoad(void) - { - if (!viewiInitStatus) - { - InitView(); - viewiInitStatus = true; - } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDetailView"); - } +TrainingDetailView *TrainingDetailView::GetInstance() { + return g_pTrainingDetailView; +} - void TrainingDetailView::UnLoad(void) {} +/* InitView:初始化界面*/ +bool TrainingDetailView ::InitPage() { + // 初始化Image + InitImageView(progress_image, 0, 0, 100, 100, "image5", COLOR_PROGRESS_IMAGE); + // InitImageView(lineimage2_, 225, 190, 0, 0, "image", LINE_2_IMAGE); + if (lineimage2_ == nullptr) { + lineimage2_ = new UIImageView(); + } + lineimage2_->SetPosition(232, 191); + lineimage2_->Resize(2, 82); + lineimage2_->SetViewId("image2"); + lineimage2_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff333333); + lineimage2_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + lineimage2_->SetVisible(true); + + Add(progress_image); + Add(lineimage2_); + + // 初始化Lable + InitLabelExt(u_milelabel, 16, 234, 220, 35, "label2", STR_RANGE_SETTING, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(u_stepslabel, 73, 362, 320, 35, "label3", STR_STEP_NUMBER, + DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(u_calorielabel, 225, 235, 230, 35, "label4", STR_CALORIE_SETTING, + DEFAULT_VECTOR_FONT_FILENAME, 30); + u_milelabel->SetTextColor(Color::Gray()); + u_stepslabel->SetTextColor(Color::Gray()); + u_calorielabel->SetTextColor(Color::Gray()); + + InitLabel(milelabel, 17, 160, 200, 80, "label6", "13.21", + DEFAULT_VECTOR_FONT_FILENAME, 65); + InitLabel(calorielabel, 230, 160, 200, 80, "label7", "28312", + DEFAULT_VECTOR_FONT_FILENAME, 65); + InitLabel(steplabel, 133, 285, 200, 80, "label8", "210.03", + DEFAULT_VECTOR_FONT_FILENAME, 65); + Add(u_milelabel); + Add(u_stepslabel); + Add(u_calorielabel); + Add(milelabel); + Add(steplabel); + Add(calorielabel); + + InitButtonExt(intensity_button, 103, 70, 260, 80, "button", + STR_LOWER_STRENGTH, 30); + Add(intensity_button); + + SetTouchable(true); + + return true; +} +/* DeInit:删除组件 */ +void TrainingDetailView::DeInit() { + RemoveAll(); + if (u_milelabel != nullptr) { + delete u_milelabel; + u_milelabel = nullptr; + } + if (u_stepslabel != nullptr) { + delete u_stepslabel; + u_stepslabel = nullptr; + } + if (u_calorielabel != nullptr) { + delete u_calorielabel; + u_calorielabel = nullptr; + } + if (milelabel != nullptr) { + delete milelabel; + milelabel = nullptr; + } + if (steplabel != nullptr) { + delete steplabel; + steplabel = nullptr; + } + if (calorielabel != nullptr) { + delete calorielabel; + calorielabel = nullptr; + } + + if (progress_image != nullptr) { + delete progress_image; + progress_image = nullptr; + } + if (lineimage2_ != nullptr) { + delete lineimage2_; + lineimage2_ = nullptr; + } + if (intensity_button != nullptr) { + delete intensity_button; + intensity_button = nullptr; + } +} - UILabelExt *TrainingDetailView::GetMileLabel() - { - return milelabel; - } - UILabelExt *TrainingDetailView::GetStepLabel() - { - return steplabel; - } - UILabelExt *TrainingDetailView::GetCalorieLabel() - { - return calorielabel; - } - UILabelButtonExt *TrainingDetailView::Get_Intensity_Button() - { - return intensity_button; - } +bool TrainingDetailView::InitView(void *caller) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TrainingDetailView InitView %p", + caller); + if (InitPage() == false) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TrainingDetailView::InitPage fail"); + return false; + } + SetDraggable(true); + SetTouchable(true); + // SleepDataRefresh(); + return true; +} +UILabelExt *TrainingDetailView::GetMileLabel() { return milelabel; } +UILabelExt *TrainingDetailView::GetStepLabel() { return steplabel; } +UILabelExt *TrainingDetailView::GetCalorieLabel() { return calorielabel; } +UILabelButtonExt *TrainingDetailView::Get_Intensity_Button() { + return intensity_button; } +} // namespace OHOS