91 lines
3.1 KiB
C++
91 lines
3.1 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description:
|
|
*
|
|
* Author: huangshuyi
|
|
*
|
|
* Create: 2024-8
|
|
*--------------------------------------------------------------------------*/
|
|
#include "common/screen.h"
|
|
#include "TjdUiAppCurtainEffect.h"
|
|
#include "dfx/dfx_dom_dump.h"
|
|
|
|
using namespace OHOS;
|
|
|
|
namespace TJD {
|
|
void TjdUiAppCurtainEffect::OnSwipe(UISwipeView& view)
|
|
{
|
|
//printf("OnSwipe\n");
|
|
ImageInfo info;
|
|
if (preLeftCard) {
|
|
container_->UIViewGroup::Remove(screenshotImage_);
|
|
if (preLeftCard->GetViewType() != UI_IMAGE_VIEW) {
|
|
ImageCacheFree(screenshotInfo_);
|
|
}
|
|
delete screenshotImage_;
|
|
screenshotImage_ = nullptr;
|
|
preLeftCard->SetVisible(true);
|
|
preRightCard->SetVisible(true);
|
|
preLeftCard = nullptr;
|
|
preRightCard = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
// 左rose 中cat 右dove
|
|
//向右滑 leftcard是rose rightcard是cat
|
|
//向左滑 leftcard是cat rightcard是dove
|
|
void TjdUiAppCurtainEffect::CommonAlg(UIView* leftCard, UIView* rightCard, int16_t xOffset)
|
|
{
|
|
//printf("xOffset:%d\n", xOffset);
|
|
if (preLeftCard != leftCard && preRightCard != rightCard) {
|
|
//printf("init preLeftCard and preRightCard\n");
|
|
if (leftCard->GetViewType() == UI_IMAGE_VIEW) {
|
|
if (xOffset > 0) {
|
|
screenshotInfo_ = *(static_cast<UIImageView *>(rightCard)->GetImageInfo());
|
|
} else {
|
|
screenshotInfo_ = *(static_cast<UIImageView *>(leftCard)->GetImageInfo());
|
|
}
|
|
} else {
|
|
if (xOffset > 0) {
|
|
rightCard->GetBitmap(screenshotInfo_);
|
|
} else {
|
|
leftCard->GetBitmap(screenshotInfo_);
|
|
}
|
|
}
|
|
preLeftCard = leftCard;
|
|
preRightCard = rightCard;
|
|
if (screenshotImage_ == nullptr) {
|
|
screenshotImage_ = new UIImageView();
|
|
}
|
|
screenshotImage_->SetPosition(0, 0, Screen::GetInstance().GetHeight(), Screen::GetInstance().GetWidth());
|
|
if (xOffset > 0) {
|
|
rightCard->SetVisible(false);
|
|
screenshotImage_->SetSrc(&screenshotInfo_);
|
|
container_->UIViewGroup::Insert(nullptr, screenshotImage_);
|
|
// DfxDomDump::GetInstance().DumpView(container_);
|
|
} else {
|
|
screenshotImage_->SetSrc(&screenshotInfo_);
|
|
leftCard->SetVisible(false);
|
|
container_->UIViewGroup::Insert(nullptr, screenshotImage_);
|
|
// DfxDomDump::GetInstance().DumpView(container_);
|
|
//DfxDomDump::GetInstance().DumpView(container_);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
void TjdUiAppCurtainEffect::CardSwipeAlg(UICardPage* leftCard, UICardPage* rightCard, int16_t xOffset)
|
|
{
|
|
//printf("using no jietu style,leftCard:%s,rightCard:%s,xOffset:%d\n", leftCard->GetViewId(), rightCard->GetViewId(), xOffset);
|
|
CommonAlg(leftCard, rightCard, xOffset);
|
|
}
|
|
|
|
void TjdUiAppCurtainEffect::CardSwipeAlg(UIImageView* leftCard, UIImageView* rightCard, int16_t xOffset)
|
|
{
|
|
//printf("using jietu style\n");
|
|
CommonAlg(leftCard, rightCard, xOffset);
|
|
}
|
|
}
|