87 lines
3.0 KiB
C++
87 lines
3.0 KiB
C++
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2025. All rights reserved.
|
|
*
|
|
* Description: TjdUiPageTransition.h
|
|
*
|
|
* Author: luziquan@ss-tjd.com
|
|
*
|
|
* Create: 2025-06-05
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
#ifndef TJD_UI_PAGE_TRANSITION_H
|
|
#define TJD_UI_PAGE_TRANSITION_H
|
|
|
|
#include "TjdUiPageManager.h"
|
|
#include <vector>
|
|
|
|
namespace TJD {
|
|
|
|
class UIPageTranslation
|
|
{
|
|
public:
|
|
virtual ~UIPageTranslation() = default;
|
|
|
|
virtual void Init(OHOS::UIImageView *target, OHOS::UIImageView *current, OHOS::UIViewGroup *parent,
|
|
uint32_t duration) = 0;
|
|
virtual void ApplyAnimation(int32_t runTime) = 0;
|
|
virtual void OnStop() = 0;
|
|
|
|
protected:
|
|
uint32_t duration_ = 0;
|
|
};
|
|
|
|
class UIPageTranslationManager
|
|
{
|
|
public:
|
|
static UIPageTranslationManager &GetInstance();
|
|
void RegisterTranslation(PageTransitionType type, UIPageTranslation *translation);
|
|
UIPageTranslation *GetTranslation(PageTransitionType type);
|
|
|
|
private:
|
|
UIPageTranslationManager();
|
|
~UIPageTranslationManager() = default;
|
|
UIPageTranslationManager(const UIPageTranslationManager &) = delete;
|
|
UIPageTranslationManager &operator=(const UIPageTranslationManager &) = delete;
|
|
std::vector<UIPageTranslation *> translations_;
|
|
};
|
|
|
|
#define TJD_REGISTER_PAGE_TRANSLATION(type, translation) \
|
|
static struct Register##translation \
|
|
{ \
|
|
Register##translation() \
|
|
{ \
|
|
UIPageTranslationManager::GetInstance().RegisterTranslation(type, new translation()); \
|
|
} \
|
|
} _register##translation;
|
|
|
|
class TranslationEnter : public UIPageTranslation
|
|
{
|
|
public:
|
|
void Init(OHOS::UIImageView *target, OHOS::UIImageView *current, OHOS::UIViewGroup *parent,
|
|
uint32_t duration) override;
|
|
void ApplyAnimation(int32_t runTime) override;
|
|
void OnStop() override;
|
|
|
|
private:
|
|
OHOS::UIImageView *targetImage_{nullptr};
|
|
OHOS::UIImageView *currentImage_{nullptr};
|
|
OHOS::UIViewGroup *parent_{nullptr};
|
|
};
|
|
|
|
class TranslationExit : public UIPageTranslation
|
|
{
|
|
public:
|
|
void Init(OHOS::UIImageView *target, OHOS::UIImageView *current, OHOS::UIViewGroup *parent,
|
|
uint32_t duration) override;
|
|
void ApplyAnimation(int32_t runTime) override;
|
|
void OnStop() override;
|
|
|
|
private:
|
|
OHOS::UIImageView *targetImage_{nullptr};
|
|
OHOS::UIImageView *currentImage_{nullptr};
|
|
OHOS::UIViewGroup *parent_{nullptr};
|
|
};
|
|
|
|
} // namespace TJD
|
|
|
|
#endif |