mcu_hi3321_watch/tjd/ui/app/spo2/TjdUiAppBloodOxygenView.h
2025-05-26 20:15:20 +08:00

210 lines
6.4 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*----------------------------------------------------------------------------
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
*
* Description:
*
* Author: wuchangxin
*
* Create: 2024-6-23
*--------------------------------------------------------------------------*/
#ifndef TJDUI_APP_SPO2_H
#define TJDUI_APP_SPO2_H
#include "ChangeSliceListener.h"
#include "TjdUiAppBloodOxygenPresenter.h"
#include "View.h"
#include "components/ui_chart.h"
#include "components/ui_image_animator.h"
#include "components/ui_image_view.h"
#include "components/ui_label.h"
#include "components/ui_swipe_view_nested.h"
#include "graphic_timer.h"
#include "ui_label_ext.h"
#include "ui_swipe_view.h"
namespace TJD {
class SpO2FlickerTimer : public OHOS::GraphicTimer
{
public:
SpO2FlickerTimer(int32_t periodMs, GraphicTimerCb cb, void *arg, bool isPeriodic = false)
: OHOS::GraphicTimer(periodMs, cb, arg, isPeriodic)
{
label_ = static_cast<OHOS::UILabel *>(arg);
}
~SpO2FlickerTimer() {}
void Start();
void Stop();
private:
OHOS::UILabel *label_{nullptr};
};
class Spo2ScrollPickerCallback : public OHOS::AnimatorCallback
{
public:
Spo2ScrollPickerCallback() {}
~Spo2ScrollPickerCallback() {}
void Callback(OHOS::UIView *view);
void OnStop(OHOS::UIView &view) {}
void SetAnimator(OHOS::Animator *animator) { animator_ = animator; }
bool GetState() { return state_; };
private:
bool state_{false};
OHOS::Animator *animator_{nullptr};
uint8_t cnt = 0;
void CycleLabelsUp(OHOS::UIView *view);
// 数字向下循环0→1→2→0
void CycleLabelsDown(OHOS::UIView *view);
};
class Spo2ScrollPicker : public OHOS::UIScrollView
{
public:
Spo2ScrollPicker();
~Spo2ScrollPicker();
void DateInit(uint8_t value);
void UpdateLabels();
void ResetLabelPositions();
bool CheckValueChanges(uint8_t value);
uint8_t spo2Values_;
uint8_t preValues_;
bool needsUpdate_{false};
bool directions_{false};
private:
OHOS::UILabel label[3];
};
class TjdUiAppSpO2OnClickedListener : public OHOS::UIView::OnClickListener
{
public:
TjdUiAppSpO2OnClickedListener(void) {}
virtual ~TjdUiAppSpO2OnClickedListener(void) {}
virtual bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event);
private:
};
class TjdUiAppSpO2Presenter;
class TjdUiAppSpO2View : public OHOS::View<TjdUiAppSpO2Presenter>, public OHOS::UIViewGroup
{
public:
TjdUiAppSpO2View();
~TjdUiAppSpO2View();
static TjdUiAppSpO2View *GetInstance(void);
void InitSpO2List();
void OnStart() override;
void OnStop() override;
void ChangedView(SpO2View view, SpO2View hideView);
OHOS::UIImageAnimatorView *GetAnimatorView(void);
void UpdateSpO2ViewData(uint32_t index, uint8_t SpO2Value);
SpO2View curView;
SpO2FlickerTimer *flickerTimer_{nullptr};
OHOS::UILabel *SpO2_Cur_ = nullptr;
void SetScrollPickerVisible(bool visible)
{
unit_->SetVisible(visible);
leftScrollPicker->SetVisible(visible);
rightScrollPicker->SetVisible(visible);
}
void ScrollPickerDataInit(uint16_t value)
{
leftScrollPicker->DateInit(value / 100);
rightScrollPicker->DateInit(value % 10);
}
void UpdateRodViewGroup(void);
void InitRodViewInfo(void);
static uint8_t spo2WaitTime_;
private:
OHOS::UILabel *lblTitle_{nullptr};
void SpO2MainViewInit(void);
void SpO2AverageViewInit(void);
void SpO2RemindViewInit(void);
void SpO2UnwearViewInit(void);
void ImageInfoInit(void);
bool ShowSwipeView(SpO2View hideView);
bool ShowRemindView(SpO2View hideView);
bool ShowUnwearView(SpO2View hideView);
uint8_t SpO2ValueRodValue(uint8_t SpO2Value);
OHOS::UIViewGroup *groupList_[SpO2View::SPO2MAX_VIEW]{nullptr};
OHOS::UISwipeView::OnSwipeListener *onSwipeListener_{nullptr};
OHOS::UIView::OnDragListener *OnDragListener_{nullptr};
OHOS::UISwipeViewNested *swipeContainer_ = nullptr;
// SpO2MainViewInit
OHOS::Point array[288];
OHOS::UIViewGroup *SpO2_container_{nullptr};
OHOS::UIViewGroup *containerAll_{nullptr};
OHOS::UIImageView *image_chart_time = nullptr;
OHOS::UIChartDataSerial *dataSerial_ = nullptr;
OHOS::UIChartPolyline *uiChart1_ = nullptr;
OHOS::UIImageView *image_high = nullptr;
OHOS::UIImageView *image_pull_up = nullptr;
OHOS::UIImageView *image_about = nullptr;
OHOS::UIImageView *image_low = nullptr;
OHOS::UILabel *labelNum100_ = nullptr;
OHOS::UILabel *labelNum90_ = nullptr;
OHOS::UILabel *labelNum80_ = nullptr;
OHOS::UILabel *labelNum70_ = nullptr;
OHOS::UILabel *SpO2_Max_ = nullptr;
OHOS::UILabel *SpO2_Min_ = nullptr;
OHOS::UIImageAnimatorView *imageAnimator_ = nullptr;
// SpO2AverageViewInit
OHOS::UIViewGroup *Average_container_{nullptr};
OHOS::UIImageView *image5_ = nullptr;
OHOS::UIImageView *image6_ = nullptr;
OHOS::UILabel *label2Num100_ = nullptr;
OHOS::UILabel *label2Num90_ = nullptr;
OHOS::UILabel *label2Num80_ = nullptr;
OHOS::UILabel *label2Num70_ = nullptr;
OHOS::UILabelExt *SpO2_Text1_ = nullptr;
OHOS::UILabelExt *SpO2_Text2_ = nullptr;
OHOS::UIView *view1_ = nullptr;
UIView *rodViewGroup[7]{nullptr};
uint8_t rodViewY[7]{0};
uint8_t rodViewHeight[7]{0};
// SpO2RemindViewInit
OHOS::UIViewGroup *RemindView_ = nullptr;
OHOS::UILabelExt *remindText = nullptr;
OHOS::UIImageView *remindImg = nullptr;
// SpO2UnwearViewInit
OHOS::UIViewGroup *UnwearView_ = nullptr;
OHOS::UILabelExt *unwearText1 = nullptr;
OHOS::UILabelExt *unwearText2 = nullptr;
OHOS::UIImageView *unwearImg1 = nullptr;
OHOS::UIImageView *unwearImg2 = nullptr;
TjdUiAppSpO2OnClickedListener *imgAboutListener_{nullptr};
TjdUiAppSpO2OnClickedListener *imgRemindListener_{nullptr};
TjdUiAppSpO2OnClickedListener *imgUnwearListener_{nullptr};
SpO2ChangeView viewMapper_[SPO2MAX_VIEW] = {
&TjdUiAppSpO2View::ShowSwipeView,
&TjdUiAppSpO2View::ShowRemindView,
&TjdUiAppSpO2View::ShowUnwearView,
};
OHOS::UILabel *unit_ = nullptr;
Spo2ScrollPicker *leftScrollPicker = nullptr;
Spo2ScrollPicker *rightScrollPicker = nullptr;
OHOS::Animator *leftAnimator_{nullptr};
OHOS::Animator *rightAnimator_{nullptr};
Spo2ScrollPickerCallback *leftCallback_ = nullptr;
Spo2ScrollPickerCallback *rightCallback_ = nullptr;
};
} // namespace TJD
#endif