/*---------------------------------------------------------------------------- * Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved. * * Description: TjdUiWFPageFootballOne.h * * Author: huangshuyi * * Create: 2024-9 *--------------------------------------------------------------------------*/ #ifndef TJDUI_WF_PAGE_FOOTBALL_ONE_H #define TJDUI_WF_PAGE_FOOTBALL_ONE_H #include "TjdUiWatchFaceBase.h" #include "common/image.h" #include "components/ui_icosahedron_view.h" #include "components/ui_label.h" #include "components/ui_sweep_clock.h" #include "components/ui_view_group.h" #include "graphic_timer.h" namespace TJD { class TjdUiWFPageFootballOne : public TjdUiWfBase, public OHOS::UIView::OnClickListener, public OHOS::UIView::OnDragListener { public: TjdUiWFPageFootballOne(); virtual ~TjdUiWFPageFootballOne(); void InitView(); void Update(void) override; void PreLoad(void) override; void UnLoad(void) override; void OnActive() override; void OnInactive() override; private: void PageInit(); void InitClock(void); bool viewiInitStatus{false}; OHOS::UIViewGroup *mainView_{nullptr}; OHOS::ImageInfo* imgInfo_ = nullptr; OHOS::ImageInfo* imgInverseInfo_ = nullptr; OHOS::UILabel *labelTimeH_{nullptr }; OHOS::UILabel *labelTimeM_{nullptr }; OHOS::UILabel *labelDiv_{nullptr }; OHOS::UILabel *labelDate_{nullptr}; OHOS::UILabel *labelWeek_{nullptr}; OHOS::Image *secondHand{nullptr}; OHOS::Image *minuteHand{nullptr}; OHOS::Image *hourHand{nullptr}; OHOS::Image *dotHand{nullptr}; OHOS::UISweepClock *mainSweepClock{nullptr}; class FootballUIIcosahedronView : public OHOS::UIIcosahedronView { public: bool OnDragStartEvent(const OHOS::DragEvent& event) override { if (animator_) { animator_->Stop(); } if (footballRect_.IsContains(event.GetCurrentPos())) { UIIcosahedronView::OnDragStartEvent(event); isOutZoneStart_ = false; return true; } isOutZoneStart_ = true; return false; } bool OnDragEvent(const OHOS::DragEvent& event) override { if (isOutZoneStart_ == false) { UIIcosahedronView::OnDragEvent(event); return true; } return false; } bool OnDragEndEvent(const OHOS::DragEvent& event) override { if (animator_) { animator_->Start(); } if (isOutZoneStart_ == false) { UIIcosahedronView::OnDragEndEvent(event); return true; } return false; } void SetAnimator(OHOS::Animator* animator) { animator_ = animator; } OHOS::Rect footballRect_; private: bool isOutZoneStart_ = false; OHOS::Animator* animator_ = nullptr; }; FootballUIIcosahedronView* container_ = nullptr; class EntryAnimatorCallback : public OHOS::AnimatorCallback { public: explicit EntryAnimatorCallback(OHOS::UIView* view, int16_t startPos, int16_t endPos) : startPos_(startPos), endPos_(endPos), animator_(new OHOS::Animator(this, view, 0, true)) {} // 1000:duration of animator_, in milliseconds. ~EntryAnimatorCallback() override { if (animator_ != nullptr) { delete animator_; animator_ = nullptr; } } void Callback(OHOS::UIView* view) override; OHOS::Animator* GetAnimator() const { return animator_; } protected: int16_t startPos_; int16_t endPos_; OHOS::Animator* animator_; }; EntryAnimatorCallback* callback_ = nullptr; OHOS::Animator* enterAnimator_ = nullptr; OHOS::GraphicTimer* timesClock_{nullptr}; }; } // namespace TJD #endif // TJDUI_FOOTBALL_PAGE_H