-
-
Notifications
You must be signed in to change notification settings - Fork 962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calendar app #923
Open
thnikk
wants to merge
14
commits into
InfiniTimeOrg:main
Choose a base branch
from
thnikk:develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Calendar app #923
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
800e948
Added calendar app
thnikk 498b722
Added status bar to calendar
thnikk 42aa879
Fixed crashing by disabling clicks
thnikk 67ffa04
Styled inactive months and removed styling from days of the week
thnikk bf546ca
Added month navigation with up and down swipes
thnikk 364a6cf
Changed today highlighting from red to an inverted background
thnikk b2fe1a2
Moved calendar to app
thnikk 63f14a3
Added symbol for calendar icon
thnikk 573f72b
Merged upstream
thnikk daf6912
Re-added calendar icon
thnikk ab614a7
Add calendar icon to range
thnikk 3d3474a
Changed swipe directions in calendar
thnikk e4a74ee
Updated statusbar to use formatted time
thnikk 3a739c6
Switched to set_text for statusbar instead of set_text_fmt
thnikk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ namespace Pinetime { | |
FlashLight, | ||
BatteryInfo, | ||
Music, | ||
Calendar, | ||
Paint, | ||
Paddle, | ||
Twos, | ||
|
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
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,85 @@ | ||
#include "displayapp/screens/Calendar.h" | ||
#include "displayapp/DisplayApp.h" | ||
#include "components/datetime/DateTimeController.h" | ||
#include "displayapp/screens/BatteryIcon.h" | ||
|
||
using namespace Pinetime::Applications::Screens; | ||
|
||
Calendar::Calendar(DisplayApp* app, Pinetime::Controllers::Battery& batteryController, Controllers::DateTime& dateTimeController) : Screen(app), batteryController {batteryController}, dateTimeController {dateTimeController} { | ||
|
||
// Status bar clock and battery | ||
label_time = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_text(label_time, dateTimeController.FormattedTime().c_str()); | ||
lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER); | ||
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0); | ||
batteryIcon = lv_label_create(lv_scr_act(), nullptr); | ||
lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); | ||
lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); | ||
|
||
// Create calendar object | ||
calendar = lv_calendar_create(lv_scr_act(), NULL); | ||
// Set size | ||
lv_obj_set_size(calendar, 230, 200); | ||
// Set alignment | ||
lv_obj_align(calendar, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -5); | ||
// 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_BLACK); | ||
|
||
// 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()); | ||
|
||
// 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; | ||
|
||
} | ||
|
||
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; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also utilize SwipeUP/SwipeDown to switch to next/prev year. Btw, a rebase is needed. And I've just done that so you call pull from: |
||
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,33 @@ | ||
#pragma once | ||
|
||
#include "displayapp/screens/Screen.h" | ||
#include <lvgl/lvgl.h> | ||
#include "components/datetime/DateTimeController.h" | ||
#include "components/battery/BatteryController.h" | ||
|
||
namespace Pinetime { | ||
namespace Controllers { | ||
class Settings; | ||
} | ||
|
||
namespace Applications { | ||
namespace Screens { | ||
class Calendar : public Screen { | ||
public: | ||
Calendar(DisplayApp* app, | ||
Pinetime::Controllers::Battery& batteryController, | ||
Controllers::DateTime& dateTimeController); | ||
~Calendar() override; | ||
private: | ||
bool OnTouchEvent(TouchEvents event); | ||
Pinetime::Controllers::Battery& batteryController; | ||
Controllers::DateTime& dateTimeController; | ||
lv_obj_t* batteryIcon; | ||
lv_obj_t* label_time; | ||
lv_obj_t * calendar; | ||
lv_calendar_date_t today; | ||
lv_calendar_date_t current; | ||
}; | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.