195 lines
6.7 KiB
C++
195 lines
6.7 KiB
C++
#ifndef TJDUIAPP_EBOOK_VIEW
|
|
#define TJDUIAPP_EBOOK_VIEW
|
|
|
|
#include "TjdUiAppEbookPresenter.h"
|
|
#include "TjdUiAppSettingPage.h"
|
|
#include "View.h"
|
|
#include "components/ui_list_nested.h"
|
|
#include "components/ui_scroll_view_nested.h"
|
|
#include "ui_button.h"
|
|
#include "ui_image_view.h"
|
|
#include "ui_label.h"
|
|
#include "ui_label_ext.h"
|
|
#include "ui_radio_button.h"
|
|
#include "ui_scroll_view.h"
|
|
#include "ui_view_group.h"
|
|
#include <map>
|
|
|
|
namespace TJD {
|
|
class EbookWaitView : public OHOS::UIScrollView
|
|
{
|
|
public:
|
|
EbookWaitView();
|
|
~EbookWaitView();
|
|
void ShowView();
|
|
void HideView();
|
|
void Stop() { animator_.Stop(); }
|
|
|
|
private:
|
|
OHOS::UIImageAnimatorView animator_;
|
|
OHOS::UILabelExt desc_;
|
|
};
|
|
|
|
class EbookBackdropRadioButton : public OHOS::UIViewGroup, public OHOS::UICheckBox::OnChangeListener
|
|
{
|
|
public:
|
|
EbookBackdropRadioButton();
|
|
~EbookBackdropRadioButton() { RemoveAll(); }
|
|
bool OnChange(OHOS::UICheckBox::UICheckBoxState state) override;
|
|
|
|
void SetRadioColor(uint8_t key, int64_t color);
|
|
void SetRadioImage(OHOS::ImageInfo *selected, OHOS::ImageInfo *unselect);
|
|
void SetLabelText(const char *text) { label_.SetText(text); }
|
|
void SetLabelId(uint16_t textId) { label_.SetTextId(textId); }
|
|
void SetRadioStatus(OHOS::UICheckBox::UICheckBoxState state) { radio_.SetState(state); }
|
|
void SetID(uint8_t id) { ID = id; }
|
|
|
|
private:
|
|
uint8_t ID = 0;
|
|
OHOS::ImageInfo image;
|
|
OHOS::UILabelExt label_;
|
|
OHOS::UIRadioButton radio_;
|
|
};
|
|
|
|
class EbookFilpVFXRadioButton : public OHOS::UIViewGroup,
|
|
public OHOS::UICheckBox::OnChangeListener,
|
|
public OHOS::UIView::OnClickListener
|
|
{
|
|
public:
|
|
EbookFilpVFXRadioButton();
|
|
~EbookFilpVFXRadioButton() { RemoveAll(); }
|
|
bool OnChange(OHOS::UICheckBox::UICheckBoxState state) override;
|
|
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event)
|
|
{
|
|
radio_.OnClickEvent(event);
|
|
return true;
|
|
}
|
|
|
|
void SetLabelText(const char *text) { label_.SetText(text); }
|
|
void SetRadioStatus(OHOS::UICheckBox::UICheckBoxState state) { radio_.SetState(state); }
|
|
void SetFilpVFXID(uint8_t id) { filpVFXID = id; }
|
|
|
|
private:
|
|
uint8_t filpVFXID = 0;
|
|
OHOS::UILabel label_;
|
|
OHOS::UIRadioButton radio_;
|
|
};
|
|
|
|
class TextLabel : public OHOS::UILabel
|
|
{
|
|
public:
|
|
uint16_t GetTruncateIndex(void)
|
|
{
|
|
OHOS::Style style = GetStyleConst();
|
|
labelText_->ReMeasureTextSize(GetContentRect(), style);
|
|
return labelText_->GetTruncateIndex(GetContentRect(), style);
|
|
}
|
|
};
|
|
|
|
class EbookUIScrollView : public OHOS::UIScrollViewNested
|
|
{
|
|
public:
|
|
EbookUIScrollView() {}
|
|
~EbookUIScrollView() {}
|
|
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 TjdEbookAdapter;
|
|
class TjdUiAppEbookPresenter;
|
|
class TjdUiAppEbookView : public OHOS::View<TjdUiAppEbookPresenter>
|
|
{
|
|
public:
|
|
TjdUiAppEbookView();
|
|
~TjdUiAppEbookView();
|
|
static TjdUiAppEbookView *GetInstance(void);
|
|
|
|
void OnStart() override;
|
|
void OnStop() override;
|
|
|
|
OHOS::UIScrollView *NoneViewInit(void);
|
|
OHOS::UIScrollView *ListViewInit(void);
|
|
OHOS::UIScrollView *MainViewInit(void);
|
|
OHOS::UIScrollView *DeleteViewInit(void);
|
|
OHOS::UIScrollView *SettingViewInit(void);
|
|
|
|
int16_t GetListPosition(void);
|
|
void SetTitleVisible(bool visible);
|
|
bool ShowNoneView(EbookView hideView);
|
|
bool ShowListView(EbookView hideView);
|
|
bool ShowMainView(EbookView hideView);
|
|
bool ShowDeleteView(EbookView hideView);
|
|
bool ShowSettingView(EbookView hideView);
|
|
bool ChangeView(EbookView view, EbookView hideView);
|
|
void ResetListPosition(void);
|
|
void DeleteEbookItemFromList(uint32_t id);
|
|
void SetBackdrop(void);
|
|
|
|
TjdEbookAdapter *GetAdapter(void) { return listAdapter_; }
|
|
void SetBackDropID(uint8_t id) { selectedBackDropID = id; }
|
|
void SetFilpVFXID(uint8_t id) { selectedFilpVFXID = id; }
|
|
uint8_t GetBackDropID(void) { return selectedBackDropID; }
|
|
uint8_t GetFilpVFXID(void) { return selectedFilpVFXID; }
|
|
OHOS::UIListNested *GetEbookUIList() { return contentList_; }
|
|
TjdEbookAdapter *GetEbookAdapter() { return listAdapter_; }
|
|
void UpdateEbookAdapter(std::list<EbookItem> &list);
|
|
|
|
std::map<EbookView, EbookView> viewHierarchy = {{EbookView::EBOOK_MAIN_VIEW, EbookView::EBOOK_LIST_VIEW},
|
|
{EbookView::EBOOK_DELETE_VIEW, EbookView::EBOOK_LIST_VIEW},
|
|
{EbookView::EBOOK_SETTING_VIEW, EbookView::EBOOK_MAIN_VIEW}};
|
|
|
|
// NoneView
|
|
OHOS::UILabelExt *noneLabel1{nullptr};
|
|
OHOS::UILabel *noneLabel2{nullptr};
|
|
// ListView
|
|
OHOS::UILabelExt *listLabel{nullptr};
|
|
// MainView
|
|
OHOS::UIImageView *backdropImage{nullptr};
|
|
OHOS::UILabel *txtName{nullptr};
|
|
TextLabel *nextViewText{nullptr};
|
|
TextLabel *curViewText{nullptr};
|
|
TextLabel *lastViewText{nullptr};
|
|
OHOS::UIButton *setButton{nullptr};
|
|
OHOS::UIButton *lastButton{nullptr};
|
|
OHOS::UIButton *nextButton{nullptr};
|
|
EbookWaitView *setWaitAnimator_{nullptr};
|
|
// DeleteView
|
|
OHOS::UILabelExt *deleteLabel{nullptr};
|
|
TextLabel *deleteNameLabel{nullptr};
|
|
OHOS::UIButton *cancelButton{nullptr};
|
|
OHOS::UIButton *confirmButton{nullptr};
|
|
// SettingView
|
|
OHOS::UIButton *setConfirmButton{nullptr};
|
|
EbookBackdropRadioButton *backdropButtons[4]{nullptr};
|
|
EbookFilpVFXRadioButton *FilpVFXButtons[4]{nullptr};
|
|
|
|
private:
|
|
typedef bool (TjdUiAppEbookView::*EbookChangeView)(EbookView);
|
|
|
|
EbookChangeView viewMapper_[EBOOK_VIEW_MAX] = {&TjdUiAppEbookView::ShowNoneView, &TjdUiAppEbookView::ShowListView,
|
|
&TjdUiAppEbookView::ShowMainView, &TjdUiAppEbookView::ShowDeleteView,
|
|
&TjdUiAppEbookView::ShowSettingView};
|
|
|
|
OHOS::UIViewGroup *groupList_[EbookView::EBOOK_VIEW_MAX]{nullptr};
|
|
|
|
EbookUIScrollView *containerAll_{nullptr};
|
|
OHOS::UIScrollView *noneContainer_{nullptr};
|
|
OHOS::UIScrollView *listContainer_{nullptr};
|
|
OHOS::UIScrollView *mainContainer_{nullptr};
|
|
OHOS::UIScrollView *deleteContainer_{nullptr};
|
|
OHOS::UIScrollView *settingContainer_{nullptr};
|
|
|
|
OHOS::UIListNested *contentList_{nullptr};
|
|
TjdEbookAdapter *listAdapter_{nullptr};
|
|
|
|
uint8_t selectedBackDropID = 0;
|
|
uint8_t selectedFilpVFXID = 0;
|
|
};
|
|
|
|
} // namespace TJD
|
|
|
|
#endif |