370 lines
11 KiB
C++
370 lines
11 KiB
C++
#ifndef TJD_UI_APP_SETTING_PAGE_H
|
||
#define TJD_UI_APP_SETTING_PAGE_H
|
||
|
||
#include "TjdUiAppSettingListItemView.h"
|
||
#include "components/tjd_ui_time_picker.h"
|
||
#include "components/tjd_ui_transform_list_group.h"
|
||
#include "components/ui_canvas_ext.h"
|
||
#include "components/ui_checkbox.h"
|
||
#include "components/ui_image_animator.h"
|
||
#include "components/ui_image_view.h"
|
||
#include "components/ui_label.h"
|
||
#include "components/ui_label_button.h"
|
||
#include "components/ui_picker.h"
|
||
#include "components/ui_qrcode.h"
|
||
#include "components/ui_radio_button.h"
|
||
#include "components/ui_scroll_view.h"
|
||
#include "components/ui_slider.h"
|
||
#include "components/ui_swipe_view.h"
|
||
#include "components/ui_transform_group.h"
|
||
#include "components/ui_view_group.h"
|
||
#include "graphic_timer.h"
|
||
#include "image_info.h"
|
||
#include <list>
|
||
#include <stdio.h>
|
||
|
||
extern "C"
|
||
{
|
||
#include "sys_typedef.h"
|
||
}
|
||
|
||
namespace TJD {
|
||
|
||
enum CommonBaseViewType
|
||
{
|
||
COMMON_RADIO_BUTTON = OHOS::UIViewType::UI_NUMBER_MAX + 1,
|
||
COMMON_ALBUM_ITEMVIEW,
|
||
};
|
||
|
||
#define SETTING_COMMON
|
||
|
||
#pragma region 公共控件
|
||
/**
|
||
* @brief 设置项目基类
|
||
*
|
||
*/
|
||
class SettingItemViewBase : public OHOS::UIScrollView
|
||
{
|
||
public:
|
||
virtual ~SettingItemViewBase() { SetScrollBlankSize(17); }
|
||
|
||
/**
|
||
* @brief 显示设置项,在此做更新UI操作,子类需要重写此方法
|
||
*/
|
||
virtual void Show() = 0;
|
||
|
||
/**
|
||
* @brief 下发退出事件,子类需要重写此方法
|
||
* @param view
|
||
*/
|
||
virtual void PageExitEvent(bool isSwipe) = 0;
|
||
};
|
||
|
||
/**
|
||
* @brief 确认界面基类
|
||
*/
|
||
class CommonEnterCancelViewBase : public OHOS::UIScrollView
|
||
{
|
||
public:
|
||
CommonEnterCancelViewBase() {}
|
||
CommonEnterCancelViewBase(const char *title, const char *desc);
|
||
virtual ~CommonEnterCancelViewBase() { RemoveAll(); };
|
||
void InitView(const char *title, const char *desc);
|
||
void SetSrc(OHOS::ImageInfo *icon);
|
||
void SetControlSrc(OHOS::ImageInfo *enter, OHOS::ImageInfo *cancel);
|
||
void SetText(const char *title, const char *desc);
|
||
|
||
protected:
|
||
virtual void EnterCallback(){};
|
||
virtual void CancelCallback(){};
|
||
|
||
private:
|
||
class SettingItemEnterOnClick : public OHOS::UIView::OnClickListener
|
||
{
|
||
public:
|
||
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override;
|
||
};
|
||
SettingItemEnterOnClick enterCallback_;
|
||
OHOS::UIImageView icon_;
|
||
OHOS::UILabel title_;
|
||
OHOS::UILabel desc_;
|
||
OHOS::UIImageView btnOK_;
|
||
OHOS::UIImageView btnCancel_;
|
||
};
|
||
|
||
/**
|
||
* @brief 等待动画界面基类
|
||
*/
|
||
class CommonWaitAnimatorViewBase : public OHOS::UIScrollView
|
||
{
|
||
public:
|
||
CommonWaitAnimatorViewBase(){};
|
||
CommonWaitAnimatorViewBase(const char *desc);
|
||
virtual ~CommonWaitAnimatorViewBase();
|
||
void InitView(const char *desc, bool isLoop = false);
|
||
void SetText(const char *desc);
|
||
void Start();
|
||
void Stop();
|
||
|
||
protected:
|
||
virtual void CompleteCallback(){};
|
||
OHOS::GraphicTimer *waitTimer_{nullptr};
|
||
OHOS::UIImageAnimatorView animator_;
|
||
|
||
private:
|
||
static void TimerCallback(void *arg);
|
||
static void CompleteEventProc(void *arg);
|
||
OHOS::UILabel desc_;
|
||
};
|
||
|
||
/**
|
||
* @brief 通用开关界面基类
|
||
*/
|
||
class CommonSwitchViewBase : public OHOS::UIViewGroup
|
||
{
|
||
public:
|
||
CommonSwitchViewBase() {}
|
||
CommonSwitchViewBase(const char *desc, int16_t width = 450, int16_t height = 110);
|
||
virtual ~CommonSwitchViewBase() { RemoveAll(); };
|
||
virtual void InitView(const char *desc, int16_t width = 450, int16_t height = 110);
|
||
void SetSrc(OHOS::ImageInfo *open, OHOS::ImageInfo *close);
|
||
void SetSwitchState(OHOS::UICheckBox::UICheckBoxState state) { switch_.SetState(state, true); }
|
||
OHOS::UICheckBox::UICheckBoxState GetSwitchState() { return switch_.GetState(); }
|
||
|
||
protected:
|
||
virtual void SwitchCallback(OHOS::UIView &view, OHOS::UICheckBox::UICheckBoxState value){};
|
||
OHOS::UIImageView icon_;
|
||
OHOS::UILabel title_;
|
||
OHOS::UILabel desc_;
|
||
OHOS::UICheckBox switch_;
|
||
|
||
private:
|
||
bool OnClickEvent(const OHOS::ClickEvent &event) override;
|
||
};
|
||
|
||
/**
|
||
* @brief 错误弹窗界面基类
|
||
*/
|
||
class CommonErrorWindowsViewBase : public OHOS::UIViewGroup
|
||
{
|
||
public:
|
||
CommonErrorWindowsViewBase();
|
||
virtual ~CommonErrorWindowsViewBase();
|
||
void SetPeriod(int32_t periodMs);
|
||
void ShowMessage(OHOS::UIView *retView, const char *desc);
|
||
|
||
private:
|
||
static void CompleteEvent(void *arg);
|
||
void HideErrorView();
|
||
OHOS::UIView *retView_{nullptr};
|
||
OHOS::UILabel desc_;
|
||
OHOS::GraphicTimer *errorTimer_{nullptr};
|
||
};
|
||
|
||
/**
|
||
* @brief 输入界面基类
|
||
* @note 按下OK会调用InputOkCallBack,按下取消会调用CancelCallBack
|
||
*/
|
||
class CommonInputViewBase : public OHOS::UIViewGroup
|
||
{
|
||
public:
|
||
enum InputViewType
|
||
{
|
||
INPUT_TYPE_NUMBER = 0,
|
||
INPUT_TYPE_PASSWORD,
|
||
INPUT_TYPE_MAX
|
||
};
|
||
|
||
CommonInputViewBase(InputViewType type);
|
||
CommonInputViewBase(){};
|
||
virtual ~CommonInputViewBase();
|
||
void InitView(InputViewType type);
|
||
void ResetPassword();
|
||
void SetHideText(const char *text);
|
||
bool OnClickEvent(const OHOS::ClickEvent &event) override { return true; };
|
||
|
||
protected:
|
||
virtual void InputOkCallBack(const char *val) = 0;
|
||
virtual void CancelCallBack() = 0;
|
||
|
||
private:
|
||
void Push(char key);
|
||
void Enter();
|
||
void Delete();
|
||
void InitPasswordView();
|
||
class KeyBoardListener : public OHOS::UIView::OnClickListener
|
||
{
|
||
public:
|
||
KeyBoardListener() {}
|
||
virtual ~KeyBoardListener() {}
|
||
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event) override;
|
||
};
|
||
KeyBoardListener listener_;
|
||
InputViewType type_{INPUT_TYPE_NUMBER};
|
||
OHOS::UILabelButton key_[12];
|
||
OHOS::UIViewGroup editView_;
|
||
OHOS::UIImageView passwrodEdit_[4];
|
||
OHOS::UILabel hideText_;
|
||
uint8_t currentPasswordIndex_{0};
|
||
std::string keyId_[12]{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "0", "12"};
|
||
std::string password_;
|
||
};
|
||
|
||
/**
|
||
* @brief 大型按钮界面基类
|
||
*/
|
||
class CommonMultiButtonViewBase : public OHOS::UIViewGroup
|
||
{
|
||
public:
|
||
CommonMultiButtonViewBase(){};
|
||
CommonMultiButtonViewBase(const char *title, const char *value, bool isIcon, int16_t width = 450,
|
||
int16_t height = 120);
|
||
virtual ~CommonMultiButtonViewBase();
|
||
void InitView(const char *title, const char *value, bool isIcon, int16_t width = 450, int16_t height = 120);
|
||
void SetSrc(OHOS::ImageInfo *more);
|
||
void SetTitle(const char *title)
|
||
{
|
||
title_.SetText(title);
|
||
title_.Invalidate();
|
||
}
|
||
void SetValue(const char *value)
|
||
{
|
||
value_.SetText(value);
|
||
value_.Invalidate();
|
||
}
|
||
void Resize(int16_t width, int16_t height) override;
|
||
void SetPosition(int16_t x, int16_t y) override
|
||
{
|
||
SetX(x);
|
||
SetY(y);
|
||
}
|
||
void SetPosition(int16_t x, int16_t y, int16_t width, int16_t height) override;
|
||
|
||
protected:
|
||
virtual void EnterCallback(OHOS::UIView &view, const OHOS::ClickEvent &event){};
|
||
|
||
private:
|
||
bool OnClickEvent(const OHOS::ClickEvent &event) override;
|
||
OHOS::UILabel title_;
|
||
OHOS::UILabel value_;
|
||
OHOS::UIImageView icon_;
|
||
bool hasValue_{true};
|
||
};
|
||
|
||
/**
|
||
* @brief 单确认按钮框架界面基类
|
||
*/
|
||
class CommonEnterViewBase : public OHOS::UIScrollView
|
||
{
|
||
public:
|
||
CommonEnterViewBase(){};
|
||
CommonEnterViewBase(const char *title) { InitView(title); };
|
||
virtual ~CommonEnterViewBase()
|
||
{
|
||
RemoveAll();
|
||
enterView_.RemoveAll();
|
||
}
|
||
void InitView(const char *title);
|
||
void SetSrc(OHOS::ImageInfo *enter);
|
||
void SetFullSrc(OHOS::ImageInfo *enter);
|
||
void SetTitle(const char *title) { title_.SetText(title); }
|
||
void SetEnterColor(uint32_t enterColor);
|
||
|
||
protected:
|
||
virtual void EnterCallback(){};
|
||
CommonEnterViewBase *GetView() { return this; }
|
||
|
||
private:
|
||
class EnterOnClickListener : public OHOS::UIView::OnClickListener
|
||
{
|
||
public:
|
||
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event);
|
||
};
|
||
EnterOnClickListener listener_;
|
||
OHOS::UILabel title_;
|
||
OHOS::UIViewGroup enterView_;
|
||
OHOS::UIImageView enterIcon_;
|
||
};
|
||
|
||
/**
|
||
* @brief 梯度进度界面基类
|
||
*/
|
||
class CommonGradingBarViewBase : public OHOS::UIViewGroup
|
||
{
|
||
public:
|
||
CommonGradingBarViewBase() {}
|
||
CommonGradingBarViewBase(OHOS::ImageInfo *leftInfo, OHOS::ImageInfo *rightInfo) { InitView(leftInfo, rightInfo); }
|
||
virtual ~CommonGradingBarViewBase();
|
||
void InitView(OHOS::ImageInfo *leftInfo, OHOS::ImageInfo *rightInfo);
|
||
void ChangeValue(uint8_t value);
|
||
uint8_t GetValue() { return value_; }
|
||
|
||
protected:
|
||
virtual void OnChangeCallback(OHOS::UIView &view, uint8_t value){};
|
||
|
||
private:
|
||
bool OnClickEvent(const OHOS::ClickEvent &event) override;
|
||
void LeftOnClickEvent();
|
||
void RightOnClickEvent();
|
||
static const uint8_t MAX_LEVEL = 5;
|
||
uint8_t value_{0};
|
||
OHOS::UIImageView leftIcon_;
|
||
OHOS::UIImageView rightIcon_;
|
||
OHOS::UIView level_[MAX_LEVEL];
|
||
};
|
||
|
||
/**
|
||
* @brief 单选按钮界面基类
|
||
*/
|
||
class CommonRadioButtonViewBase : public OHOS::UIViewGroup
|
||
{
|
||
public:
|
||
CommonRadioButtonViewBase() {}
|
||
CommonRadioButtonViewBase(const char *name, const char *desc, int16_t width = 450, int16_t height = 110)
|
||
{
|
||
InitView(name, desc, width, height);
|
||
}
|
||
virtual ~CommonRadioButtonViewBase();
|
||
virtual void InitView(const char *name, const char *desc, int16_t width = 450, int16_t height = 110);
|
||
virtual void SetSrc(OHOS::ImageInfo *icon, int16_t x, int16_t y, int16_t width, int16_t height);
|
||
void SetIconScale(const OHOS::Vector2<float> scale, const OHOS::Vector2<float> pivot);
|
||
void SetControlSrc(OHOS::ImageInfo *select, OHOS::ImageInfo *unselect);
|
||
void SetDesc(const char *desc) { desc_.SetText(desc); }
|
||
void SetState(OHOS::UICheckBox::UICheckBoxState state) { radio_.SetState(state, true); }
|
||
void SetRadioFindEnable(bool enable) { isFindRadioButton_ = enable; }
|
||
bool GetRadioFindEnable() { return isFindRadioButton_; }
|
||
OHOS::UICheckBox::UICheckBoxState GetState() { return state_; }
|
||
OHOS::UIViewType GetViewType() const override { return (OHOS::UIViewType)COMMON_RADIO_BUTTON; }
|
||
const char *GetName() { return radio_.GetName(); }
|
||
|
||
protected:
|
||
virtual void OnChangeCallback(OHOS::UIView &view, const OHOS::UICheckBox::UICheckBoxState state){};
|
||
OHOS::UILabel desc_;
|
||
OHOS::UIRadioButton radio_;
|
||
OHOS::UIImageView icon_;
|
||
|
||
private:
|
||
bool OnClickEvent(const OHOS::ClickEvent &event) override;
|
||
void ToggleRadioButton()
|
||
{
|
||
auto state = radio_.GetState();
|
||
if (state == OHOS::UICheckBox::UICheckBoxState::SELECTED)
|
||
state = OHOS::UICheckBox::UICheckBoxState::UNSELECTED;
|
||
else
|
||
state = OHOS::UICheckBox::UICheckBoxState::SELECTED;
|
||
radio_.SetState(state, true);
|
||
}
|
||
void FindRadioButtonAndChangeState(OHOS::UIView *view);
|
||
bool isFindRadioButton_{true};
|
||
OHOS::UIRadioButton &GetRadioButton() { return radio_; }
|
||
const int CALCULATE = 30;
|
||
OHOS::UICheckBox::UICheckBoxState state_{OHOS::UICheckBox::UICheckBoxState::UNSELECTED};
|
||
OHOS::Vector2<float> scale_;
|
||
OHOS::Vector2<float> pivot_;
|
||
};
|
||
|
||
#pragma endregion
|
||
|
||
} // namespace TJD
|
||
|
||
#endif |