Remove shared backdrop from main tab labels

This commit is contained in:
2026-11-07 22:01:40 +00:00
parent 6e4e11aca2
commit cd034db77a
4 changed files with 58 additions and 46 deletions
@@ -208,7 +208,6 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
selected: currentIndex, selected: currentIndex,
buttonBuilder: (index) => _button(context, index), buttonBuilder: (index) => _button(context, index),
onTap: widget.onTap, onTap: widget.onTap,
backdrop: _backdrop,
); );
} }
final gap = _gap(width); final gap = _gap(width);
@@ -12,23 +12,18 @@ class FloatingDestinationLabels extends StatelessWidget {
required this.selected, required this.selected,
required this.buttonBuilder, required this.buttonBuilder,
required this.onTap, required this.onTap,
required this.backdrop,
}); });
final bool cupertino; final bool cupertino;
final List<String> labels; final List<String> labels;
final int selected; final int selected;
final Widget Function(int) buttonBuilder; final Widget Function(int) buttonBuilder;
final ValueChanged<int> onTap; final ValueChanged<int> onTap;
final BackdropKey backdrop;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final color = cupertino final color = cupertino
? CupertinoColors.label.resolveFrom(context) ? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface; : Theme.of(context).colorScheme.onSurface;
final surface = cupertino
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainer;
final style = cupertino final style = cupertino
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle ? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
: Theme.of(context).textTheme.labelSmall!; : Theme.of(context).textTheme.labelSmall!;
@@ -36,49 +31,40 @@ class FloatingDestinationLabels extends StatelessWidget {
role: SemanticsRole.tabBar, role: SemanticsRole.tabBar,
container: true, container: true,
explicitChildNodes: true, explicitChildNodes: true,
child: DecoratedBox( child: Padding(
decoration: BoxDecoration( padding: const EdgeInsets.all(8),
color: surface, child: Wrap(
borderRadius: BorderRadius.circular(16), alignment: WrapAlignment.center,
), crossAxisAlignment: WrapCrossAlignment.center,
child: Padding( spacing: 8,
padding: const EdgeInsets.all(8), runSpacing: 8,
child: BackdropGroup( children: [
backdropKey: backdrop, for (var index = 0; index < labels.length; index++)
child: Wrap( GestureDetector(
alignment: WrapAlignment.center, key: ValueKey('destination-label-${labels[index]}'),
crossAxisAlignment: WrapCrossAlignment.center, excludeFromSemantics: true,
spacing: 8, onTap: () => onTap(index),
runSpacing: 8, child: TextFieldTapRegion(
children: [ child: Column(
for (var index = 0; index < labels.length; index++) mainAxisSize: MainAxisSize.min,
GestureDetector( children: [
key: ValueKey('destination-label-${labels[index]}'), buttonBuilder(index),
excludeFromSemantics: true, ExcludeSemantics(
onTap: () => onTap(index), child: Text(
child: TextFieldTapRegion( labels[index],
child: Column( style: style.copyWith(
mainAxisSize: MainAxisSize.min, color: color,
children: [ fontWeight: index == selected
buttonBuilder(index), ? FontWeight.w600
ExcludeSemantics( : style.fontWeight,
child: Text(
labels[index],
style: style.copyWith(
color: color,
fontWeight: index == selected
? FontWeight.w600
: style.fontWeight,
),
),
), ),
], ),
), ),
), ],
), ),
], ),
), ),
), ],
), ),
), ),
); );
+8
View File
@@ -0,0 +1,8 @@
# Main tab captions without a shared backdrop
Removed the shared rounded surface and backdrop group behind the main
navigation captions. The labels retain their content-driven padding, wrapping,
hit targets, text scaling, safe-area clearance, and existing per-tab selected
button decoration. Focused coverage checks phone and wide layouts on Material
and Cupertino hosts. Browser captures also covered 560px/1200px Material layouts
in light and dark themes; the four PNGs were inspected during review.
+19
View File
@@ -5,6 +5,7 @@ import 'package:pipelines_app/shell/list_detail_policy.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart'; import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart'; import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_labels.dart';
/// Main navigation keeps visible captions and full-size targets, floating at /// Main navigation keeps visible captions and full-size targets, floating at
/// the trailing edge on a phone and centered under the list on a wide window. /// the trailing edge on a phone and centered under the list on a wide window.
@@ -39,6 +40,22 @@ void main() {
expect(bounds.width - contentBounds!.width, inInclusiveRange(0, 32)); expect(bounds.width - contentBounds!.width, inInclusiveRange(0, 32));
} }
Future<void> expectNoSharedBackdrop(WidgetTester tester) async {
expect(
find.descendant(
of: find.byType(FloatingDestinationLabels),
matching: find.byWidgetPredicate(
(widget) =>
widget is DecoratedBox &&
widget.decoration is BoxDecoration &&
(widget.decoration as BoxDecoration).borderRadius ==
BorderRadius.circular(16),
),
),
findsNothing,
);
}
Future<void> setSize(WidgetTester tester, Size size) async { Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size; tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1; tester.view.devicePixelRatio = 1;
@@ -80,6 +97,7 @@ void main() {
await tester.pumpWidget(shell(cupertino: cupertino)); await tester.pumpWidget(shell(cupertino: cupertino));
final rect = tester.getRect(pill()); final rect = tester.getRect(pill());
await expectLabeledTargets(tester, rect); await expectLabeledTargets(tester, rect);
await expectNoSharedBackdrop(tester);
expect(rect.width, lessThanOrEqualTo(390 - 2 * 16)); expect(rect.width, lessThanOrEqualTo(390 - 2 * 16));
expect(rect.right, 390 - 16); expect(rect.right, 390 - 16);
expect(rect.bottom, 844 - 16); expect(rect.bottom, 844 - 16);
@@ -111,6 +129,7 @@ void main() {
expect(rect.width, lessThan(1200 * 0.6)); expect(rect.width, lessThan(1200 * 0.6));
// Captions participate in the bar's content-driven width. // Captions participate in the bar's content-driven width.
await expectLabeledTargets(tester, rect); await expectLabeledTargets(tester, rect);
await expectNoSharedBackdrop(tester);
expect( expect(
rect.width, rect.width,
lessThanOrEqualTo(listDetailListWidth(1200, 1200, null) - 2 * 16), lessThanOrEqualTo(listDetailListWidth(1200, 1200, null) - 2 * 16),