Skip to content

Commit

Permalink
Reformatted the code to comply with clang-format.
Browse files Browse the repository at this point in the history
  • Loading branch information
JustScott committed Jan 15, 2024
1 parent e90c69c commit 94d384e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 65 deletions.
126 changes: 62 additions & 64 deletions src/displayapp/screens/Calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,75 +23,73 @@ using namespace Pinetime::Applications::Screens;

Calendar::Calendar(Controllers::DateTime& dateTimeController) : dateTimeController {dateTimeController} {

// Create calendar object
calendar = lv_calendar_create(lv_scr_act(), NULL);
// Set size
lv_obj_set_size(calendar, LV_HOR_RES, LV_VER_RES);
// Set alignment
lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5);
// Disable clicks
lv_obj_set_click(calendar, false);

// Set style of today's date
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
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex(0x505050));

// Get today's date
current.year = static_cast<int>(dateTimeController.Year());
current.month = static_cast<int>(dateTimeController.Month());
current.day = static_cast<int>(dateTimeController.Day());

// Set today's date
lv_calendar_set_today_date(calendar, &current);
lv_calendar_set_showed_date(calendar, &current);
// Create calendar object
calendar = lv_calendar_create(lv_scr_act(), NULL);
// Set size
lv_obj_set_size(calendar, LV_HOR_RES, LV_VER_RES);
// Set alignment
lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5);
// Disable clicks
lv_obj_set_click(calendar, false);

// Set style of today's date
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
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, lv_color_hex(0x505050));

// Get today's date
current.year = static_cast<int>(dateTimeController.Year());
current.month = static_cast<int>(dateTimeController.Month());
current.day = static_cast<int>(dateTimeController.Day());

// Set today's date
lv_calendar_set_today_date(calendar, &current);
lv_calendar_set_showed_date(calendar, &current);
}

bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case TouchEvents::SwipeLeft: {
if (current.month == 12) {
current.month = 1;
current.year++;
}
else{
current.month++;
}

lv_calendar_set_showed_date(calendar, &current);
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;
}
switch (event) {
case TouchEvents::SwipeLeft: {
if (current.month == 12) {
current.month = 1;
current.year++;
} else {
current.month++;
}

lv_calendar_set_showed_date(calendar, &current);
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;
}
}
}

Calendar::~Calendar() {
lv_obj_clean(lv_scr_act());
lv_obj_clean(lv_scr_act());
}
3 changes: 2 additions & 1 deletion src/displayapp/screens/Calendar.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "displayapp/screens/Screen.h"
#include "components/datetime/DateTimeController.h"
#include <lvgl/lvgl.h>

#include "Symbols.h"

namespace Pinetime {
Expand All @@ -37,6 +37,7 @@ namespace Pinetime {
public:
Calendar(Controllers::DateTime& dateTimeController);
~Calendar() override;

private:
bool OnTouchEvent(TouchEvents event);
Controllers::DateTime& dateTimeController;
Expand Down

0 comments on commit 94d384e

Please sign in to comment.