Skip to content

feat(dive_profile_chart): add used gas#275

Open
readme42 wants to merge 2 commits into
submersion-app:mainfrom
readme42:gas-bar
Open

feat(dive_profile_chart): add used gas#275
readme42 wants to merge 2 commits into
submersion-app:mainfrom
readme42:gas-bar

Conversation

@readme42
Copy link
Copy Markdown
Contributor

@readme42 readme42 commented May 1, 2026

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 test passes
  • flutter analyze passes
  • Manual testing on: Windows

Screenshots

gas1

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

@ericgriffin
Copy link
Copy Markdown
Member

@readme42 great idea!

@readme42
Copy link
Copy Markdown
Contributor Author

readme42 commented May 3, 2026

Added a new checkbox in the settings menu called "Gases" to show/hide the gases in the graph.
The colored decoration represents the colors of the 4 gas types

gasbar1

Works in overview
gasbar2

And in fullscreen view
gasbar3

Also added a 4th gas type oxygen, which was labled as EAN100 before.

gasbar4

Tests are still missing, but I have to wait 4 hours for new tokens to arive ;)

@readme42 readme42 force-pushed the gas-bar branch 4 times, most recently from c8d38f7 to 8bd7238 Compare May 4, 2026 14:12
…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.
@readme42 readme42 marked this pull request as ready for review May 4, 2026 22:01
@readme42 readme42 requested a review from ericgriffin as a code owner May 4, 2026 22:01
@ericgriffin ericgriffin requested a review from Copilot May 12, 2026 04:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 GasTimelineStrip and plumbing in DiveProfileChart to 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,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants