Reformatted the code to comply with clang-format.

This commit is contained in:
JustScott 2024-01-14 10:15:13 -06:00
parent 780e68f456
commit 0535e93848
2 changed files with 59 additions and 60 deletions

View file

@ -23,75 +23,73 @@ using namespace Pinetime::Applications::Screens;
Calendar::Calendar(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} { Calendar::Calendar(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} {
// Create calendar object // Create calendar object
calendar = lv_calendar_create(lv_scr_act(), NULL); calendar = lv_calendar_create(lv_scr_act(), NULL);
// Set size // Set size
lv_obj_set_size(calendar, LV_HOR_RES, LV_VER_RES); lv_obj_set_size(calendar, LV_HOR_RES, LV_VER_RES);
// Set alignment // Set alignment
lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5); lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5);
// Disable clicks // Disable clicks
lv_obj_set_click(calendar, false); lv_obj_set_click(calendar, false);
// Set style of today's date // Set style of today's date
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_RED); lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_RED);
// Set style of inactive month's days // Set style of inactive month's days
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex(0x505050)); lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex(0x505050));
// Get today's date // Get today's date
current.year = static_cast<int>(dateTimeController.Year()); current.year = static_cast<int>(dateTimeController.Year());
current.month = static_cast<int>(dateTimeController.Month()); current.month = static_cast<int>(dateTimeController.Month());
current.day = static_cast<int>(dateTimeController.Day()); current.day = static_cast<int>(dateTimeController.Day());
// Set today's date // Set today's date
lv_calendar_set_today_date(calendar, &current); lv_calendar_set_today_date(calendar, &current);
lv_calendar_set_showed_date(calendar, &current); lv_calendar_set_showed_date(calendar, &current);
} }
bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) { switch (event) {
case TouchEvents::SwipeLeft: { case TouchEvents::SwipeLeft: {
if (current.month == 12) { if (current.month == 12) {
current.month = 1; current.month = 1;
current.year++; current.year++;
} } else {
else{ current.month++;
current.month++; }
}
lv_calendar_set_showed_date(calendar, &current); lv_calendar_set_showed_date(calendar, &current);
return true; return true;
}
case TouchEvents::SwipeRight: {
if (current.month == 1) {
current.month = 12;
current.year--;
}
else{
current.month--;
}
lv_calendar_set_showed_date(calendar, &current);
return true;
}
/*
case TouchEvents::SwipeUp: {
current.year++;
lv_calendar_set_showed_date(calendar, &current);
return true;
}
case TouchEvents::SwipeDown: {
current.year--;
lv_calendar_set_showed_date(calendar, &current);
return true;
}
*/
default: {
return false;
}
} }
case TouchEvents::SwipeRight: {
if (current.month == 1) {
current.month = 12;
current.year--;
} else {
current.month--;
}
lv_calendar_set_showed_date(calendar, &current);
return true;
}
/*
case TouchEvents::SwipeUp: {
current.year++;
lv_calendar_set_showed_date(calendar, &current);
return true;
}
case TouchEvents::SwipeDown: {
current.year--;
lv_calendar_set_showed_date(calendar, &current);
return true;
}
*/
default: {
return false;
}
}
} }
Calendar::~Calendar() { Calendar::~Calendar() {
lv_obj_clean(lv_scr_act()); lv_obj_clean(lv_scr_act());
} }

View file

@ -23,7 +23,7 @@
#include "displayapp/screens/Screen.h" #include "displayapp/screens/Screen.h"
#include "components/datetime/DateTimeController.h" #include "components/datetime/DateTimeController.h"
#include <lvgl/lvgl.h> #include <lvgl/lvgl.h>
#include "Symbols.h" #include "Symbols.h"
namespace Pinetime { namespace Pinetime {
@ -37,6 +37,7 @@ namespace Pinetime {
public: public:
Calendar(Controllers::DateTime& dateTimeController); Calendar(Controllers::DateTime& dateTimeController);
~Calendar() override; ~Calendar() override;
private: private:
bool OnTouchEvent(TouchEvents event); bool OnTouchEvent(TouchEvents event);
Controllers::DateTime& dateTimeController; Controllers::DateTime& dateTimeController;