mcu_hi3321_watch/tjd/ui/app/wallet/TjdUiAppWalletPresenter.cpp
2025-05-26 20:15:20 +08:00

125 lines
3.7 KiB
C++
Raw Permalink 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.

#include "TjdUiAppWalletPresenter.h"
#include "NativeAbility.h"
#include "TjdUiAppIds.h"
#include "dock/input_device.h"
#include "TjdUiAppWalletView.h"
#include "TjdUiRegisterManager.h"
using namespace OHOS;
namespace TJD {
TJD_REGIST_NATIVE_MENU(TJD_APP_VIEW_WALLET, TjdUiAppWalletView, TjdUiAppWalletPresenter, IMG_MENU_LIST_MENU_WALLET, STR_ID_23);
static TjdUiAppWalletPresenter *g_pv_AppWalletPresenter = nullptr;
TjdUiAppWalletPresenter::TjdUiAppWalletPresenter()
{
g_pv_AppWalletPresenter = this;
}
TjdUiAppWalletPresenter::~TjdUiAppWalletPresenter()
{
g_pv_AppWalletPresenter = nullptr;
}
TjdUiAppWalletPresenter *TjdUiAppWalletPresenter::GetInstance(void) { return g_pv_AppWalletPresenter; }
void TjdUiAppWalletPresenter::OnStart()
{
TjdUiCommonOnKeyListener::GetInstance()->SetOnKeyActListener(this, KeyModelType::APP_KEY_TYPE);
}
void TjdUiAppWalletPresenter::OnStop()
{
TjdUiCommonOnKeyListener::GetInstance()->ClearOnKeyActListener(KeyModelType::APP_KEY_TYPE);
}
void TjdUiAppWalletPresenter::ScreenDragEventCallback(OHOS::UIView &view, const OHOS::DragEvent &event)
{
TjdUiAppWalletView *walletView = TjdUiAppWalletView::GetInstance();
if (walletView == nullptr) {
return;
}
switch (TjdUiAppWalletView::currentViewIndex_) {
case WalletView::TIPVIEW:
OHOS::NativeAbility::GetInstance().ChangePreSlice();
break;
case WalletView::LISTVIEW:
OHOS::NativeAbility::GetInstance().ChangePreSlice();
break;
case WalletView::CARDVIEW:
walletView->ChangedView(WalletView::LISTVIEW,WalletView::CARDVIEW);
break;
default:
break;
}
}
// bool TjdUiAppWalletPresenter::OnDragStart(OHOS::UIView &view, const OHOS::DragEvent &event)
// {
// // 如果在0-80的距离内开始滑动并且拖动的距离大于200则认为是退出标志
// dragStartX_ = event.GetStartPoint().x;
// return false;
// }
// bool TjdUiAppWalletPresenter::OnDrag(OHOS::UIView &view, const OHOS::DragEvent &event)
// {
// dragCurrentX_ = event.GetCurrentPos().x;
// dragDistance_ = dragCurrentX_ - dragStartX_;
// return false;
// }
// bool TjdUiAppWalletPresenter::OnDragEnd(OHOS::UIView &view, const OHOS::DragEvent &event)
// {
// dragDistance_ = dragCurrentX_ - dragStartX_;
// if (dragDistance_ >= 250 && dragStartX_ < 80) {
// isExit_ = true;
// } else {
// isExit_ = false;
// }
// dragDistance_ = 0;
// if (isExit_ == false) {
// return false;
// }
// if (event.GetDragDirection() == OHOS::DragEvent::DIRECTION_LEFT_TO_RIGHT) {
// // OHOS::NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MENU_LIST);
// OHOS::NativeAbility::GetInstance().ChangePreSlice();
// }
// return false;
// }
bool TjdUiAppWalletPresenter::OnKeyAct(OHOS::UIView &view, const OHOS::KeyEvent &event)
{
if (!TjdUiCommonOnKeyListener::CheckIsExitEvent(event)) {
return true;
}
ExitWalletView();
return false;
}
bool TjdUiAppWalletPresenter::OnClick(UIView &view, const ClickEvent &event)
{
if (view.GetViewId() == "imgReturn_Return") {
// OHOS::NativeAbility::GetInstance().ChangeSlice(TJD_APP_VIEW_MENU_LIST);
OHOS::NativeAbility::GetInstance().ChangePreSlice();
}
else if(view.GetViewId() == "imgReturn_cardView"){
TjdUiAppWalletView::GetInstance()->ChangedView(LISTVIEW,CARDVIEW);
}else if(view.GetViewId() == "imgReturn_listView"){
TjdUiAppWalletView::GetInstance()->ChangedView(LISTVIEW,TIPVIEW);
}
return true;
}
void TjdUiAppWalletPresenter::ExitWalletView(void)
{
OHOS::NativeAbility::GetInstance().ChangePreSlice();
}
} // namespace TJD