Feature/dive detail section config#97
Merged
Merged
Conversation
Define the 17 configurable section IDs, their display metadata, and JSON serialization for database storage. Includes ensureAllSections for forward-compatible new-section detection.
Nullable TEXT column stores JSON section config. Null means use defaults. No data backfill needed for existing divers.
New field with copyWith support and clear-to-defaults flag. SettingsNotifier gets set and reset methods for the section config.
JSON serialization via DiveDetailSectionConfig.sectionsFromJson/toJson. Stores null when config matches defaults to avoid unnecessary writes.
ReorderableListView with visibility toggle switches per section. Reset to Default in overflow menu. Dimmed styling for hidden sections.
Navigation tile in Appearance links to /settings/dive-detail-sections. New GoRoute wires the DiveDetailSectionsPage into the router.
Replace hardcoded section order with a registry map and loop over the user's diveDetailSections config. Fixed sections (header, profile) remain at the top. All data-driven auto-hide conditions preserved.
The previous code used List == (reference equality) to detect defaults and write null. This always evaluates to false for loaded lists, breaking the reset-to-defaults flow. Simplify by always writing JSON.
The settings page uses a separate _AppearanceSectionContent widget for the master-detail layout on desktop. The new section was only added to the mobile AppearancePage, not the desktop inline version.
Add 17 new tests (32 -> 49 total) covering: - Model: fromJson missing visible field, fromJson unknown ID throws, copyWith no-args, round-trip serialization, ensureAllSections with empty list and custom visibility preservation - Widget: toggle switch updates visibility, hidden section has reduced opacity, reset-to-default menu, initial switch state, app bar title, section descriptions - AppSettings: copyWith preserves when unset, defaults match static const, clearDiveDetailSections takes precedence
Add 20 more tests (49 -> 69 total) covering: - Model: fromJson explicit false, single-item round-trip, tryFromJson success/missing-id/non-string-id, sectionsFromJson with map-JSON/ non-map-list-items/all-unknown-IDs/mixed-types, ensureAllSections preserves custom visibility, every displayName/description value, unique displayName constraint - Widget: toggle back on restores opacity, multiple independent toggles, overflow menu present, subheading text, custom initial section order via provider override - AppSettings: sequential copyWith independence, empty list, custom constructor
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds user-configurable ordering and visibility for Dive Detail page sections, persisting per-diver preferences to the database and wiring them through settings/state so the Dive Detail UI renders from configuration rather than a hardcoded order.
Changes:
- Introduces
DiveDetailSectionId/DiveDetailSectionConfig(JSON serialization + default/forward-compatible parsing). - Persists section configuration in
diver_settingsvia a new nullabledive_detail_sectionsTEXT column and schema bump to v56. - Adds a new settings UI page for drag-and-drop reordering + visibility toggles, and updates Dive Detail rendering to be config-driven.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/core/constants/dive_detail_sections.dart | Defines section IDs, display metadata, config model, and JSON serialization/parsing helpers. |
| lib/core/database/database.dart | Adds dive_detail_sections column and migrates schema version to 56. |
| lib/core/router/app_router.dart | Registers the new settings route for configuring dive detail sections. |
| lib/features/settings/data/repositories/diver_settings_repository.dart | Saves/loads section config JSON to/from diver_settings. |
| lib/features/settings/presentation/providers/settings_providers.dart | Extends AppSettings + SettingsNotifier to hold and persist section config. |
| lib/features/settings/presentation/pages/dive_detail_sections_page.dart | New UI for reordering and toggling section visibility + reset-to-default. |
| lib/features/settings/presentation/pages/appearance_page.dart | Adds navigation entry to the new dive detail sections configuration page. |
| lib/features/settings/presentation/pages/settings_page.dart | Adds navigation entry (desktop/mobile settings layout) to the new configuration page. |
| lib/features/dive_log/presentation/pages/dive_detail_page.dart | Replaces hardcoded section order with config-driven rendering via a section builder registry. |
| test/core/constants/dive_detail_sections_test.dart | Adds unit tests for section config defaults and serialization/deserialization behavior. |
| test/features/settings/presentation/pages/dive_detail_sections_page_test.dart | Adds widget tests for reorder/toggle/reset behaviors and UI rendering. |
| test/features/settings/presentation/providers/settings_providers_test.dart | Adds tests for AppSettings defaults and copyWith behavior for section config. |
| test/features/settings/presentation/pages/settings_page_test.dart | Updates settings page test notifier mock for new settings APIs. |
| test/features/statistics/presentation/pages/records_page_test.dart | Updates notifier mock for new settings APIs. |
Add localizedDisplayName() and localizedDescription() to DiveDetailSectionId backed by ARB strings for all supported locales. Update settings and appearance pages to use localized section metadata. Add DiveDetailPage widget tests verifying section config visibility, ordering, and content rendering.
Add widget tests for dataSources, buddies, sightings, signatures, details, and all-sections-together rendering. Extract _buildTestWidget extraOverrides parameter and _alwaysRenderOverrides helper for sections that require additional provider stubs.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
… coverage Add widget tests for AppearancePage verifying the Dive Details section header, tile content, and reorder icon. Extend section config tests with dataSources, buddies, sightings, signatures, details, and all-sections rendering using extraOverrides for provider-dependent sections.
PR #95 (duration->bottomTime rename) claimed migration v56. Bump the dive_detail_sections column addition to v57 and update schemaVersion.
- Bump migration from v56 to v57 (PR #95 claimed v56 for the duration->bottom_time column rename) - Regenerate Drift code against updated schema - Add missing setDiveDetailSections/resetDiveDetailSections stubs to MockSettingsNotifier
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.
Summary
Add user-configurable ordering and visibility for dive detail page sections. Divers can reorder and hide/show sections via a new drag-and-drop settings page, with preferences persisted to the database.
Changes
DiveDetailSectionIdenum andDiveDetailSectionConfigmodel with JSON serialization and forward-compatible section detectiondiveDetailSectionsnullable TEXT column todiver_settingstable (migration v56)AppSettings,SettingsNotifier, andDiverSettingsRepositoryDiveDetailSectionsPagewithReorderableListView, visibility toggle switches, and reset-to-defaultDiveDetailPagewith config-driven rendering via a registry mapTest Plan
flutter testpassesflutter analyzepassesScreenshots