109 lines
3.7 KiB
C++
109 lines
3.7 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description:
|
|
*
|
|
* Author: huangshuyi
|
|
*
|
|
* Create: 2024-8
|
|
*--------------------------------------------------------------------------*/
|
|
#include "common/screen.h"
|
|
#include "TjdUiAppCurtainFadeInEffect.h"
|
|
#include "dfx/dfx_dom_dump.h"
|
|
|
|
using namespace OHOS;
|
|
|
|
namespace TJD {
|
|
void TjdUiAppCurtainFadeInEffect::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 TjdUiAppCurtainFadeInEffect::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_);
|
|
}
|
|
}
|
|
|
|
int16_t width = Screen::GetInstance().GetWidth();
|
|
int16_t middleWidth = width / 2;
|
|
uint8_t opa;
|
|
opa = EasingEquation::LinearEaseNone(0, 255, abs(xOffset), width);
|
|
//printf("opa:%d,offset:%d\n", opa, xOffset);
|
|
|
|
if (xOffset > 0) {
|
|
leftCard->SetOpaScale(opa);
|
|
rightCard->SetOpaScale(255 - opa);
|
|
|
|
//leftCard->SetStyle(STYLE_IMAGE_OPA, opa);
|
|
//rightCard->SetOpacity(100 - opa);
|
|
} else if (xOffset < 0) {
|
|
rightCard->SetOpaScale(opa);
|
|
leftCard->SetOpaScale(255 - opa);
|
|
|
|
}
|
|
return;
|
|
}
|
|
|
|
void TjdUiAppCurtainFadeInEffect::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 TjdUiAppCurtainFadeInEffect::CardSwipeAlg(UIImageView* leftCard, UIImageView* rightCard, int16_t xOffset)
|
|
{
|
|
//printf("using jietu style\n");
|
|
CommonAlg(leftCard, rightCard, xOffset);
|
|
}
|
|
}
|