feat(nodes): Display role-specific icons#4572
Merged
Merged
Conversation
This commit introduces dynamic, role-specific icons for nodes, enhancing the user interface by providing a clearer visual representation of a device's function within the mesh. A new `MeshtasticIcons.role()` function has been added to `core/ui` which maps each `Config.DeviceConfig.Role` to a distinct `ImageVector`. This allows for more granular and intuitive icons for roles such as `ROUTER`, `REPEATER`, `TRACKER`, `SENSOR`, and more. The `NodeDetailsSection` and `NodeItem` composables in the `feature/node` module have been updated to utilize this new functionality, replacing the generic role icon with specific icons based on the node's configured role. Additionally, a new `RoleInfo` composable overload that accepts a `Config.DeviceConfig.Role` enum has been created, improving type safety and code clarity. Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
…ction
This commit enhances the `DropDownPreference` composable to support leading icons for both the selected item and the items in the dropdown list. It also refactors the role selection UI to utilize this new capability.
Specific changes include:
- **`DropDownPreference` Refactor**:
- Introduced a `DropDownItem` data class to encapsulate the value, label, and an optional icon for each item.
- Overloaded `DropDownPreference` to accept a list of `DropDownItem` objects.
- The composable now displays an icon next to the selected item and in the dropdown list if provided.
- Added a helper for `Enum` types to automatically filter out `@Deprecated` values.
- **Role Selection UI**:
- A new `mountain_flag_24px` icon has been added and is now used for the `ROUTER` role.
- The device role dropdown in the radio configuration screen now displays an icon next to each role, improving clarity and user experience.
- **Iconography**:
- The `MeshtasticIcons.role` function is now a `@Composable` function to support vector resources.
- Removed deprecated `ROUTER_CLIENT` and `REPEATER` roles from the icon mapping.
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4572 +/- ##
=======================================
Coverage 14.79% 14.79%
=======================================
Files 427 428 +1
Lines 14841 14845 +4
Branches 2455 2456 +1
=======================================
+ Hits 2195 2197 +2
- Misses 12329 12330 +1
- Partials 317 318 +1 ☔ View full report in Codecov by Sentry. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request enhances the UI component system to support icons for enum-based dropdowns, and updates the device role display throughout the app to show a role-specific icon instead of a generic one. It introduces a new icon mapping for device roles, adds a custom drawable for router roles, and updates relevant UI components and usages to leverage these improvements.
UI Component Improvements:
DropDownPreferenceto support custom icons and labels for enum items, introducing a newDropDownItemdata class and optionalitemIconanditemLabellambdas. Deprecated and unrecognized enum values are now filtered out, and deprecated detection is handled via reflection. [1] [2] [3] [4] [5] [6]Device Role Icon Mapping:
MeshtasticIcons.rolefunction that mapsConfig.DeviceConfig.Roleenum values to specific Material icons or a custom vector drawable for routers, providing a unique icon for each role. [1] [2] [3]UI Usage Updates:
NodeDetailsSection,NodeItem, andTelemetryInfoto use the newMeshtasticIcons.rolemapping, ensuring consistent and meaningful iconography for roles. [1] [2] [3] [4] [5]Settings Screen Enhancements:
itemIconanditemLabelparameters. [1] [2]Assets:
mountain_flag_24px.xml) for the router role icon.