-
-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A basic calendar app that shows all the days dates in the current month along with the correlating week days, highlights the current day, and allows swiping left and right to increase and decrease the current month by one. Co-authored-by: thnikk <[email protected]> Co-authored-by: Boteium <[email protected]>
- Loading branch information
1 parent
d69cfcf
commit e374a77
Showing
9 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ namespace Pinetime { | |
Twos, | ||
HeartRate, | ||
Navigation, | ||
Calendar, | ||
StopWatch, | ||
Metronome, | ||
Motion, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* 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" | ||
#include "displayapp/InfiniTimeTheme.h" | ||
|
||
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, Colors::deepOrange); | ||
|
||
// Set style of inactive month's days | ||
lv_obj_set_style_local_text_color(calendar, LV_CALENDAR_PART_DATE, LV_STATE_DISABLED, Colors::gray); | ||
|
||
// 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, ¤t); | ||
lv_calendar_set_showed_date(calendar, ¤t); | ||
} | ||
|
||
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, ¤t); | ||
return true; | ||
} | ||
case TouchEvents::SwipeRight: { | ||
if (current.month == 1) { | ||
current.month = 12; | ||
current.year--; | ||
} else { | ||
current.month--; | ||
} | ||
|
||
lv_calendar_set_showed_date(calendar, ¤t); | ||
return true; | ||
} | ||
/* | ||
case TouchEvents::SwipeUp: { | ||
current.year++; | ||
lv_calendar_set_showed_date(calendar, ¤t); | ||
return true; | ||
} | ||
case TouchEvents::SwipeDown: { | ||
current.year--; | ||
lv_calendar_set_showed_date(calendar, ¤t); | ||
return true; | ||
} | ||
*/ | ||
default: { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
Calendar::~Calendar() { | ||
lv_obj_clean(lv_scr_act()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* 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" | ||
#include "displayapp/Controllers.h" | ||
#include "displayapp/screens/Screen.h" | ||
#include "components/datetime/DateTimeController.h" | ||
#include <lvgl/lvgl.h> | ||
|
||
#include "Symbols.h" | ||
|
||
namespace Pinetime { | ||
namespace Controllers { | ||
class Settings; | ||
} | ||
|
||
namespace Applications { | ||
namespace Screens { | ||
class Calendar : public Screen { | ||
public: | ||
Calendar(Controllers::DateTime& dateTimeController); | ||
~Calendar() override; | ||
|
||
private: | ||
bool OnTouchEvent(TouchEvents event); | ||
Controllers::DateTime& dateTimeController; | ||
lv_obj_t* calendar; | ||
lv_calendar_date_t current; | ||
}; | ||
} | ||
|
||
template <> | ||
struct AppTraits<Apps::Calendar> { | ||
static constexpr Apps app = Apps::Calendar; | ||
static constexpr const char* icon = Screens::Symbols::calendar; | ||
|
||
static Screens::Screen* Create(AppControllers& controllers) { | ||
return new Screens::Calendar(controllers.dateTimeController); | ||
}; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters