mcu_hi3321_watch/application/wearable/nativeapp/nativeui/uisample/include/UISampleView.h
2025-05-26 20:15:20 +08:00

61 lines
1.6 KiB
C++

/*
* Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
* Description: SettingView.h
* Author:
* Create: 2021-11-23
*/
#ifndef UISAMPLE_VIEW_H
#define UISAMPLE_VIEW_H
#include "View.h"
#include "components/root_view.h"
#include "components/ui_view_group.h"
#include "components/ui_scroll_view.h"
#include "components/ui_label.h"
#include "components/ui_list.h"
#include "ChangeSliceListener.h"
#include "test_case_list_adapter.h"
#include "UiConfig.h"
namespace OHOS {
class UISamplePresenter;
class UISampleOnDragListener : public UIView::OnDragListener {
public:
UISampleOnDragListener() {}
~UISampleOnDragListener() override {}
bool OnDrag(UIView& view, const DragEvent& event) override
{
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UISampleOnDragListener::OnDrag");
UNUSED(view);
if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) &&
(event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) {
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "UISampleOnDragListener::OnDrag ChangeSlice(VIEW_APPLIST)");
NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
}
return false;
}
};
class UISampleView : public View<UISamplePresenter> {
public:
UISampleView();
~UISampleView() override;
static UISampleView *GetInstance();
void OnStart() override;
void OnStop() override;
void InitView();
private:
UIView::OnDragListener *dragListener_ = nullptr;
UIList* mainList_ = nullptr;
TestCaseListAdapter* adapter_ = nullptr;
};
}
#endif // UISAMPLE_VIEW_H