-
Notifications
You must be signed in to change notification settings - Fork 404
Experiment: Native HomeView/dashboard #4142
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
Conversation
Co-authored-by: bgoncal <[email protected]>
Co-authored-by: bgoncal <[email protected]>
Moved EntityTileView from HomeView.swift to a new EntityTileView.swift file and enhanced it to support displaying entity state and customizable icon color. Updated HomeView toolbar to use ToolbarItemGroup and improved button layout.
HomeView and HomeViewModel now require a Server instance to be passed during initialization, improving dependency management and testability. Updated usages and previews accordingly. Also added @available(iOS 26.0, *) and @observable annotations, and made minor UI adjustments including a new toolbar button and navigation title.
EntityTileView now displays icon color based on entity state and attributes, supporting color modes such as rgb and hs. HomeViewModel subscribes to entity state changes and provides up-to-date state and attributes to EntityTileView, improving real-time UI feedback for entities like lights.
Moved context-aware state description logic into Domain.contextualStateDescription(for:), reducing duplication and improving maintainability. Updated EntityTileView to use HAEntity and Domain for state and icon logic, and adjusted HomeView and CarPlayEntityListItem to use the new API. Added Domain.swift to WebView/Home and made minor CarPlay icon rendering adjustments for platform compatibility.
EntityTileView now wraps the icon in a Button that triggers a LightIntent for light entities, enabling AppIntents-based actions from the UI. The view and its initializer are updated to accept a Server parameter, and HomeView is updated to pass the server. Minor improvements and fixes are included for entity ID usage and LightIntent parameter defaults.
Updated HomeViewModel to include both light and cover domains when filtering entities for the selected server. Also reformatted LightIntent initialization in EntityTileView for readability and fixed minor formatting in LightIntent.swift.
7a3b516 to
b154cbe
Compare
|
Found 1 unused localization strings in the codebase. Click to see detailsTo clean up these strings, manually remove them from the |
Extracted the animated gradient and orb background from ModernAssistView into a new reusable ModernAssistBackgroundView component. Updated ModernAssistView and HomeView to use the new background view. Also improved EntityTileView with a glass effect and adjusted corner radius, and updated HomeView grid spacing for consistency.
Extended entity intent handling and filtering to support the 'cover' domain alongside 'light'. Updated HomeViewModel to use a shared allowedDomains list and refactored domain filtering logic. Also added specific state string handling for the 'shade' device class in Domain.swift.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4142 +/- ##
=======================================
Coverage ? 45.07%
=======================================
Files ? 244
Lines ? 13903
Branches ? 0
=======================================
Hits ? 6267
Misses ? 7636
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Wow this is awesome and beats a webview... I hope the Android team is looking at this and making thier own native UI too, would be great. |
|
For now it's just an experiment, it's a long run until having enough implemented for a fully functional native dashboard hahaha but thanks for the feedback! 💪🏻 CC: @TimoPtr |
Introduces a toolbar menu allowing users to filter displayed sections in HomeView, with support for single or multiple section selection. Adds state management for selected sections and updates the view to show only filtered sections. Includes UI for toggling multi-selection and clearing filters.
Introduces HomeSectionsReorderView for reordering room sections in the Home view. Removes Domain.swift, updates HomeView and HomeViewModel to support section order persistence, filtering, and toggling selection logic. Section order is now saved per server and can be modified via a new UI.
Extracted the RoomIdentifier struct from HomeView.swift and placed it in a new RoomIdentifier.swift file under the Room directory. Updated the Xcode project to include the new file.
Added observation of HomeViewConfiguration changes using ValueObservation. The configuration property now saves cached data on update, and the initializer sets up observation instead of directly loading the configuration. This ensures the view model stays in sync with configuration changes in the database.
Simplifies the observeConfigChanges method by removing the do-catch block and directly initializing the ValueObservation. Updates error logging message for clarity.
HomeViewConfiguration now conforms to Equatable, enabling comparison. RoomView now updates cached entities when the configuration changes, improving data consistency.
HomeView and HomeViewModel now manage entity subscriptions based on app lifecycle events. Subscriptions are started when the app becomes active and stopped when entering the background, improving resource management and ensuring up-to-date data.
Introduces ValueObservation-based listeners for appEntities and registryEntities, ensuring the HomeViewModel updates its data and subscriptions reactively when underlying database entities change. This improves data consistency and removes the need for initial synchronous entity loading.
Refactors the HomeView toolbar by splitting it into smaller components and reworking the filter menu to use buttons instead of toggles. Moves section filtering and selection logic into dedicated view properties. Updates HomeViewModel to improve entity filtering, section building, and state management, and removes unnecessary calls to save and rebuild sections after configuration changes.
Introduces a debounced save mechanism using a cancellable Task to prevent frequent database writes when saving the Home view configuration. Removes the rebuildSections method and ensures sections are rebuilt after saving. This improves performance and reliability when updating configuration state.
Added guards in appEntities and registryEntities didSet observers to avoid calling buildSectionsFromEntityStates when the lists are empty. This prevents unnecessary processing and potential errors when entity arrays are empty.
Changed RoomSection to store entityIds instead of HAEntity objects and updated grouping, sorting, and filtering logic to operate on entity IDs. Updated HomeView, RoomView, and EntityTileView to use the new structure and improved tile rendering. This refactor streamlines entity management and prepares for more efficient state updates.
Replaces immediate section building with a debounced async approach to avoid redundant executions. Caches area and entity-to-area mapping, optimizes entity filtering and grouping, and improves error handling. This enhances performance and responsiveness when entity or registry data changes.
Moved entity filtering logic from HomeViewModel to HomeView for improved clarity and separation of concerns. Replaced debounced async section building with direct area observation and synchronous room section construction, simplifying state management and improving UI responsiveness.
Refactored visibleEntitiesForSection to use lookup dictionaries and sets for faster filtering of entities, reducing repeated O(n) searches. Improved sorting logic to use custom order if available, falling back to alphabetical order, and streamlined the filtering process for clarity and efficiency.
RoomView now receives a RoomSection and HomeViewModel instead of server, roomId, and roomName. Entity filtering and sorting logic has been moved into computed properties, improving performance and code clarity. HomeView updated to pass RoomSection to RoomView, aligning with the new data model.
Standardized variable names in conditional bindings within HomeView.swift for improved clarity and consistency. No functional changes were made.
Swapped ModernAssistBackgroundView for Color.secondaryBackground in HomeView to update the background styling.
Moved the light mode toggle buttons into the control bar and refactored their appearance for better UI consistency. Updated background views in HomeView and RoomView to use Color.secondaryBackground instead of ModernAssistBackgroundView. Improved section rendering logic in HomeView to avoid empty sections.
Refactored VerticalToggleControl to use a taller, rectangular thumb with updated icon sizing and padding, and removed the glass effect from the track. Added a new toggle button to SwitchControlsView for direct switch toggling, improving accessibility and user interaction.
Moved the reorder button and divider to the top of the filter menu. Updated section filter button to show a label with a checkmark or circle only when multiple selection is allowed or the section is visible; otherwise, display just the section name.
|
Merging as a debug feature, control will not be available in prod yet. |
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 introduces an experimental native dashboard feature that provides a native Swift UI alternative to the WebView-based interface. The implementation includes support for lights, covers, switches, and fans with interactive controls, entity management, and room-based organization.
Key changes:
- Database schema extensions for tracking entity visibility/disabled states and home view configuration
- Refactored API request methods with clearer naming (
configAreasRegistry,configEntityRegistryList, etc.) - New native views for home dashboard, rooms, and entity controls with domain-specific implementations
- iOS 26.0+ requirement for the experimental feature with Control Widget integration
Reviewed changes
Copilot reviewed 62 out of 63 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
Sources/Shared/HAAreasRegistryResponse.swift |
Renamed response types and added hiddenBy/disabledBy tracking for entities |
Sources/Shared/HATypedRequest+App.swift |
Renamed API request methods for better clarity |
Sources/Shared/AreasService.swift |
Added entity property synchronization and refactored type names |
Sources/Shared/HAAppEntity.swift |
Added filtering capabilities and hidden/disabled state tracking |
Sources/Shared/Environment/HomeViewConfigurationTable.swift |
New database table for storing user's dashboard configuration |
Sources/App/WebView/ExperimentalSpace/* |
Complete native dashboard implementation with views, view models, and controls |
Tests/App/Area/AreasService.test.swift |
Updated tests for new entity registry parameters |
| Localization files | Added strings for new UI elements |
| Dependency files | Updated HAKit from 0.4.8 to 0.4.9 |
Basic implementation of a native dashboard - WIP