mcu_hi3321_watch/tjd/ui/app/message/total/TjdUiMessageTotalPage.h
2025-05-26 20:15:20 +08:00

153 lines
5.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*----------------------------------------------------------------------------
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
*
* Description:
*
* Author: huangshuyi
*
* Create: 2024-4
*--------------------------------------------------------------------------*/
#ifndef TJDUI_MESSAGE_TOTAL_PAGE_H
#define TJDUI_MESSAGE_TOTAL_PAGE_H
#include <string>
#include <time.h>
#include "components/ui_view_group.h"
#include "View.h"
#include "components/ui_label.h"
#include "components/root_view.h"
#include "components/ui_view_group.h"
#include "components/ui_image_view.h"
#include "components/ui_label_button.h"
#include "font/ui_font_bitmap.h"
#include "font/ui_font.h"
#include "graphic_config.h"
#include "animator/animator_manager.h"
#include "time.h"
#include "sys/time.h"
#include "components/abstract_adapter.h"
#include "components/ui_scroll_view.h"
#include "sql_message.h"
// #include "TjdUiMessageCommon.h"
#include "TjdUiMessageConfirmDelPage.h"
#include "TjdUiAppIds.h"
#include "NativeAbility.h"
namespace TJD {
class TjdUiMessageTotalPage : public TjdUiMessagePageCommon
{
public:
TjdUiMessageTotalPage();
virtual ~TjdUiMessageTotalPage();
static TjdUiMessageTotalPage *GetInstance(void);
void show(void) override;
void hide(void) override;
void FocusManage(bool flag);
void DeleteMessage(uint8_t index) override;
bool OnClick(OHOS::UIView &view, const OHOS::ClickEvent &event);
OHOS::UIViewGroup *PageInit(OHOS::UIViewGroup *cont);
void UpdateMessagePageGroup(void);
static message_enum messageType;
static TjdUiAppViewId sliceId;
private:
int16_t CreateMessageItem(OHOS::UIViewGroup*& cont, const uint8_t& index, const int16_t& x, const int16_t& y, OHOS::UIView::OnClickListener*itemClickListener);
void CreateMessagePageGroup(void);
OHOS::UIScrollView *scrollCont{nullptr};
OHOS::UIViewGroup *messagePageGroup{nullptr};
OHOS::UIViewGroup *pageGroup{nullptr};
OHOS::UIViewGroup *container_{nullptr};
class TjdUiMessageScroll : public OHOS::UIScrollView
{
public:
bool OnDragEvent(const OHOS::DragEvent& event) override
{
OHOS::UIView* child = GetChildrenHead();
OHOS::Rect coor = child->GetRect();
OHOS::Rect coor1 = GetRect();
// printf("get absolution coor of viewgroup x:%d,y:%d, top:%d, bottom:%d, h:%d,name:%s\n", coor.GetX(), coor.GetY(), coor.GetTop(), coor.GetBottom(), coor.GetHeight(), child->GetViewId());
// printf("get absolution coor of scroll x:%d,y:%d, top:%d, bottom:%d, h:%d,name:%s\n", coor1.GetX(), coor1.GetY(), coor1.GetTop(), coor1.GetBottom(), coor1.GetHeight(), GetViewId());
bool dir = event.GetDeltaY() > 0 ? true : false;//true:向下滑动false:向上滑动
if (dir == false) {
if ((coor1.GetTop() > 0)) {
//返回false表示不拦截事件继续传递给父控件
return false;
}
OHOS::UIScrollView::OnDragEvent(event);
//返回true表示拦截事件不继续传递给父控件,自己滚动
return true;
} else if (dir == true) {
if ((coor1.GetTop() >= 0)) {
if (coor.GetY() < 0) {
//返回true表示拦截事件不继续传递给父控件,自己滚动
OHOS::UIScrollView::OnDragEvent(event);
return true;
}
//返回false表示不拦截事件继续传递给父控件
return false;
}
//返回true表示拦截事件不继续传递给父控件,自己滚动
OHOS::UIScrollView::OnDragEvent(event);
return true;
}
//UIScrollView::OnDragEvent(event);
return true;
}
private:
bool isConsumed = true;
};
class DelClickListener : public OHOS::UIView:: OnClickListener
{
public:
DelClickListener(const DelClickListener &) = delete;
DelClickListener &operator=(const DelClickListener &) = delete;
DelClickListener() {}
~DelClickListener() override
{
}
bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override
{
printf("DelClick,type:%d,index:%d\n", view.GetViewType(), view.GetViewIndex());
if (TjdUiMessageTotalPage::GetInstance()) {
TjdUiMessageTotalPage::GetInstance()->hide();
}
if (TjdUiMessageConfirmDelPage::GetInstance()) {
TjdUiMessageConfirmDelPage::GetInstance()->show();
}
return true;
}
};
class ItemClickListener : public OHOS::UIView:: OnClickListener
{
public:
ItemClickListener(const ItemClickListener &) = delete;
ItemClickListener &operator=(const ItemClickListener &) = delete;
ItemClickListener() {}
~ItemClickListener() override
{
}
bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override
{
printf("ItemClick,type:%d,index:%d\n", view.GetViewType(), view.GetViewIndex());
TjdUiMessageTotalPage::messageType = (message_enum)view.GetViewIndex();
OHOS::NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MESSAGE_PARTICULAR);
return true;
}
};
//TjdUiMessageScreenDragListener* screenDragListener{nullptr};
OHOS::UIView::OnClickListener*itemClickListener{nullptr};
OHOS::UIView::OnClickListener*delClickListener{nullptr};
};
} // namespace OHOS
#endif