/*---------------------------------------------------------------------------- * Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved. * * Description: * * Author: wuchangxin * * Create: 2024-6-23 *--------------------------------------------------------------------------*/ #ifndef TJDUI_APP_SPO2_PRESENTER_H #define TJDUI_APP_SPO2_PRESENTER_H #include "Presenter.h" #include "components/ui_view.h" #include "ui_swipe_view.h" #include "graphic_timer.h" #include "components/root_view.h" #include "dock/input_device.h" #include "TjdUiScreenDrag.h" #include "TjdUiTaskListener.h" namespace TJD { enum SpO2View { SPO2SWIPE_VIEW = 0, SPO2REMIND_VIEW, SPO2UNWEAR_VIEW, SPO2MAX_VIEW }; enum class SpO2Action { Start, Stop, GetStatus, }; class TjdUiAppSpO2View; typedef bool (TjdUiAppSpO2View::*SpO2ChangeView)(SpO2View hideView); class TjdUiAppSpO2Presenter : public OHOS::Presenter, public TjdUiTaskListener, public TjdUiScreenDragListener, public OHOS::UISwipeView::OnSwipeListener, public OHOS::UIView::OnClickListener, public OHOS::RootView::OnKeyActListener { public: TjdUiAppSpO2Presenter(); virtual ~TjdUiAppSpO2Presenter(); static TjdUiAppSpO2Presenter *GetInstance(void); void OnStart() override; void OnPause() override; void OnResume() override; void OnStop() override; void Notify(void) override; void OnSwipe(OHOS::UISwipeView& view) override; // bool OnDragStart(OHOS::UIView &view, const OHOS::DragEvent &event) override; // bool OnDrag(OHOS::UIView &view, const OHOS::DragEvent &event) override; // bool OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event) override; bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override; bool OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event) override; void ScreenDragEventCallback(OHOS::UIView &view, const OHOS::DragEvent &event) override { ExitSpO2View(); }; void TimeTaskStart(void); void TimeTaskStop(void); uint8_t SpO2ControlHandler(SpO2Action action, void *param); uint8_t SpO2GetWearStatus(void); void SpO2Process(void); uint32_t GetCurTimeIndex(void); void SpO2PointArrayInit(void); OHOS::Point *GetSpO2PointArray(void); uint8_t exitTimerCount_{0}; uint8_t GetSpO2Value(void) {return spo2CurValue;} private: bool needsUpdate_{false}; bool isExit_{false}; int16_t dragStartX_{0}; int16_t dragCurrentX_{0}; int32_t dragDistance_{0}; bool timerFlag{false}; bool refreshStatus{true}; uint8_t refreshCount{0}; OHOS::Point *SpO2PointArray{nullptr}; OHOS::GraphicTimer* timer_{nullptr}; uint8_t spo2CurValue{0}; void ExitSpO2View(void); }; } // namespace TJD #endif