191 lines
4.8 KiB
C++
191 lines
4.8 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description: TjdUiAppCompassView.h
|
|
*
|
|
* Author: wuchangxin@ss-tjd.com
|
|
*
|
|
* Create: 2025-02-25
|
|
*--------------------------------------------------------------------------*/
|
|
#ifndef TJDUIAPP_COMPASS_VIEW
|
|
#define TJDUIAPP_COMPASS_VIEW
|
|
|
|
#include "TjdUiAppCompassPresenter.h"
|
|
#include "View.h"
|
|
#include "components/ui_image_view.h"
|
|
#include "components/ui_label.h"
|
|
#include "components/ui_scroll_view.h"
|
|
#include "components/ui_scroll_view_nested.h"
|
|
#include "graphic_timer.h"
|
|
#include "msensor_api.h"
|
|
#include "ui_label_ext.h"
|
|
#include "ui_view_group.h"
|
|
#include <list>
|
|
#include <map>
|
|
namespace TJD {
|
|
|
|
enum CompassView
|
|
{
|
|
VIEW_COMPASS_CALIBRATION = 0, // 校准页面
|
|
VIEW_COMPASS_SHOW, //指南针显示页
|
|
VIEW_COMPASS_DATA, //指南针数据页
|
|
VIEW_COMPASS_MAX
|
|
};
|
|
|
|
class CompassUIScrollView : public OHOS::UIScrollViewNested
|
|
{
|
|
public:
|
|
CompassUIScrollView() {}
|
|
~CompassUIScrollView() {}
|
|
bool OnDragStartEvent(const OHOS::DragEvent &event) override;
|
|
bool OnDragEvent(const OHOS::DragEvent &event) override;
|
|
bool OnDragEndEvent(const OHOS::DragEvent &event) override;
|
|
|
|
private:
|
|
bool isOnStart_{false};
|
|
};
|
|
|
|
class CompassViewBase : public OHOS::UIScrollView
|
|
{
|
|
public:
|
|
CompassViewBase() { SetHorizontalScrollState(false); }
|
|
virtual ~CompassViewBase() {}
|
|
virtual void ShowView() { SetVisible(true); };
|
|
virtual void HideView() { SetVisible(false); };
|
|
};
|
|
|
|
#pragma region 指南针校准页面
|
|
class CompassCalibrationView : public CompassViewBase
|
|
{
|
|
public:
|
|
CompassCalibrationView();
|
|
~CompassCalibrationView();
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
|
|
private:
|
|
OHOS::UILabelExt tip_;
|
|
OHOS::UIImageView ImgGuide_;
|
|
};
|
|
#pragma endregion 指南针校准页面
|
|
|
|
#pragma region 指南针显示页面
|
|
class ShowViewAnimatorCallback : public OHOS::AnimatorCallback
|
|
{
|
|
public:
|
|
explicit ShowViewAnimatorCallback(OHOS::UIImageView *compassBg, OHOS::UILabel *direction, OHOS::UILabel *azimuth)
|
|
{
|
|
direction_ = direction;
|
|
compassBg_ = compassBg;
|
|
azimuth_ = azimuth;
|
|
}
|
|
~ShowViewAnimatorCallback()
|
|
{
|
|
direction_ = nullptr;
|
|
compassBg_ = nullptr;
|
|
azimuth_ = nullptr;
|
|
}
|
|
void Callback(OHOS::UIView *view);
|
|
|
|
private:
|
|
OHOS::UILabel *direction_{nullptr};
|
|
OHOS::UIImageView *compassBg_{nullptr};
|
|
OHOS::UILabel *azimuth_{nullptr};
|
|
};
|
|
class CompassShowView : public CompassViewBase
|
|
{
|
|
public:
|
|
CompassShowView();
|
|
~CompassShowView();
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
|
|
private:
|
|
OHOS::UILabel compassDirection_;
|
|
OHOS::UILabel compassAzimuth_;
|
|
OHOS::UIImageView compassBg_;
|
|
OHOS::UIImageView compassFg_;
|
|
OHOS::UIImageView compassPoint_;
|
|
OHOS::UIImageView compassList_;
|
|
|
|
ShowViewAnimatorCallback *callback_{nullptr};
|
|
};
|
|
|
|
#pragma endregion 指南针显示页面
|
|
|
|
#pragma region 指南针数据页面
|
|
class DataAnimatorCallback : public OHOS::AnimatorCallback
|
|
{
|
|
public:
|
|
explicit DataAnimatorCallback(OHOS::UIImageView *point, OHOS::UILabelExt *direction, OHOS::UILabel *directionVal,
|
|
OHOS::UILabel *slopeVal)
|
|
{
|
|
direction_ = direction;
|
|
directionVal_ = directionVal;
|
|
slopeVal_ = slopeVal;
|
|
point_ = point;
|
|
}
|
|
~DataAnimatorCallback()
|
|
{
|
|
direction_ = nullptr;
|
|
directionVal_ = nullptr;
|
|
slopeVal_ = nullptr;
|
|
point_ = nullptr;
|
|
}
|
|
void Callback(OHOS::UIView *view);
|
|
|
|
private:
|
|
OHOS::UILabelExt *direction_{nullptr};
|
|
OHOS::UILabel *directionVal_{nullptr};
|
|
OHOS::UILabel *slopeVal_{nullptr};
|
|
OHOS::UIImageView *point_{nullptr};
|
|
};
|
|
class CompassDataView : public CompassViewBase
|
|
{
|
|
public:
|
|
CompassDataView();
|
|
~CompassDataView();
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
|
|
private:
|
|
OHOS::UILabelExt direction_;
|
|
OHOS::UILabel directionVal_;
|
|
OHOS::UILabelExt slope_;
|
|
OHOS::UILabel slopeVal_;
|
|
|
|
OHOS::UIImageView pointBg_;
|
|
OHOS::UIImageView point_;
|
|
|
|
DataAnimatorCallback *callback_{nullptr};
|
|
};
|
|
|
|
#pragma endregion 指南针数据页面
|
|
|
|
#pragma region 指南针页面管理
|
|
|
|
class TjdUiAppCompassPresenter;
|
|
class TjdUiAppCompassView : public OHOS::View<TjdUiAppCompassPresenter>
|
|
{
|
|
public:
|
|
TjdUiAppCompassView();
|
|
~TjdUiAppCompassView();
|
|
static TjdUiAppCompassView *GetInstance(void);
|
|
|
|
void OnStart() override;
|
|
void OnStop() override;
|
|
|
|
void ShowView(CompassView showIndex);
|
|
static CompassView currentViewIndex_;
|
|
|
|
private:
|
|
void InitTargetView(CompassView index);
|
|
|
|
CompassViewBase *viewManager_[VIEW_COMPASS_MAX]{nullptr};
|
|
CompassUIScrollView *mainContainer_{nullptr};
|
|
};
|
|
#pragma endregion 指南针页面管理
|
|
|
|
} // namespace TJD
|
|
|
|
#endif |