InfiniTime.git

ref: e06dd405bc9548ad6e1250b01d6132fbe032bc4d

src/displayapp/screens/Weather.h


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once

#include <cstdint>
#include <lvgl/lvgl.h>
#include "displayapp/screens/Screen.h"
#include "components/ble/SimpleWeatherService.h"
#include "displayapp/apps/Apps.h"
#include "displayapp/Controllers.h"
#include "Symbols.h"
#include "utility/DirtyValue.h"

namespace Pinetime {

  namespace Controllers {
    class Settings;
  }

  namespace Applications {
    namespace Screens {

      class Weather : public Screen {
      public:
        Weather(Controllers::Settings& settingsController, Controllers::SimpleWeatherService& weatherService);
        ~Weather() override;

        void Refresh() override;

      private:
        Controllers::Settings& settingsController;
        Controllers::SimpleWeatherService& weatherService;

        Utility::DirtyValue<std::optional<Controllers::SimpleWeatherService::CurrentWeather>> currentWeather {};
        Utility::DirtyValue<std::optional<Controllers::SimpleWeatherService::Forecast>> currentForecast {};

        lv_obj_t* icon;
        lv_obj_t* condition;
        lv_obj_t* temperature;
        lv_obj_t* minTemperature;
        lv_obj_t* maxTemperature;
        lv_obj_t* forecast;

        lv_task_t* taskRefresh;
      };
    }

    template <>
    struct AppTraits<Apps::Weather> {
      static constexpr Apps app = Apps::Weather;
      static constexpr const char* icon = Screens::Symbols::cloudSunRain;

      static Screens::Screen* Create(AppControllers& controllers) {
        return new Screens::Weather(controllers.settingsController, *controllers.weatherController);
      };
    };
  }
}