fix(dive-edit): stop segmented-button labels wrapping mid-word on phones - #798
Conversation
Two SegmentedButtons in the dive editor overflowed their labels on narrow screens, wrapping mid-word: - Dive Mode (OC/CCR/SCR/GAUGE): each segment showed an icon *and* a label, which doesn't fit four segments on a phone. Drop the icons (text-only); the caption below and the tooltip already say what each mode is. - Weighting feedback (Felt right / Overweighted / Underweighted): the long single-word labels are wider than a third of the row. Wrap the labels in FittedBox(scaleDown) with maxLines: 1 so they scale to fit on one line instead of char-wrapping. Adds a dive-mode-selector widget test (labels present, single line, no per-segment icons); the existing weighting-feedback test still passes.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
📦 Build artifacts for this PR · commit
Artifacts expire in 7 days. Downloading requires being signed in to GitHub. macOS needs two extractions: unzip the downloaded artifact, then unzip the Updated automatically on each push. |
There was a problem hiding this comment.
Pull request overview
Improves the dive editor’s segmented-button layout on small screens by preventing mid-word wrapping in segment labels (notably “GAUGE”, “Overweighted”, “Underweighted”).
Changes:
- Removed per-segment icons from the Dive Mode
SegmentedButtonto reduce horizontal pressure on phones. - Wrapped Dive Mode and Weighting Feedback segment labels in
FittedBox(fit: BoxFit.scaleDown)+Text(maxLines: 1)to keep labels on a single line. - Added a new widget test covering the Dive Mode selector’s text-only segments and single-line label behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/features/dive_log/presentation/widgets/dive_mode_selector.dart | Removes icons and scales label text down to avoid mid-word wrapping in Dive Mode segments. |
| lib/features/dive_log/presentation/pages/dive_edit_page.dart | Scales Weighting Feedback segment labels down to prevent mid-word wrapping on phones. |
| test/features/dive_log/presentation/widgets/dive_mode_selector_test.dart | Adds a regression test for text-only Dive Mode segments and single-line label rendering. |
Copilot review: finding no Icon descendants under SegmentedButton is brittle because the framework renders internal icons (e.g. the selected checkmark) that this widget does not control. Assert directly that every ButtonSegment's icon field is null instead.
Problem
On a phone, two
SegmentedButtons in the dive editor overflow their labels and wrap mid-word:Fix
dive_mode_selector.dart+dive_edit_page.dart:FittedBox(fit: BoxFit.scaleDown)withmaxLines: 1, so a label that is slightly too wide scales down to fit on one line rather than char-wrapping.Tests
dive_mode_selector_test.dart: the four labels render, the longest stays single-line inside aFittedBox, and the segments no longer carry icons.dive_edit_weight_feedback_test.dart(taps the labels) still passes.Verified locally against Flutter 3.44.8 / Dart 3.12.2:
flutter test test/features/dive_log/presentation/pages/(+ the new widget test) passes,flutter analyzeclean,dart formatclean.