@@ -23,75 +23,73 @@ using namespace Pinetime::Applications::Screens;
23
23
24
24
Calendar::Calendar (Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} {
25
25
26
- // Create calendar object
27
- calendar = lv_calendar_create (lv_scr_act (), NULL );
28
- // Set size
29
- lv_obj_set_size (calendar, LV_HOR_RES, LV_VER_RES);
30
- // Set alignment
31
- lv_obj_align (calendar, NULL , LV_ALIGN_IN_BOTTOM_MID, 0 , -5 );
32
- // Disable clicks
33
- lv_obj_set_click (calendar, false );
34
-
35
- // Set style of today's date
36
- lv_obj_set_style_local_text_color (calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_RED);
37
-
38
- // Set style of inactive month's days
39
- lv_obj_set_style_local_text_color (calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex (0x505050 ));
40
-
41
- // Get today's date
42
- current.year = static_cast <int >(dateTimeController.Year ());
43
- current.month = static_cast <int >(dateTimeController.Month ());
44
- current.day = static_cast <int >(dateTimeController.Day ());
45
-
46
- // Set today's date
47
- lv_calendar_set_today_date (calendar, ¤t);
48
- lv_calendar_set_showed_date (calendar, ¤t);
26
+ // Create calendar object
27
+ calendar = lv_calendar_create (lv_scr_act (), NULL );
28
+ // Set size
29
+ lv_obj_set_size (calendar, LV_HOR_RES, LV_VER_RES);
30
+ // Set alignment
31
+ lv_obj_align (calendar, NULL , LV_ALIGN_IN_BOTTOM_MID, 0 , -5 );
32
+ // Disable clicks
33
+ lv_obj_set_click (calendar, false );
34
+
35
+ // Set style of today's date
36
+ lv_obj_set_style_local_text_color (calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_RED);
37
+
38
+ // Set style of inactive month's days
39
+ lv_obj_set_style_local_text_color (calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex (0x505050 ));
40
+
41
+ // Get today's date
42
+ current.year = static_cast <int >(dateTimeController.Year ());
43
+ current.month = static_cast <int >(dateTimeController.Month ());
44
+ current.day = static_cast <int >(dateTimeController.Day ());
45
+
46
+ // Set today's date
47
+ lv_calendar_set_today_date (calendar, ¤t);
48
+ lv_calendar_set_showed_date (calendar, ¤t);
49
49
}
50
50
51
51
bool Calendar::OnTouchEvent (Pinetime::Applications::TouchEvents event) {
52
- switch (event) {
53
- case TouchEvents::SwipeLeft: {
54
- if (current.month == 12 ) {
55
- current.month = 1 ;
56
- current.year ++;
57
- }
58
- else {
59
- current.month ++;
60
- }
61
-
62
- lv_calendar_set_showed_date (calendar, ¤t);
63
- return true ;
64
- }
65
- case TouchEvents::SwipeRight: {
66
- if (current.month == 1 ) {
67
- current.month = 12 ;
68
- current.year --;
69
- }
70
- else {
71
- current.month --;
72
- }
73
-
74
- lv_calendar_set_showed_date (calendar, ¤t);
75
- return true ;
76
- }
77
- /*
78
- case TouchEvents::SwipeUp: {
79
- current.year++;
80
- lv_calendar_set_showed_date(calendar, ¤t);
81
- return true;
82
- }
83
- case TouchEvents::SwipeDown: {
84
- current.year--;
85
- lv_calendar_set_showed_date(calendar, ¤t);
86
- return true;
87
- }
88
- */
89
- default : {
90
- return false ;
91
- }
52
+ switch (event) {
53
+ case TouchEvents::SwipeLeft: {
54
+ if (current.month == 12 ) {
55
+ current.month = 1 ;
56
+ current.year ++;
57
+ } else {
58
+ current.month ++;
59
+ }
60
+
61
+ lv_calendar_set_showed_date (calendar, ¤t);
62
+ return true ;
92
63
}
64
+ case TouchEvents::SwipeRight: {
65
+ if (current.month == 1 ) {
66
+ current.month = 12 ;
67
+ current.year --;
68
+ } else {
69
+ current.month --;
70
+ }
71
+
72
+ lv_calendar_set_showed_date (calendar, ¤t);
73
+ return true ;
74
+ }
75
+ /*
76
+ case TouchEvents::SwipeUp: {
77
+ current.year++;
78
+ lv_calendar_set_showed_date(calendar, ¤t);
79
+ return true;
80
+ }
81
+ case TouchEvents::SwipeDown: {
82
+ current.year--;
83
+ lv_calendar_set_showed_date(calendar, ¤t);
84
+ return true;
85
+ }
86
+ */
87
+ default : {
88
+ return false ;
89
+ }
90
+ }
93
91
}
94
92
95
93
Calendar::~Calendar () {
96
- lv_obj_clean (lv_scr_act ());
94
+ lv_obj_clean (lv_scr_act ());
97
95
}
0 commit comments