-
Notifications
You must be signed in to change notification settings - Fork 34
feat(tank-presets): hide individual built-in tank presets from the pickers #2315
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
Merged
ericgriffin
merged 5 commits into
submersion-app:main
from
alpheios-one:github-issue-2305-hide-tank-presets
Sep 25, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f6cf1e6
feat(tank-presets): hide individual built-in tank presets from the pi…
alpheios-one 115d764
fix(tank-presets): address review on hidden tank presets
alpheios-one 0e3d95b
fix(tank-presets): address second review on hidden tank presets
alpheios-one 351ad83
fix(weight-planner): keep the tank presets while hiding one reloads them
alpheios-one a391f97
test(weight-planner): const UnitFormatter in the rig composer reload …
alpheios-one File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
65 changes: 65 additions & 0 deletions
65
lib/features/tank_presets/domain/services/tank_preset_visibility.dart
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import 'package:submersion/core/constants/tank_presets.dart'; | ||
| import 'package:submersion/features/tank_presets/domain/entities/tank_preset_entity.dart'; | ||
|
|
||
| // Which tank presets the diver's pickers offer (issue #2305). | ||
| // | ||
| // A diver can hide built-in presets they never use. Hiding only narrows the | ||
| // pickers: import matching and default resolution keep reading the full | ||
| // catalog, and the Tank Presets settings page keeps listing everything so a | ||
| // hidden preset can be shown again. | ||
|
|
||
| /// [all] without the built-in presets named in [hidden]. | ||
| /// | ||
| /// Custom presets are never hidden, even when one shares a built-in slug. | ||
| /// The [defaultPresetName] always stays, so a default that ended up in the | ||
| /// hidden set (the settings page never allows that, but a synced row could | ||
| /// carry it) is still offered where it is applied. | ||
| List<TankPresetEntity> visibleTankPresets( | ||
| List<TankPresetEntity> all, | ||
| Set<String> hidden, { | ||
| String? defaultPresetName, | ||
| }) { | ||
| if (hidden.isEmpty) return all; | ||
| return [ | ||
| for (final preset in all) | ||
| if (!preset.isBuiltIn || | ||
| preset.name == defaultPresetName || | ||
| !hidden.contains(preset.name)) | ||
| preset, | ||
| ]; | ||
| } | ||
|
|
||
| /// [visible] plus any hidden built-in preset named in [keep], so a picker | ||
| /// whose current value is a hidden preset still shows that value. | ||
| /// | ||
| /// Restored presets go back to their catalog position among the built-in | ||
| /// ones, custom presets stay first, and every preset already in [visible] | ||
| /// keeps its instance. Returns [visible] itself when nothing is missing. | ||
| List<TankPresetEntity> withKeptTankPresets( | ||
| List<TankPresetEntity> visible, | ||
| Iterable<String?> keep, | ||
| ) { | ||
| final present = {for (final preset in visible) preset.name}; | ||
| final missing = { | ||
| for (final name in keep) | ||
| if (name != null && | ||
| !present.contains(name) && | ||
| TankPresets.byName(name) != null) | ||
| name, | ||
| }; | ||
| if (missing.isEmpty) return visible; | ||
|
|
||
| final builtInByName = { | ||
| for (final preset in visible) | ||
| if (preset.isBuiltIn) preset.name: preset, | ||
| }; | ||
| return [ | ||
| for (final preset in visible) | ||
| if (!preset.isBuiltIn) preset, | ||
| for (final builtIn in TankPresets.all) | ||
| if (builtInByName[builtIn.name] case final existing?) | ||
| existing | ||
| else if (missing.contains(builtIn.name)) | ||
| TankPresetEntity.fromBuiltIn(builtIn), | ||
| ]; | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.