203 lines
6.4 KiB
C++
203 lines
6.4 KiB
C++
#ifndef TJDUIAPP_HR_VIEW_H
|
||
#define TJDUIAPP_HR_VIEW_H
|
||
|
||
#include "ChangeSliceListener.h"
|
||
#include "TjdUiAppHrPresenter.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_picker.h"
|
||
#include "ui_swipe_view.h"
|
||
#include <array>
|
||
#include <vector>
|
||
|
||
namespace TJD {
|
||
|
||
#define HR_SWIPEVIEW_ID "swipeContainer_"
|
||
|
||
class HrFlickerTimer : public OHOS::GraphicTimer
|
||
{
|
||
public:
|
||
HrFlickerTimer(int32_t periodMs, GraphicTimerCb cb, void *arg, bool isPeriodic = false)
|
||
: OHOS::GraphicTimer(periodMs, cb, arg, isPeriodic)
|
||
{
|
||
label_ = static_cast<OHOS::UILabel *>(arg);
|
||
}
|
||
~HrFlickerTimer() {}
|
||
void Start();
|
||
void Stop();
|
||
|
||
private:
|
||
OHOS::UILabel *label_{nullptr};
|
||
};
|
||
|
||
class HrOnClickedListener : public OHOS::UIView::OnClickListener
|
||
{
|
||
public:
|
||
HrOnClickedListener() {}
|
||
~HrOnClickedListener() {}
|
||
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override;
|
||
|
||
private:
|
||
};
|
||
|
||
//===================================================================
|
||
class HeratRateScrollPickerCallback : public OHOS::AnimatorCallback
|
||
{
|
||
public:
|
||
HeratRateScrollPickerCallback() {}
|
||
~HeratRateScrollPickerCallback() {}
|
||
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 HeratRateScrollPicker : public OHOS::UIScrollView
|
||
{
|
||
public:
|
||
HeratRateScrollPicker();
|
||
~HeratRateScrollPicker();
|
||
|
||
void DateInit(uint8_t value);
|
||
void UpdateLabels();
|
||
void ResetLabelPositions();
|
||
bool CheckValueChanges(uint8_t value);
|
||
uint8_t hrValues_;
|
||
uint8_t preValues_;
|
||
bool needsUpdate_{false};
|
||
bool directions_{false};
|
||
|
||
private:
|
||
OHOS::UILabel label[3];
|
||
};
|
||
|
||
class TjdUiAppHrPresenter;
|
||
class TjdUiAppHrView : public OHOS::View<TjdUiAppHrPresenter>, public OHOS::UIViewGroup
|
||
{
|
||
public:
|
||
TjdUiAppHrView();
|
||
~TjdUiAppHrView();
|
||
static TjdUiAppHrView *GetInstance(void);
|
||
void OnStart() override;
|
||
void OnStop() override;
|
||
|
||
void ChangedView(HrView view, HrView hideView);
|
||
void UpdateHrViewData(uint32_t index, uint8_t hrValue);
|
||
OHOS::UIImageAnimatorView *GetAnimatorView(void);
|
||
OHOS::UISwipeViewNested *GetSwipeView(void) { return swipeContainer_; }
|
||
void InitViewData(void);
|
||
void SetScrollPickerVisible(bool visible)
|
||
{
|
||
leftScrollPicker->SetVisible(visible);
|
||
midScrollPicker->SetVisible(visible);
|
||
rightScrollPicker->SetVisible(visible);
|
||
}
|
||
|
||
HrView curView;
|
||
HrFlickerTimer *flickerTimer{nullptr};
|
||
OHOS::UIImageAnimatorView *imageAnimator1_ = nullptr;
|
||
static uint8_t herarRateWaitTime_;
|
||
// static uint8_t currentLowValue; // 当前选中值(初始为1)
|
||
// static uint8_t currentMidValue; // 当前选中值(初始为1)
|
||
// static uint8_t currentHighValue; // 当前选中值(初始为1)
|
||
void ScrollPickerDataInit(uint16_t value)
|
||
{
|
||
leftScrollPicker->DateInit(value / 100);
|
||
midScrollPicker->DateInit(value / 10 % 10);
|
||
rightScrollPicker->DateInit(value % 10);
|
||
}
|
||
void UpdateRodViewGroup(void);
|
||
|
||
private:
|
||
void InitImageInfo(void);
|
||
void Container1Init(void);
|
||
void Container2Init(void);
|
||
void AboutViewInit(void);
|
||
void UnwearViewInit(void);
|
||
|
||
bool ShowSwipeView(HrView hideView);
|
||
bool ShowAboutView(HrView hideView);
|
||
bool ShowUnwearView(HrView hideView);
|
||
|
||
HrChangeView viewMapper_[HRMAX_VIEW] = {
|
||
&TjdUiAppHrView::ShowSwipeView,
|
||
&TjdUiAppHrView::ShowAboutView,
|
||
&TjdUiAppHrView::ShowUnwearView,
|
||
};
|
||
|
||
OHOS::UISwipeView::OnSwipeListener *onSwipeListener_{nullptr};
|
||
OHOS::UIView::OnDragListener *OnDragListener_{nullptr};
|
||
|
||
OHOS::UIViewGroup *containerAll_{nullptr};
|
||
OHOS::UIViewGroup *groupList_[HrView::HRMAX_VIEW]{nullptr};
|
||
OHOS::UISwipeViewNested *swipeContainer_ = nullptr;
|
||
OHOS::UIViewGroup *container1_ = nullptr;
|
||
OHOS::UIViewGroup *container2_ = nullptr;
|
||
OHOS::UIViewGroup *AboutView_ = nullptr;
|
||
OHOS::UIViewGroup *UnwearView_ = nullptr;
|
||
|
||
OHOS::UIChartDataSerial *dataSerial_ = nullptr;
|
||
OHOS::UIChartPolyline *uiChart1_ = nullptr;
|
||
OHOS::UIImageView *image1_ = nullptr;
|
||
OHOS::UIImageView *image2_ = nullptr;
|
||
OHOS::UIImageView *image3_ = nullptr;
|
||
OHOS::UIImageView *image4_ = nullptr;
|
||
OHOS::UIImageView *imageAbout_ = nullptr;
|
||
HrOnClickedListener *swipe1ImageLister = nullptr;
|
||
OHOS::UILabel *label1Num200_ = nullptr;
|
||
OHOS::UILabel *label1Num150_ = nullptr;
|
||
OHOS::UILabel *label1Num100_ = nullptr;
|
||
OHOS::UILabel *label1Num50_ = nullptr;
|
||
OHOS::UILabel *hrMax_ = nullptr;
|
||
OHOS::UILabel *hrMin_ = nullptr;
|
||
OHOS::UILabel *hrCurValue_ = nullptr;
|
||
OHOS::UILabelExt *hrUnit_ = nullptr;
|
||
|
||
OHOS::UIImageView *image5_ = nullptr;
|
||
OHOS::UIImageView *image6_ = nullptr;
|
||
OHOS::UILabel *label2Num200_ = nullptr;
|
||
OHOS::UILabel *label2Num150_ = nullptr;
|
||
OHOS::UILabel *label2Num100_ = nullptr;
|
||
OHOS::UILabel *label2Num50_ = nullptr;
|
||
OHOS::UILabelExt *hrText1_ = nullptr;
|
||
OHOS::UILabelExt *hrText2_ = nullptr;
|
||
OHOS::UIView *view1_ = nullptr;
|
||
UIView *rodViewGroup[7]{nullptr};
|
||
|
||
OHOS::UILabelExt *aboutText = nullptr;
|
||
OHOS::UIImageView *aboutImg = nullptr;
|
||
HrOnClickedListener *aboutImageLister = nullptr;
|
||
|
||
OHOS::UILabelExt *unwearText1 = nullptr;
|
||
OHOS::UILabelExt *unwearText2 = nullptr;
|
||
OHOS::UIImageView *unwearImg1 = nullptr;
|
||
HrOnClickedListener *unwearImageLister = nullptr;
|
||
OHOS::UIImageView *unwearImg2 = nullptr;
|
||
|
||
HeratRateScrollPicker *leftScrollPicker = nullptr;
|
||
HeratRateScrollPicker *midScrollPicker = nullptr;
|
||
HeratRateScrollPicker *rightScrollPicker = nullptr;
|
||
OHOS::Animator *leftAnimator_{nullptr};
|
||
OHOS::Animator *midAnimator_{nullptr};
|
||
OHOS::Animator *rightAnimator_{nullptr};
|
||
HeratRateScrollPickerCallback *leftCallback_ = nullptr;
|
||
HeratRateScrollPickerCallback *midCallback_ = nullptr;
|
||
HeratRateScrollPickerCallback *rightCallback_ = nullptr;
|
||
};
|
||
|
||
} // namespace TJD
|
||
#endif
|