Skip to content
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

Add an optional help text to CheckboxList to explain that resources are missing #2214

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/displayapp/screens/CheckboxList.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "displayapp/DisplayApp.h"
#include "displayapp/screens/CheckboxList.h"
#include "displayapp/screens/Styles.h"
#include "displayapp/InfiniTimeTheme.h"

using namespace Pinetime::Applications::Screens;

Expand All @@ -17,7 +18,8 @@ CheckboxList::CheckboxList(const uint8_t screenID,
const char* optionsSymbol,
uint32_t originalValue,
std::function<void(uint32_t)> OnValueChanged,
std::array<Item, MaxItems> options)
std::array<Item, MaxItems> options,
const char* optionsHelptext)
: screenID {screenID},
OnValueChanged {std::move(OnValueChanged)},
options {options},
Expand Down Expand Up @@ -53,6 +55,17 @@ CheckboxList::CheckboxList(const uint8_t screenID,
lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER);
lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0);

lv_obj_t* helptext;
if (optionsHelptext != nullptr) {
helptext = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_align(helptext, LV_LABEL_ALIGN_CENTER);
lv_label_set_long_mode(helptext, LV_LABEL_LONG_SROLL_CIRC);
lv_obj_set_width(helptext, LV_HOR_RES);
lv_obj_set_style_local_text_color(helptext, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
lv_label_set_text_static(helptext, optionsHelptext);
lv_obj_align(helptext, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
}

for (unsigned int i = 0; i < options.size(); i++) {
if (strcmp(options[i].name, "")) {
cbOption[i] = lv_checkbox_create(container1, nullptr);
Expand Down
3 changes: 2 additions & 1 deletion src/displayapp/screens/CheckboxList.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ namespace Pinetime {
const char* optionsSymbol,
uint32_t originalValue,
std::function<void(uint32_t)> OnValueChanged,
std::array<Item, MaxItems> options);
std::array<Item, MaxItems> options,
const char* optionsHelptext = nullptr);
~CheckboxList() override;
void UpdateSelected(lv_obj_t* object, lv_event_t event);

Expand Down
6 changes: 5 additions & 1 deletion src/displayapp/screens/settings/SettingWatchFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ using namespace Pinetime::Applications::Screens;

constexpr const char* SettingWatchFace::title;
constexpr const char* SettingWatchFace::symbol;
constexpr const char* SettingWatchFace::helptext;

namespace {
uint32_t IndexOf(const std::array<Pinetime::Applications::Screens::SettingWatchFace::Item,
Expand Down Expand Up @@ -70,12 +71,14 @@ bool SettingWatchFace::OnTouchEvent(Pinetime::Applications::TouchEvents event) {

std::unique_ptr<Screen> SettingWatchFace::CreateScreen(unsigned int screenNum) const {
std::array<Screens::CheckboxList::Item, settingsPerScreen> watchfacesOnThisScreen;
bool needsHelptext = false;
for (int i = 0; i < settingsPerScreen; i++) {
if (i + (screenNum * settingsPerScreen) >= watchfaceItems.size()) {
watchfacesOnThisScreen[i] = {"", false};
} else {
auto& item = watchfaceItems[i + (screenNum * settingsPerScreen)];
watchfacesOnThisScreen[i] = Screens::CheckboxList::Item {item.name, item.enabled};
needsHelptext |= !item.enabled;
}
}

Expand All @@ -89,5 +92,6 @@ std::unique_ptr<Screen> SettingWatchFace::CreateScreen(unsigned int screenNum) c
settings.SetWatchFace(IndexToWatchFace(watchfaceItems, index));
settings.SaveSettings();
},
watchfacesOnThisScreen);
watchfacesOnThisScreen,
needsHelptext ? helptext : nullptr);
}
1 change: 1 addition & 0 deletions src/displayapp/screens/settings/SettingWatchFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace Pinetime {

static constexpr const char* title = "Watch face";
static constexpr const char* symbol = Symbols::home;
static constexpr const char* helptext = " Resources missing! Install resource pack to use greyed out watch faces.";

ScreenList<nScreens> screens;
};
Expand Down
Loading