Skip to content

feat(tank-presets): hide individual built-in tank presets from the pickers - #2315

Open
alpheios-one wants to merge 5 commits into
submersion-app:mainfrom
alpheios-one:github-issue-2305-hide-tank-presets
Open

alpheios-one wants to merge 5 commits into
submersion-app:mainfrom
alpheios-one:github-issue-2305-hide-tank-presets

Conversation

@alpheios-one

@alpheios-one alpheios-one commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Related Issue

Closes #2305

Summary

Divers can now hide built-in tank presets they never use. On Settings > Tank Presets each built-in preset gets a switch; a hidden preset no longer appears in any tank picker, but stays listed (dimmed) on the settings page so it can be shown again. The selection is stored per diver and syncs.

Changes

  • Setting: new per-diver hiddenTankPresetIds, stored as a JSON list in diver_settings.hidden_tank_preset_ids. Schema v227 (225 is held by feat(import): keep the tissue loading the dive computer recorded (#1977) #1978, 226 is the media cloud asset id): additive nullable column with a beforeOpen backstop; the sync compatibility floor stays at 224, since an older reader simply shows every built-in preset.
  • Filtering: tankPresetsProvider leaves hidden built-in presets out, so the tank editor, cylinder configurations, weight planner, transmitters and the blender cylinder menu all follow. tankPresetListNotifierProvider, which backs the settings page, stays unfiltered. The provider selects the effectively hidden set by content, so a settings reload or starring a visible preset does not re-query it.
  • Custom presets never get a switch and are never hidden, even when one shares a built-in slug.
  • Default preset: the starred default has no switch and is always offered, even if a synced row lists it as hidden. Starring a hidden preset makes it the default and shows it again. Changing the default also drops a stale hidden entry for the outgoing default, so it does not vanish the moment it stops being the default. Deleting a custom default still falls back to AL80, as the delete dialog says, and shows AL80 again if it was hidden.
  • Existing records: a tank, transmitter or weight-planner tank that already uses a hidden preset keeps showing it in its own dropdown (withKeptTankPresets), without offering it elsewhere. The tank editor and transmitter dropdowns no longer flash a progress bar when the list reloads.
  • Unchanged: import matching (TankPresets.byName, matchBySpecs) and the default preset for imports still read the full catalog.
  • New strings in all 11 ARB files.

How to Test

  1. Settings > Tank Presets: every built-in preset except the starred default has a switch; custom presets have none.
  2. Switch off e.g. HP80: its row is dimmed but stays listed.
  3. HP80 is gone from the tank picker in the dive editor, from transmitters, from the weight planner and from the blender's cylinder menu.
  4. Open a dive that already uses HP80: its tank still shows HP80.
  5. Tap the star on a hidden preset: it becomes the default, is shown again, and its switch disappears.

Test Plan

  • flutter analyze passes
  • New and affected tests pass: visibility helpers, settings persistence (including malformed JSON), notifier rules, provider filtering (including a synced row that hides the default), settings page switches, tank editor keeping a hidden preset, migration v227
  • Manual testing on: Windows

…ckers

Each built-in preset on the Tank Presets page gets a switch that hides it
from every tank picker (tank editor, cylinder configurations, weight
planner, transmitters, blender). The settings page keeps listing all of
them, dimmed when hidden, so a preset can be shown again.

- New per-diver setting hiddenTankPresetIds, stored as a JSON list in
  diver_settings.hidden_tank_preset_ids (schema v227, additive column with
  a beforeOpen backstop; the sync floor stays).
- tankPresetsProvider filters hidden built-in presets; custom presets are
  never hidden, and the default preset always stays offered.
- The default preset has no switch and cannot be hidden. Starring a hidden
  preset makes it the default and shows it again.
- A tank, transmitter or weight-planner rig that already uses a hidden
  preset keeps showing it in its dropdown.
- Import matching and default resolution still read the full catalog.

Closes submersion-app#2305
- Weight planner: keep a hidden preset only in the dropdown of the tank
  that uses it, instead of offering it to every tank in the rig.
- tankPresetsProvider selects the hidden set by content, so a reload that
  decodes an equal set does not re-run it.
- setDefaultTankPreset only rewrites the hidden set when the new default
  was actually hidden.
- A hidden preset's tile is dimmed rather than disabled, since its star and
  switch stay usable (and are announced as such).
- Drop the unreachable null branch of the switch's onChanged.

Refs submersion-app#2305
- setDefaultTankPreset also drops a stale hidden entry for the outgoing
  default, so a synced row that hid the default cannot make it vanish the
  moment the diver picks another default.
- tankPresetsProvider selects the effectively hidden set (hidden minus the
  default) in one content-compared key, so starring a visible preset does
  not re-query the presets.
- The tank editor and transmitter preset dropdowns keep their current
  value on reload instead of flashing a progress bar.
- Test doubles guard the default preset like the real notifier.

Refs submersion-app#2305
@alpheios-one
alpheios-one force-pushed the github-issue-2305-hide-tank-presets branch from aae3ed3 to 0e3d95b Compare September 24, 2026 05:20
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build artifacts for this PR · commit a391f97

Platform Download
Android (APK) android-apk
macOS macos-build
Windows windows-build
Linux linux-build

Artifacts expire in 7 days. Downloading requires being signed in to GitHub. macOS needs two extractions: unzip the downloaded artifact, then unzip the submersion-macos.zip inside it to get a runnable submersion.app. The build is ad-hoc signed — right-click → Open on first launch.

Updated automatically on each push.

@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.96907% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/core/database/database.dart 91.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved same-slug preset identity issues and a weight-planner reload state issue affect expected behavior.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds per-diver hiding of built-in tank presets, including persistence, migration, picker filtering, settings UI, localization, and retained existing selections.

Changes:

  • Adds hidden_tank_preset_ids with schema migration v227.
  • Filters hidden built-ins across tank-related pickers while preserving current selections.
  • Adds settings controls, translations, and comprehensive tests.
File Summary
test/​helpers/​mock_providers.dart Updates settings test providers.
test/​features/​tank_presets/​presentation/​providers/​tank_preset_providers_test.dart Tests filtering and default behavior.
test/​features/​tank_presets/​presentation/​pages/​tank_presets_page_test.dart Tests visibility controls and defaults.
test/​features/​tank_presets/​domain/​services/​tank_preset_visibility_test.dart Tests visibility and retained selections.
test/​features/​statistics/​presentation/​pages/​records_page_test.dart Updates settings test setup.
test/​features/​settings/​presentation/​providers/​settings_notifier_real_test.dart Tests hidden-preset state changes.
test/​features/​settings/​presentation/​pages/​settings_page_test.dart Updates settings page tests.
test/​features/​settings/​presentation/​pages/​settings_page_shared_data_test.dart Updates shared settings test data.
test/​features/​settings/​data/​repositories/​diver_settings_repository_hidden_tank_presets_test.dart Tests persistence and malformed JSON handling.
test/​features/​dive_log/​presentation/​widgets/​tank_editor_test.dart Tests retaining hidden current presets.
test/​core/​database/​migration_v227_hidden_tank_presets_test.dart Tests migration v227.
test/​core/​database/​migration_v226_media_cloud_asset_id_test.dart Adjusts migration v226 expectations.
lib/​l10n/​arb/​app_zh.arb Adds Chinese translations.
lib/​l10n/​arb/​app_pt.arb Adds Portuguese translations.
lib/​l10n/​arb/​app_nl.arb Adds Dutch translations.
lib/​l10n/​arb/​app_localizations.dart Updates localization accessors.
lib/​l10n/​arb/​app_localizations_zh.dart Adds generated Chinese localization data.
lib/​l10n/​arb/​app_localizations_pt.dart Adds generated Portuguese localization data.
lib/​l10n/​arb/​app_localizations_nl.dart Adds generated Dutch localization data.
lib/​l10n/​arb/​app_localizations_it.dart Adds generated Italian localization data.
lib/​l10n/​arb/​app_localizations_hu.dart Adds generated Hungarian localization data.
lib/​l10n/​arb/​app_localizations_he.dart Adds generated Hebrew localization data.
lib/​l10n/​arb/​app_localizations_fr.dart Adds generated French localization data.
lib/​l10n/​arb/​app_localizations_es.dart Adds generated Spanish localization data.
lib/​l10n/​arb/​app_localizations_en.dart Adds generated English localization data.
lib/​l10n/​arb/​app_localizations_de.dart Adds generated German localization data.
lib/​l10n/​arb/​app_localizations_ar.dart Adds generated Arabic localization data.
lib/​l10n/​arb/​app_it.arb Adds Italian translations.
lib/​l10n/​arb/​app_hu.arb Adds Hungarian translations.
lib/​l10n/​arb/​app_he.arb Adds Hebrew translations.
lib/​l10n/​arb/​app_fr.arb Adds French translations.
lib/​l10n/​arb/​app_es.arb Adds Spanish translations.
lib/​l10n/​arb/​app_en.arb Adds English source strings.
lib/​l10n/​arb/​app_de.arb Adds German translations.
lib/​l10n/​arb/​app_ar.arb Adds Arabic translations.
lib/​features/​weight_planner/​presentation/​widgets/​rig_composer.dart Applies filtering; reloads can temporarily empty the list.
lib/​features/​transmitters/​presentation/​pages/​transmitter_edit_page.dart Retains hidden selected presets.
lib/​features/​tank_presets/​presentation/​providers/​tank_preset_providers.dart Filters picker results; same-slug custom/default identity needs distinction.
lib/​features/​tank_presets/​presentation/​pages/​tank_presets_page.dart Adds switches and dimmed rows; same-slug defaults can suppress a built-in switch.
lib/​features/​tank_presets/​domain/​services/​tank_preset_visibility.dart Implements filtering; name-only matching can lose hidden built-in selections.
lib/​features/​settings/​presentation/​providers/​settings_providers.dart Adds hidden-preset state; same-slug custom presets can be misidentified as built-in defaults.
lib/​features/​settings/​data/​repositories/​diver_settings_repository.dart Persists hidden preset IDs.
lib/​features/​dive_log/​presentation/​widgets/​tank_editor.dart Retains hidden selected presets.
lib/​core/​database/​database.dart Adds the v227 hidden-preset column and migration backstop.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/features/weight_planner/presentation/widgets/rig_composer.dart Outdated
tankPresetsProvider watches the hidden-preset setting, so hiding or showing
a preset reloads it through a dependency. valueOrNull drops the previous
list during that reload, which briefly disabled Add tank and emptied the
rig's tank dropdowns; value keeps it until the filtered list lands.

Refs submersion-app#2305
@ericgriffin

Copy link
Copy Markdown
Member

@alpheios-one would you mind posting screenshots of the visual/UI changes (it makes reviewing much easier)? Thanks!

@ericgriffin ericgriffin added enhancement New feature or request user interface labels Sep 25, 2026
@alpheios-one

alpheios-one commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Sure, here are the screenshots (Windows build).

1. Settings > Tank Presets
Each built-in preset now has a switch. A hidden preset (HP80 here) stays in the list, dimmed, so it can be shown again. The starred default preset (AL80) has no switch, and neither do custom presets.

image

2. Tank preset picker in the dive editor
The hidden preset no longer appears in the picker. The same applies to transmitters, the weight planner, the blender and cylinder configurations.

image

@alpheios-one

Copy link
Copy Markdown
Contributor Author

@ericgriffin The screenshots are in the comment above. Thanks for the hint. I will think about how to present my changes better in the future so the review is more efficient, for example with screenshots directly in the PR description.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request user interface

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Allow hiding individual built-in tank presets

3 participants