Skip to content

Commit

Permalink
Removed unused variables, some of the commented out code, and added a
Browse files Browse the repository at this point in the history
license copyright notice to the source and header calendar files.
  • Loading branch information
JustScott committed Jan 15, 2024
1 parent 47c9091 commit e90c69c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 19 deletions.
41 changes: 25 additions & 16 deletions src/displayapp/screens/Calendar.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/* Copyright (C) 2024 thnikk, Boteium, JustScott
This file is part of InfiniTime.
InfiniTime is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
InfiniTime is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include "displayapp/screens/Calendar.h"
#include "components/datetime/DateTimeController.h"

Expand All @@ -14,31 +32,20 @@ Calendar::Calendar(Controllers::DateTime& dateTimeController) : dateTimeControll
// Disable clicks
lv_obj_set_click(calendar, false);

// Set background of today's date
/*
lv_obj_set_style_local_bg_opa(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_OPA_COVER);
lv_obj_set_style_local_bg_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, LV_COLOR_WHITE);
lv_obj_set_style_local_radius(calendar, LV_CALENDAR_PART_DATE, LV_STATE_FOCUSED, 3);
*/

// 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
today.year = static_cast<int>(dateTimeController.Year());
today.month = static_cast<int>(dateTimeController.Month());
today.day = static_cast<int>(dateTimeController.Day());
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, &today);
lv_calendar_set_showed_date(calendar, &today);

// Use today's date as a reference for which month to show if moved
current = today;

lv_calendar_set_today_date(calendar, &current);
lv_calendar_set_showed_date(calendar, &current);
}

bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
Expand All @@ -51,6 +58,7 @@ bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
else{
current.month++;
}

lv_calendar_set_showed_date(calendar, &current);
return true;
}
Expand All @@ -62,6 +70,7 @@ bool Calendar::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
else{
current.month--;
}

lv_calendar_set_showed_date(calendar, &current);
return true;
}
Expand Down
22 changes: 19 additions & 3 deletions src/displayapp/screens/Calendar.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/* Copyright (C) 2024 thnikk, Boteium, JustScott
This file is part of InfiniTime.
InfiniTime is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
InfiniTime is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include "displayapp/apps/Apps.h"
Expand All @@ -22,9 +40,7 @@ namespace Pinetime {
private:
bool OnTouchEvent(TouchEvents event);
Controllers::DateTime& dateTimeController;
lv_obj_t* label_time;
lv_obj_t * calendar;
lv_calendar_date_t today;
lv_obj_t* calendar;
lv_calendar_date_t current;
};
}
Expand Down

0 comments on commit e90c69c

Please sign in to comment.