feat(dive_profile_chart): add used gas#275
Open
readme42 wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Member
|
@readme42 great idea! |
Contributor
Author
c8d38f7 to
8bd7238
Compare
…thTank Adds isOxygen (o2 >= 99%, no helium) as a first-class gas type alongside air, nitrox, and trimix. GasMix.name returns 'O2', GasType gains an oxygen variant, and GasColors.oxygen (blue) is the matching display color. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit adds the used gas information to the dive profile chart. The used gas is calculated based on the gas consumption during the dive and is displayed as a separate line on the chart. This allows divers to easily track their gas usage throughout the dive and make informed decisions about their remaining gas supply. The implementation includes updates to the data processing logic and the chart rendering to accommodate the new information.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a gas-usage timeline strip to the dive profile chart so users can visually correlate gas changes with the profile timeline, including a legend toggle and localized label support.
Changes:
- Introduces
GasTimelineStripand plumbing inDiveProfileChartto render a colored gas bar (with cursor-line extensions). - Adds
GasUsageSegment+buildGasUsageSegments()to derive timeline segments from tanks and gas switches, and wires it through detail/panel views. - Extends gas classification/coloring to include pure O₂ and updates localizations + test coverage.
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/features/dive_log/presentation/widgets/gas_timeline_strip_test.dart | New widget tests for rendering, color mapping, and visible-window clipping of the gas strip. |
| test/features/dive_log/presentation/widgets/gas_colors_test.dart | Expands tests to cover the new oxygen color and distinctness rules. |
| test/features/dive_log/presentation/widgets/dive_profile_legend_test.dart | Verifies legend badge/tune UI behavior when gas overlay data is available. |
| test/features/dive_log/presentation/widgets/dive_profile_chart_test.dart | Integration tests ensuring the chart renders the gas strip under the right conditions. |
| test/features/dive_log/presentation/providers/profile_legend_provider_test.dart | Adds tests for the new showGas toggle state and notifier behavior. |
| test/features/dive_log/presentation/providers/gas_switch_providers_test.dart | New tests for GasType classification including oxygen. |
| test/features/dive_log/presentation/pages/dive_detail_page_test.dart | Adds wiring tests to ensure detail page/profile panel doesn’t crash when gas data varies. |
| test/features/dive_log/domain/entities/gas_mix_test.dart | Adds tests for oxygen naming and isOxygen behavior. |
| test/features/dive_log/data/services/gas_usage_segments_service_test.dart | New unit tests for gas segment construction and normalization/merging. |
| lib/l10n/arb/app_zh.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_pt.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_nl.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_localizations.dart | Adds the new localization getter for the gas toggle label. |
| lib/l10n/arb/app_localizations_zh.dart | Generated localization implementation update for Chinese. |
| lib/l10n/arb/app_localizations_pt.dart | Generated localization implementation update for Portuguese. |
| lib/l10n/arb/app_localizations_nl.dart | Generated localization implementation update for Dutch. |
| lib/l10n/arb/app_localizations_it.dart | Generated localization implementation update for Italian. |
| lib/l10n/arb/app_localizations_hu.dart | Generated localization implementation update for Hungarian. |
| lib/l10n/arb/app_localizations_he.dart | Generated localization implementation update for Hebrew. |
| lib/l10n/arb/app_localizations_fr.dart | Generated localization implementation update for French. |
| lib/l10n/arb/app_localizations_es.dart | Generated localization implementation update for Spanish. |
| lib/l10n/arb/app_localizations_en.dart | Generated localization implementation update for English. |
| lib/l10n/arb/app_localizations_de.dart | Generated localization implementation update for German. |
| lib/l10n/arb/app_localizations_ar.dart | Generated localization implementation update for Arabic. |
| lib/l10n/arb/app_it.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_hu.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_he.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_fr.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_es.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_en.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_de.arb | Adds localized label for the “show gas” toggle. |
| lib/l10n/arb/app_ar.arb | Adds localized label for the “show gas” toggle. |
| lib/features/dive_log/presentation/widgets/gas_timeline_strip.dart | New widget that renders the proportional gas blocks with tooltips and optional zoom window. |
| lib/features/dive_log/presentation/widgets/gas_colors.dart | Adds oxygen color and updates gas-mix color selection precedence. |
| lib/features/dive_log/presentation/widgets/dive_profile_panel.dart | Wires computed gas segments + duration into the chart in the embedded profile panel. |
| lib/features/dive_log/presentation/widgets/dive_profile_legend.dart | Adds config flag and UI toggle for gas strip visibility in the options dialog. |
| lib/features/dive_log/presentation/widgets/dive_profile_chart.dart | Adds strip layout reservation, overlay rendering, cursor extensions, and legend wiring. |
| lib/features/dive_log/presentation/providers/profile_legend_provider.dart | Adds showGas state and a notifier toggle method. |
| lib/features/dive_log/presentation/providers/gas_switch_providers.dart | Extends GasType enum/classification to include oxygen. |
| lib/features/dive_log/presentation/pages/dive_detail_page.dart | Wires gas segments + duration into the profile chart for detail and fullscreen views. |
| lib/features/dive_log/domain/entities/gas_switch.dart | Adds isOxygen classification for gas switches. |
| lib/features/dive_log/domain/entities/dive.dart | Adds GasMix.isOxygen and updates naming to emit O2 for pure oxygen. |
| lib/features/dive_log/data/services/gas_usage_segments_service.dart | New service constructing gas usage segments from tanks/switches for timeline visualization. |
Comment on lines
+120
to
+123
| // 240/3000 * 400 = 32px — too narrow to show label | ||
| expect(find.text('Air'), findsNothing); | ||
| // EAN50 block is 3040/3000 * 400 = wide → label shown | ||
| expect(find.text('EAN50'), findsOneWidget); |
Comment on lines
+865
to
+867
| /// Replaces the single-color decoration stripe with three stacked bars in | ||
| /// the air → nitrox → trimix colors so the indicator visually advertises | ||
| /// every gas type the strip can render, not just one. |
Comment on lines
+2091
to
+2098
| left: 16 + DiveProfileChart.leftAxisSize(availableWidth), | ||
| right: | ||
| (effectiveRightAxisMetric != null && rightAxisRange != null | ||
| ? 16 | ||
| : 0) + | ||
| DiveProfileChart.rightAxisSize(availableWidth), | ||
| bottom: 14 + 22, | ||
| height: DiveProfileChart.gasTimelineHeight, |
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
Adds a bar visualizing the used gas into the dive chart. With this, its super easy to recognize which gas was changed when. Uses the same colors as the gases got assigned already.
This was obviously inspired by how subsurface renders it.
@ericgriffin
The PR is not finalized yet - I opened it to show the idea and get some feedback. If you like it, I would make it hideable by checkbox, fix some layout things, etc ...
edit: finalized.
Changes
Test Plan
flutter testpassesflutter analyzepassesScreenshots