274 lines
9.0 KiB
C++
274 lines
9.0 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description: TjdUiAppPlayDialView.h
|
|
*
|
|
* Author: liuguanwu
|
|
*
|
|
* Create: 2024-10
|
|
*--------------------------------------------------------------------------*/
|
|
#ifndef TJDUI_APP_PLAY_DIAL_VIEW_H
|
|
#define TJDUI_APP_PLAY_DIAL_VIEW_H
|
|
|
|
/*@brief 玩转表盘(play dial)
|
|
*/
|
|
|
|
#include "View.h"
|
|
#include "TjdUiMultiLanguageExt.h"
|
|
#include "components/ui_button.h"
|
|
#include "components/ui_edit_text.h"
|
|
#include "components/ui_image_animator.h"
|
|
#include "components/ui_image_view.h"
|
|
#include "components/ui_label.h"
|
|
#include "components/ui_list.h"
|
|
#include "components/ui_scroll_view.h"
|
|
#include "components/ui_view_group.h"
|
|
#include "components/ui_canvas.h"
|
|
#include "components/ui_canvas_ext.h"
|
|
#include <cmath>
|
|
#include <vector>
|
|
#include "components/ui_scroll_view_nested.h"
|
|
#include "TjdUiAppPlayDialPresenter.h"
|
|
#include "TjdUiAppPlayDialAdapter.h"
|
|
|
|
namespace TJD {
|
|
|
|
// btn:
|
|
#define PLAYDIAL_HOME_VIEW_BTN_LEFT_ID "PlayDialHomeView_BtnLeft"
|
|
#define PLAYDIAL_HOME_VIEW_BTN_RIGHT_ID "PlayDialHomeView_BtnRight"
|
|
#define PLAYDIAL_HOME_VIEW_BTN_RECORD_ID "PlayDialHomeView_BtnRecord"
|
|
#define PLAYDIAL_AI_STYLE_VIEW_ITEM_ID "PlayDialAIStyleView_Item"
|
|
#define PLAYDIAL_AI_LISTEN_VIEW_BTN_ID "PlayDialAIListenView_Btn"
|
|
#define PLAYDIAL_AI_MAKING_VIEW_BTN_LEFT_ID "PlayDialAIMakingView_BtnLeft"
|
|
#define PLAYDIAL_AI_MAKING_VIEW_BTN_RIGHT_ID "PlayDialAIMakingView_BtnRight"
|
|
#define PLAYDIAL_AI_PREVIEW_VIEW_BTN_LEFT_ID "PlayDialAIPreviewView_BtnLeft"
|
|
#define PLAYDIAL_AI_PREVIEW_VIEW_BTN_RIGHT_ID "PlayDialAIPreviewView_BtnRight"
|
|
#define PLAYDIAL_DRAW_MAIN_VIEW_CANVAS_ID "PlayDialDrawMain_Canvas"
|
|
#define PLAYDIAL_DRAW_MAIN_VIEW_BTN_ID "PlayDialDrawMain_Btn"
|
|
#define PLAYDIAL_DRAW_PREVIEW_VIEW_BTN_LEFT_ID "PlayDialDrawPreviewView_BtnLeft"
|
|
#define PLAYDIAL_DRAW_PREVIEW_VIEW_BTN_RIGHT_ID "PlayDialDrawPreviewView_BtnRight"
|
|
#define PLAYDIAL_LOG_LIST_VIEW_LIST_ID "PlayDialLogListView_LIST"
|
|
#define PLAYDIAL_LOG_LIST_VIEW_ITEM_ID "PlayDialLogListView_Item"
|
|
#define PLAYDIAL_LOG_LIST_VIEW_IMAGE_ID "PlayDialLogListView_Image"
|
|
#define PLAYDIAL_LOG_LIST_VIEW_DELETE_ID "PlayDialLogListView_Delete"
|
|
#define PLAYDIAL_LOG_SINGLE_VIEW_BTN_ID "PlayDialLogSingleView_BTN"
|
|
//clang-format off
|
|
enum PlayDialViewIndex
|
|
{
|
|
PLAYDIAL_HOME = 0, // 主入口
|
|
PLAYDIAL_AI_STYLE, // AI表盘,风格界面
|
|
PLAYDIAL_AI_LISTEN, // AI表盘,录音界面
|
|
PLAYDIAL_AI_MAKING_TXT, // AI表盘,语音识别界面
|
|
PLAYDIAL_AI_MAKING_IMG, // AI表盘,图片加载界面
|
|
PLAYDIAL_AI_PREVIEW, // AI表盘,效果确认界面(预览界面)
|
|
PLAYDIAL_DRAW_HINT, // 绘图表盘,提示界面
|
|
PLAYDIAL_DRAW_MAIN, // 绘图表盘,绘制界面
|
|
PLAYDIAL_DRAW_MAKING_IMG, // 绘图表盘,图片加载界面
|
|
PLAYDIAL_DRAW_PREVIEW, // 绘图表盘,效果确认界面(预览界面)
|
|
PLAYDIAL_LOG_LIST, // 历史记录,列表界面
|
|
PLAYDIAL_LOG_SINGLE, // 历史记录,单图界面
|
|
PLAYDIAL_TIPSV_SUCCESS, // 设置成功页面
|
|
PLAYDIAL_TIPS_NO_CONNECT,
|
|
PLAYDIAL_TIPS_OTHER, // 提示结果,
|
|
// keep adding
|
|
PLAYDIAL_UNKNOWN,
|
|
};
|
|
//clang-format on
|
|
enum TjdAiResultIndex : uint8_t {
|
|
AI_RESULT_INVALID = 0,
|
|
AI_RESULT_LISTEN,
|
|
AI_RESULT_LOADING_TXT,
|
|
AI_RESULT_SELECT_TXT,
|
|
AI_RESULT_APP_MAKING,
|
|
AI_RESULT_APP_DONE,
|
|
AI_RESULT_LOADING_IMG,
|
|
AI_RESULT_SELECT_IMG,
|
|
AI_RESULT_SET_DING,
|
|
AI_RESULT_SET_DONE,
|
|
AI_RESULT_MAX_ID,
|
|
}; // TjdUiTextId
|
|
|
|
enum TjdDialTipsIndex : uint8_t {
|
|
PLAYDIAL_TIPS_INVALID = 0,
|
|
PLAYDIAL_TIPS_SET_SUCCESS,
|
|
PLAYDIAL_TIPS_SUCCESS,
|
|
PLAYDIAL_TIPS_FAIL,
|
|
PLAYDIAL_TIPS_NO_DATA,
|
|
PLAYDIAL_TIPS_MAX_ID,
|
|
}; // TjdUiTextId
|
|
|
|
enum DialSelectType : uint8_t
|
|
{
|
|
SELECT_TYPE_DRAW = 0,
|
|
SELECT_TYPE_AI,
|
|
SELECT_TYPE_INVALID,
|
|
};
|
|
|
|
inline void InitLabelHorCenter(OHOS::UILabel &label, uint8_t size, int16_t y, int16_t target, const char *text);
|
|
inline void InitLabelVerCenter(OHOS::UILabel &label, uint8_t size, int16_t x, int16_t target, const char *text);
|
|
inline void InitLabelCenter(OHOS::UILabel &label, uint8_t size, int16_t parentWidth, int16_t parentHeight, const char *text);
|
|
class PlayDialUIScrollView : public OHOS::UIScrollViewNested
|
|
{
|
|
public:
|
|
PlayDialUIScrollView() {}
|
|
~PlayDialUIScrollView() {}
|
|
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 PlayDialViewBase : public OHOS::UIScrollView
|
|
{
|
|
public:
|
|
PlayDialViewBase() {}
|
|
virtual ~PlayDialViewBase() {}
|
|
virtual void ShowView() { SetVisible(true); };
|
|
virtual void HideView() { SetVisible(false); };
|
|
};
|
|
/*@class view---<s> */
|
|
class TjdUiAppPlayDialPresenter;
|
|
class TjdUiAppPlayDialView : public OHOS::View<TjdUiAppPlayDialPresenter>
|
|
{
|
|
public:
|
|
TjdUiAppPlayDialView();
|
|
~TjdUiAppPlayDialView();
|
|
static TjdUiAppPlayDialView &GetInstance(void);
|
|
|
|
void OnStart() override;
|
|
void OnStop() override;
|
|
|
|
void ShowView(PlayDialViewIndex showIndex);
|
|
|
|
static PlayDialViewIndex currentViewIndex_;
|
|
static PlayDialViewIndex previousViewIndex_;
|
|
static TjdAiResultIndex Result_;
|
|
static TjdDialTipsIndex TipsIndex_;
|
|
static DialSelectType selectType_;
|
|
private:
|
|
void InitTargetView(PlayDialViewIndex index);
|
|
|
|
PlayDialUIScrollView *mainView_{nullptr};
|
|
PlayDialViewBase *viewManager_[PLAYDIAL_UNKNOWN]{nullptr};
|
|
//PlayDialTipsView *TipsView_{nullptr};
|
|
};
|
|
/*@class view---<e> */
|
|
class PlayDialHomeView : public PlayDialViewBase
|
|
{
|
|
public:
|
|
PlayDialHomeView();
|
|
~PlayDialHomeView();
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
|
|
private:
|
|
OHOS::UILabelExt titleLeft_;
|
|
OHOS::UILabelExt titleRight_;
|
|
OHOS::UIImageView clickLeft_;
|
|
OHOS::UIImageView clickRight_;
|
|
OHOS::UIImageView logoRecord_;
|
|
};
|
|
|
|
class PlayDialHistoryView : public PlayDialViewBase
|
|
{
|
|
public:
|
|
PlayDialHistoryView();
|
|
~PlayDialHistoryView();
|
|
static PlayDialHistoryView *GetInstance(void);
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
void PageInit(void);
|
|
void PageUninit(void);
|
|
void clickCallBackImage(int16_t index);
|
|
void clickCallBackDelete(int16_t index);
|
|
PlayDialHistoryAdapter::HistoryList* styleList_{nullptr};
|
|
|
|
private:
|
|
bool initFlag_{false};
|
|
OHOS::UILabelExt titleDown_;
|
|
OHOS::UIImageView logoNoRecord_;
|
|
OHOS::UIViewGroup *pageGroup_{nullptr};
|
|
};
|
|
|
|
class PlayDialHistorySingleView : public PlayDialViewBase
|
|
{
|
|
public:
|
|
PlayDialHistorySingleView();
|
|
~PlayDialHistorySingleView();
|
|
static PlayDialHistorySingleView *GetInstance(void);
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
|
|
private:
|
|
OHOS::UIImageView ImageBg_;
|
|
OHOS::UIImageView clickDown_;
|
|
OHOS::UILabelExt clickDownLabel_;
|
|
};
|
|
|
|
class PlayDialSetSuccessView : public PlayDialViewBase
|
|
{
|
|
public:
|
|
PlayDialSetSuccessView();
|
|
~PlayDialSetSuccessView();
|
|
static PlayDialSetSuccessView *GetInstance(void);
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
void TimerCallBackRun(void *arg);
|
|
static void TimerCallBack(void *arg);
|
|
|
|
private:
|
|
uint32_t tick_;
|
|
OHOS::GraphicTimer *logoTimer_{nullptr};
|
|
OHOS::UILabelExt titleDown_;
|
|
OHOS::UIImageView logoSetResul_;
|
|
};
|
|
|
|
class PlayDialNoConnectView : public PlayDialViewBase
|
|
{
|
|
public:
|
|
PlayDialNoConnectView();
|
|
~PlayDialNoConnectView();
|
|
static PlayDialNoConnectView *GetInstance(void);
|
|
void ShowView() override;
|
|
void HideView() override;
|
|
void TimerCallBackRun(void *arg);
|
|
static void TimerCallBack(void *arg);
|
|
|
|
private:
|
|
uint32_t tick_;
|
|
OHOS::GraphicTimer *logoTimer_{nullptr};
|
|
OHOS::UILabelExt titleDown_;
|
|
OHOS::UIImageView logoSetResul_;
|
|
OHOS::UIImageView clickLeft_;
|
|
OHOS::UIImageView clickLeftIcon_;
|
|
OHOS::UIImageView clickRight_;
|
|
OHOS::UIImageView clickRightIcon_;
|
|
};
|
|
class PlayDialTipsView : public OHOS::UIViewGroup
|
|
{
|
|
public:
|
|
PlayDialTipsView();
|
|
~PlayDialTipsView();
|
|
static PlayDialTipsView *GetInstance(void);
|
|
void OnStop(void);
|
|
void TimerCallBackRun(void *arg);
|
|
void TimerCallBack(void *arg);
|
|
|
|
private:
|
|
uint32_t tick_;
|
|
OHOS::GraphicTimer *logoTimer_{nullptr};
|
|
static void SetResultCB(void *arg);
|
|
OHOS::UILabelExt titleDown_;
|
|
OHOS::UIImageView logoSetResul_;
|
|
OHOS::UIImageView clickLeft_;
|
|
OHOS::UIImageView clickLeftIcon_;
|
|
OHOS::UIImageView clickRight_;
|
|
OHOS::UIImageView clickRightIcon_;
|
|
};
|
|
|
|
} // namespace TJD
|
|
|
|
#endif
|