mcu_hi3321_watch/tjd/ui/app/weather/TjdUiAppWeatherView.h
2025-05-26 20:15:20 +08:00

115 lines
3.9 KiB
C++

/*----------------------------------------------------------------------------
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
*
* Description:
*
* Author: liangjianfei
*
* Create: 2024-6
*--------------------------------------------------------------------------*/
#ifndef TJDUI_APP_WEATHERVIEW_H
#define TJDUI_APP_WEATHERVIEW_H
#include "View.h"
#include "ui_list.h"
#include "ui_label.h"
#include "ui_image_view.h"
#include "ui_swipe_view.h"
#include "ui_scroll_view.h"
#include "ui_lite_surface_view.h"
#include "TjdUiAppWeatherAdapter.h"
#include "TjdUiAppWeatherPresenter.h"
#include "graphic_timer.h"
#include "graphic_service.h"
#include "components/ui_image_animator.h"
#include "ui_label_ext.h"
#include "components/ui_swipe_view_nested.h"
#include "components/ui_scroll_view_nested.h"
#define WEATHER_SWIPEVIEW_ID "weather_swipeview_id"
#define WEATHER_ICON "weather_icon"
#define WEATHER_LOCATION "weather_location"
#define WEATHER_CUR_TEMP "weather_cur_temp"
#define WEATHER_MIN_TEMP "weather_min_temp"
#define WEATHER_MAX_TEMP "weather_max_temp"
#define WEATHER_UPDATE_H "weather_update_h"
#define WEATHER_UPDATE_M "weather_update_m"
#define WEATHER_UPDATE_AMPM "weather_update_ampm"
typedef struct {
OHOS::UILabelExt *weekLabel_;
OHOS::UILabel *tempLabel_;
OHOS::UILabel *CLabel_;
OHOS::UIImageView *icon_;
}WeekWeather;
struct WeatherInfoRes
{
int startResId;
int size;
std::string path;
};
namespace TJD {
typedef bool (TjdUiAppWeatherView::*WeatherChangeView)(WeatherSlicePage hideView);
class TjdUiAppWeatherPresenter;
class TjdUiAppWeatherView : public OHOS::View<TjdUiAppWeatherPresenter>{
public:
TjdUiAppWeatherView();
virtual ~TjdUiAppWeatherView();
static TjdUiAppWeatherView *GetInstance(void);
void OnStart() override;
void OnStop() override;
void ChangedView(WeatherSlicePage view, WeatherSlicePage hideView);
bool ShowSwipeView(WeatherSlicePage hideView);
bool ShowNoConnectView(WeatherSlicePage hideView);
bool ShowMindView(WeatherSlicePage hideView);
OHOS::UIViewGroup *GetContainerAll(void) { return containerAll_; }
void UpdateSunPosition(void);
void UpdateWeekWeatherInfo(void);
void UpdateCurWeatherInfo(void);
OHOS::UISwipeViewNested *GetSwipeView(void) { return swipeContainer_; }
// OHOS::GraphicTimer *GetTimer(void) { return timer; }
// static void TimerCallback(void *arg);
WeatherInfoRes GetWeatherInfoRes(const WeatherInfo &type);
std::unique_ptr<OHOS::ImageAnimatorInfo[]> &GetAnimatorInfoArray(void) { return animatorInfoArray_; }
void AnimatorResLoadSuccess(void);
private:
OHOS::UIViewGroup *FirstPageViewInit(void);
OHOS::UIViewGroup *SecondPageViewInit(void);
OHOS::UIViewGroup *ThirdPageViewInit(void);
OHOS::UIViewGroup *FourthPageViewInit(void);
OHOS::UIScrollViewNested *MindPageViewInit(void);
WeatherChangeView viewMapper_[WEATHERSLICEPAGE_MAX] = {
&TjdUiAppWeatherView::ShowSwipeView,
&TjdUiAppWeatherView::ShowMindView,
&TjdUiAppWeatherView::ShowNoConnectView,
};
OHOS::UIViewGroup *containerAll_{nullptr};
OHOS::UIViewGroup *groupList_[WeatherSlicePage::WEATHERSLICEPAGE_MAX]{nullptr};
OHOS::UISwipeViewNested *swipeContainer_ = nullptr;
OHOS::UIViewGroup *firstPageContainer_ = nullptr;
OHOS::UIImageView *bgStatic_{nullptr};
OHOS::UILabelExt *weather_ = nullptr;
OHOS::UIImageAnimatorView *bgAnimator_{nullptr};
WeatherInfoRes curInfo_;
std::unique_ptr<OHOS::ImageAnimatorInfo[]> animatorInfoArray_;
uint16_t weartherType_;
// OHOS::GraphicTimer *timer = nullptr;
uint16_t sunX = 45;
uint16_t sunY = 168;
std::list<WeekWeather> weekWeather;
};
} // namespace OHOS
#endif // TJDUI_APP_WEATHERVIEW_H