summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/Tab.cpp
blob: 44b806c0a6fd9acd460078d8f2e62966e096f73d (plain)
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
57
58
59
60
61
62
63
64
65
66
67
#include <cstdio>
#include <libs/date/includes/date/date.h>
#include "components/datetime/DateTimeController.h"
#include <Version.h>
#include <libs/lvgl/src/lv_core/lv_obj.h>
#include <libs/lvgl/src/lv_font/lv_font.h>
#include <libs/lvgl/lvgl.h>
#include <libraries/log/nrf_log.h>
#include "Tab.h"
#include "displayapp/DisplayApp.h"


using namespace Pinetime::Applications::Screens;

extern lv_font_t jetbrains_mono_bold_20;

//static void event_handler(lv_obj_t * obj, lv_event_t event) {
//  Tile* screen = static_cast<Tile *>(obj->user_data);
//  screen->OnObjectEvent(obj, event);
//}

Tab::Tab(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) {
/*Create a Tab view object*/
  lv_obj_t *tabview;
  tabview = lv_tabview_create(lv_scr_act(), NULL);

  /*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
  lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1");
  lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Tab 2");
  lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3");


  /*Add content to the tabs*/
  lv_obj_t * label = lv_label_create(tab1, NULL);
  lv_label_set_text(label, "This the first tab\n\n"
                           "If the content\n"
                           "of a tab\n"
                           "become too long\n"
                           "the it \n"
                           "automatically\n"
                           "become\n"
                           "scrollable.");

  label = lv_label_create(tab2, NULL);
  lv_label_set_text(label, "Second tab");

  label = lv_label_create(tab3, NULL);
  lv_label_set_text(label, "Third tab");

}

Tab::~Tab() {
  lv_obj_clean(lv_scr_act());
}

void Tab::Refresh(bool fullRefresh) {

}

void Tab::OnObjectEvent(lv_obj_t *obj, lv_event_t event) {
  if(event == LV_EVENT_CLICKED) {
    NRF_LOG_INFO("Clicked");
  }
  else if(event == LV_EVENT_VALUE_CHANGED) {
    NRF_LOG_INFO("Toggled");
  }
}