From 2f3b0365b915f9073e5b998657cd882052218dff Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Tue, 30 Jul 2024 19:51:33 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E6=A3=80=E6=B5=8B=E6=97=A0?= =?utf8?q?=E6=95=88=E6=95=B0=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../heart_blood/CheckAbnormalPresenter.cpp | 87 ++++++++ .../heart_blood/CheckAbnormalPresenter.h | 44 ++++ .../heart_blood/CheckAbnormalView.cpp | 205 ++++++++++++++++++ .../nativeui/heart_blood/CheckAbnormalView.h | 72 ++++++ 4 files changed, 408 insertions(+) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.h diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.cpp new file mode 100644 index 000000000..9743b4b72 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: bloodOxygen view + * Author: + * Create: 2021-08-01 + */ + +#include "heart_blood/CheckAbnormalPresenter.h" +#include "common/task_manager.h" +#include "BloodOxygenModel.h" + +#include "bloodoxygen/include/BloodDetectionView.h" +#include "heart_blood/CheckAbnormalView.h" + +#include "components/ui_label.h" +#include "components/ui_label_ext.h" + +#include "ChangeSliceListener.h" +#include "broadcast_service.h" +#include +#include "iostream" +#include +#include +#include +#include +#include "wearable_log.h" +#include "cmsis_os.h" +#include "securec.h" +#include "broadcast_service.h" +#include "graphic_service.h" +#include +#include +#include + +#include "ppg_service.h" +#include "displaybrightness/include/DisplayBrightnessModel.h" +#include "power_display_service.h" +#include "custom_utils.h" +#include "cywee_service.h" + +#include "MainModel.h" + +namespace OHOS +{ + + static CheckAbnormalPresenter *g_pCheckAbnormalPresenter; + + CheckAbnormalPresenter::CheckAbnormalPresenter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CheckAbnormalPresenter::new CheckAbnormalPresenter"); + g_pCheckAbnormalPresenter = this; + } + CheckAbnormalPresenter::~CheckAbnormalPresenter() + { + g_pCheckAbnormalPresenter = nullptr; + } + CheckAbnormalPresenter *CheckAbnormalPresenter::GetInstance() + { + return g_pCheckAbnormalPresenter; + } + void CheckAbnormalPresenter::OnStart() + { + Presenter::OnStart(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CheckAbnormalPresenter::On Start "); + } + void CheckAbnormalPresenter::OnPause(void) {} + + void CheckAbnormalPresenter::OnResume(void) {} + + void CheckAbnormalPresenter::OnStop(void) {} + + bool CheckAbnormalPresenter::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodPresenter::OnClick"); + + if (strcmp(view.GetViewId(), CLICK_BLOOD_STOP) == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_ZOOM); + } + if (strcmp(view.GetViewId(), CLICK_BLOOD_RE) == 0) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_BLOODOXY_CHECK, TransitionType::TRANSITION_ZOOM); + } + return true; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.h new file mode 100644 index 000000000..a420c9bc6 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.h @@ -0,0 +1,44 @@ +/*** + * @Date: 2024-07-30 11:22:09 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-30 16:39:17 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.h + */ + +#ifndef CHECK_ABNORMAL_PRESENTER_H +#define CHECK_ABNORMAL_PRESENTER_H + +#include "Presenter.h" +#include "ModelListenerSample.h" +#include "components/ui_circle_progress.h" +#include "ohos_types.h" +#include "KeyInputListener.h" +#include "common/key_code.h" +#include "heart_blood/CheckAbnormalView.h" + +namespace OHOS +{ + static constexpr const char *CLICK_BLOOD_STOP = "clickbloodstop"; // 血氧检测暂停 + static constexpr const char *CLICK_BLOOD_RE = "clickbloodre"; // 血氧检测重新 + + class CheckAbnormalView; + class CheckAbnormalPresenter : public Presenter, + public UIView::OnClickListener, + + public UIView::OnDragListener + { + public: + CheckAbnormalPresenter(); + virtual ~CheckAbnormalPresenter(); + static CheckAbnormalPresenter *GetInstance(void); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + bool OnClick(UIView &view, const ClickEvent &event) override; + }; +} + +#endif diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.cpp new file mode 100644 index 000000000..2de5203ee --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.cpp @@ -0,0 +1,205 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-30 16:39:56 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/CheckAbnormalView.cpp + */ + +#include "common/image_cache_manager.h" +#include "ui_resource_image.h" +#include +#include "components/ui_button.h" +#include "MainViewSample.h" +#include "components/ui_view_group.h" +#include "DialModelSPO2.h" +#include "DialModelHeartRate.h" +#include "BloodOxygenModel.h" + +#include "UiConfig.h" +#include "uicomponents/UIComponents.h" +#include "MainPresenterSample.h" + +#include "heart_blood/CheckAbnormalPresenter.h" +#include "heart_blood/CheckAbnormalView.h" + +#include "vibrator_service.h" +extern "C" void custom_VibratorFunc(OHOS::VibratorType vibratorType); +namespace OHOS +{ + static CheckAbnormalView *g_pCheckAbnormalView{nullptr}; + static const char *BLOOD_PATH_NOTE = "/user/res/Blood/Error.bin"; + + CheckAbnormalView::CheckAbnormalView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::CheckAbnormalView"); + g_pCheckAbnormalView = this; + } + + CheckAbnormalView::~CheckAbnormalView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::~CheckAbnormalView"); + DeInit(); + g_pCheckAbnormalView = nullptr; + } + + CheckAbnormalView *CheckAbnormalView::GetInstance() + { + return g_pCheckAbnormalView; + } + + /* -------------------------------------------------------------------------- */ + /*** + * @description: + * @return 添加按键是否成功 + */ + bool CheckAbnormalView::AddButton() + { + InitButtonExt(StButton, 58, 320, 170, 90, CLICK_BLOOD_STOP, STR_STOP, 30); + StButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); // 设置按键颜色 + StButton->SetOnClickListener(presenter_); + + InitButtonExt(ReButton, 238, 320, 170, 90, CLICK_BLOOD_RE, STR_RECHECK, 30); + ReButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xffFF8A36); // 设置按键颜色 + ReButton->SetOnClickListener(presenter_); + + container_->Add(StButton); + container_->Add(ReButton); + return true; + } + /*** + * @description: + * @return 初始化标签是否成功 + */ + bool CheckAbnormalView::InitLable() + { + /*初始化title*/ + InitLabelExt(titleLabel, 83, 50, 300, 35, "title", STR_CHECKERROR, DEFAULT_VECTOR_FONT_FILENAME, 30); + InitLabelExt(noteLabel, 53, 230, 360, 70, "time", STR_WAERKEEP, DEFAULT_VECTOR_FONT_FILENAME, 30); + // 设置来回滚动属性 + noteLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + noteLabel->SetRollSpeed(70); + + container_->Add(titleLabel); + container_->Add(noteLabel); + return true; + } + /*** + * @description: + * @return 初始化背景是否成功 + */ + bool CheckAbnormalView::Initbackground() + { + + noteimage = new UIImageView(); + noteimage->SetPosition(193, 120, 80, 80); + noteimage->SetSrc(BLOOD_PATH_NOTE); + + container_->Add(noteimage); + return true; + } + /*** + * @description: + * @return 是否初始化成功 + */ + bool CheckAbnormalView::CheckAbnormalViewInit() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bool CheckAbnormalView::InitView()"); + if (!Initbackground()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Initbackground error!"); + }; + if (!InitLable()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitLable error!"); + }; + if (!AddButton()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AddButton error!"); + }; + return true; + } + /*** + * @description: + * @return 删除组件 + */ + void CheckAbnormalView::DeInit() + { + if (StButton != nullptr) + { + delete StButton; + StButton = nullptr; + } + if (ReButton != nullptr) + { + delete ReButton; + ReButton = nullptr; + } + if (noteLabel != nullptr) + { + delete noteLabel; + noteLabel = nullptr; + } + if (titleLabel != nullptr) + { + delete titleLabel; + titleLabel = nullptr; + } + if (noteimage != nullptr) + { + delete noteimage; + noteimage = nullptr; + } + } + + void CheckAbnormalView::OnStart() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::OnStart"); + View::OnStart(); + + SetContainerView(new UIViewGroup()); + container_->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + + if (!CheckAbnormalViewInit()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::InitBloodView fail"); + } + + custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒 + + RootView::GetInstance()->Add(container_); + SetContainerView(container_); + + container_->SetDraggable(true); + container_->SetTouchable(true); + container_->SetOnDragListener(presenter_); + + // 增加按键监听 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::CheckAbnormalPresenter::GetInstance(); + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + } + void CheckAbnormalView::OnSetUpView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::OnSetUpView"); + View::OnSetUpView(); + Draw(); + } + void CheckAbnormalView::OnTearDownView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::OnTearDownView"); + View::OnTearDownView(); + return; + } + + void CheckAbnormalView::OnStop() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::OnStop"); + View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } + return; + } +} diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.h b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.h new file mode 100644 index 000000000..855637b61 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.h @@ -0,0 +1,72 @@ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-30 11:46:23 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/CheckAbnormalView.h + */ +/*** + * @Date: 2024-04-15 10:55:58 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-05-07 18:51:13 + * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/CheckAbnormalView.h + */ +/* + * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. + * Description: bloodResult view + * Author: + * Create: 2021-08-01 + */ + +#ifndef CHECK_ABNORMAL_VIEW_H +#define CHECK_ABNORMAL_VIEW_H + +#include "View.h" +#include "BaseView.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_label_button.h" +#include "components/ui_image_animator.h" +#include "components/ui_circle_progress.h" +#include "components/ui_view_group.h" +#include "heart_blood/CheckAbnormalPresenter.h" + +#include "components/ui_scroll_view.h" +#include "components/ui_label_button_ext.h" +namespace OHOS +{ + class CheckAbnormalPresenter; + class CheckAbnormalView : public View + { + public: + CheckAbnormalView(); + virtual ~CheckAbnormalView(); + static CheckAbnormalView *GetInstance(void); + + void OnStop() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStart() override; + + bool CheckAbnormalViewInit(); + + void DeInit(); + bool AddButton(); + bool InitLable(); + bool Initbackground(); + + private: + // 提醒图标 + UIImageView *noteimage = nullptr; + // 按键 + UILabelButtonExt *StButton = nullptr; + UILabelButtonExt *ReButton = nullptr; + // 提醒label + UILabelExt *titleLabel = nullptr; + UILabelExt *noteLabel = nullptr; + }; +} + +#endif // 血氧主界面 \ No newline at end of file -- 2.17.1