-
-
Notifications
You must be signed in to change notification settings - Fork 759
[E.showMenu] Add option to add separators #2672
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
base: master
Are you sure you want to change the base?
Conversation
Adjusted the rendering of menu items and updated scroll properties.
|
Since this is my first or second PR here, what are the steps I need to take? I need to update the docs, should I add this for bangle.js 1 as well? |
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.
Pull request overview
This PR adds support for separator elements in the E.showMenu function for Bangle.js Q3 devices. Separators provide visual organization for long menu lists by allowing developers to add labeled divider lines between menu sections.
Key Changes:
- Added separator detection logic that identifies menu items with string value "separator" or "Separator"
- Implemented custom rendering for separators with centered text and horizontal divider line
- Adjusted title scroll offset from -24px to -32px and updated rendering position
Comments suppressed due to low confidence (1)
libs/js/banglejs/E_showMenu_Q3.js:165
- The select function does not check if the selected item is a separator. When a separator is clicked, it will execute Bangle.buzz(20) and may cause unintended behavior. Add a check to return early if the item is a separator string, similar to the check in the draw function: if ("string" == typeof item && (item == "separator" || item == "Separator")) return;
select : function(idx, touch) {
if (idx<0) return back&&back(); // title
var item = menu[keys[idx]];
Bangle.buzz(20);
if ("function" == typeof item) item(touch);
else if ("object" == typeof item) {
if ("number" == typeof item.value) {
showSubMenu(item, keys[idx]);
} else {
// if a bool, just toggle it
if ("boolean"==typeof item.value)
item.value=!item.value;
if (item.onchange) item.onchange(item.value, touch);
if (l.scroller.isActive()) l.scroller.drawItem(idx);
}
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Added the option to add separators by adding this to your existing menu:
And it'll make a separator for that, for better organization.
I got the idea when looking at app settings pages, some of which were really long, and not that organized. Instead of adding different pages for each category, it would be nice to have it all scrollable and still organized.
Screenshots:
Hopefully it'll help keep things organized in the future, and I think it looks pretty clean and modern as well.