#ifndef TJD_UI_APP_STOPWATCH_VIEW_H #define TJD_UI_APP_STOPWATCH_VIEW_H #include "TjdUiAppStopwatchAdapter.h" #include "TjdUiAppStopwatchPresenter.h" #include "TjdUiMemManage.h" #include "View.h" #include "common/image.h" #include "components/root_view.h" #include "components/ui_image_animator.h" #include "components/ui_image_view.h" #include "components/ui_label.h" #include "components/ui_list.h" #include "components/ui_scroll_view.h" #include "components/ui_scroll_view_nested.h" #include "components/ui_view.h" #include "components/ui_view_group.h" #include "gfx_utils/graphic_types.h" #include "hal_tick.h" #include "rtc_api.h" #include "sys/time.h" #include "time.h" #include "ui_label_ext.h" #include "ui_view.h" namespace TJD { enum StopwatchViewIndex { STOPWATCH_START_VIEW, STOPWATCH_CARRY_VIEW, STOPWATCH_PAUSE_VIEW, STOPWATCH_LIST_VIEW, STOPWATCH_VIEW_COUNT }; class StopwatchAnimatorCallback : public OHOS::AnimatorCallback { public: explicit StopwatchAnimatorCallback(OHOS::UIImageView *img) : stopwatchImageScale_(img) {} ~StopwatchAnimatorCallback() override {} void Callback(OHOS::UIView *view) override; void OnStop(OHOS::UIView &view) override { curTime = 0; } uint32_t startTimestamp = 0; void SetAnimator(OHOS::Animator *animator) { animator_ = animator; } void SetLabel(OHOS::UILabel *label) { label_ = label; } private: OHOS::Point labelStartPos_{107, 230}; OHOS::Point labelEndPos_{161, 76}; OHOS::Point imageStartPos_{179, 92}; OHOS::Point imageEndPos_{92, 86}; OHOS::UILabel *label_ = nullptr; OHOS::Animator *animator_{nullptr}; OHOS::UIImageView *stopwatchImageScale_ = nullptr; float scale = 0; uint16_t curTime = 0; uint16_t durationTime = 200; int16_t startVal = durationTime; int16_t endVal = durationTime / 2; // 2: half }; class StopwatchUIScrollView : public OHOS::UIScrollViewNested { public: StopwatchUIScrollView() {} ~StopwatchUIScrollView() {} bool OnDragStartEvent(const OHOS::DragEvent &event) override; bool OnDragEvent(const OHOS::DragEvent &event) override; bool OnDragEndEvent(const OHOS::DragEvent &event) override; private: bool isOnStart_{false}; }; class TjdUiAppStopwatchtPresenter; class TjdUiAppStopwatchView : public OHOS::View, public OHOS::UIViewGroup { public: TjdUiAppStopwatchView(); ~TjdUiAppStopwatchView(); static TjdUiAppStopwatchView *GetInstance(void); void OnStart() override; void OnStop() override; void ShowView(StopwatchViewIndex hideView, StopwatchViewIndex showView); void ChangestatusPause(); void ChangestatusPause_(); void ChangeAnimator(); void ChangestatusResume(); void ChangestatusClear(); void ShowList(); void UpdateStopwatchTime(); void SaveStopwatchTime(); void StartAnimator(); void MoveLabel(); void StopTimer(); void CoumtNumInit(); void StopAiainAnimator(int8_t boolnum); StopwatchViewIndex GetCurrentView() { return currentView_; } OHOS::List &GetStopwatchItemList() { return *stopwatchInfoList_; } void SetStopWatchListOpa(uint8_t opa); bool GetStopWatchStart1Visible() { return stopwatchStart1_->IsVisible(); } bool GetStopWatchPause1Visible() { return stopwatchPause1_->IsVisible(); } bool GetStopWatchPause2Visible() { return stopwatchPause2_->IsVisible(); } bool GetStopWatchResumeVisible() { return stopwatchResume_->IsVisible(); } OHOS::UIView listBg1; OHOS::UIView listBg2; private: StopwatchViewIndex currentView_{StopwatchViewIndex::STOPWATCH_START_VIEW}; std::string textStopwatch1_{nullptr}; StopwatchUIScrollView *containerAll_{nullptr}; OHOS::UIViewGroup *stopwatchView[STOPWATCH_VIEW_COUNT]{nullptr}; OHOS::UIScrollView *InitStopwatchStartView(); OHOS::UIScrollView *InitStopwatchCarryView(); OHOS::UIImageView *stopwatchImage1_{nullptr}; OHOS::UIImageView *stopwatchImage2_{nullptr}; OHOS::UIImageView *stopwatchImageScale_{nullptr}; OHOS::UIImageView *stopwatchImage4_{nullptr}; OHOS::UIImageView *stopwatchStart1_{nullptr}; OHOS::UIImageView *stopwatchStart2_{nullptr}; OHOS::UIImageView *stopwatchResume_{nullptr}; OHOS::UIImageView *stopwatchClear_{nullptr}; OHOS::UIImageView *stopwatchPause1_{nullptr}; OHOS::UIImageView *stopwatchPause2_{nullptr}; OHOS::UIImageView *stopwatchList1_{nullptr}; OHOS::UIImageView *stopwatchImageScaleTwo{nullptr}; OHOS::UILabel *lblStopWatchStartTime_{nullptr}; OHOS::UILabel *lblStopWatchPauseTime_{nullptr}; OHOS::UILabel *lblStopWatchCarryTime_{nullptr}; OHOS::UILabel *lblStopWatchListTime_{nullptr}; OHOS::UILabelExt *lblTopStopWatch1_{nullptr}; OHOS::UILabel *lblTopStopWatch2_{nullptr}; OHOS::UIImageAnimatorView *imageAnimatorstopwatch1_{nullptr}; void InitStopwatchImage(); std::string textStopwatch2_{nullptr}; uint64_t timestamp{0}; uint64_t time1_{0}; uint64_t time2_{0}; uint64_t time3_{0}; uint64_t time4_{0}; uint64_t time5_{0}; uint64_t time6_{0}; uint8_t countNum_{0}; uint64_t timeinterval{0}; bool boolFlag_{true}; bool boolFlagAgain_{false}; OHOS::List *stopwatchInfoList_{nullptr}; TjdUiAppStopwatchAdapter *stopwatchListAdapter_{nullptr}; OHOS::UIList *stopwatchList_{nullptr}; StopwatchAnimatorCallback *callBack_{nullptr}; OHOS::Animator *moveAnimator_{nullptr}; bool animateStart_{false}; OHOS::GraphicTimer *timerMoveLabel_{nullptr}; uint16_t moveX{107}; uint16_t moveY{230}; uint16_t changeSize{72}; }; } #endif