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,
buttonBuilder: (index) => _button(context, index),
onTap: widget.onTap,
backdrop: _backdrop,
);
}
final gap = _gap(width);
@@ -12,23 +12,18 @@ class FloatingDestinationLabels extends StatelessWidget {
required this.selected,
required this.buttonBuilder,
required this.onTap,
required this.backdrop,
});
final bool cupertino;
final List<String> labels;
final int selected;
final Widget Function(int) buttonBuilder;
final ValueChanged<int> onTap;
final BackdropKey backdrop;
@override
Widget build(BuildContext context) {
final color = cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface;
final surface = cupertino
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainer;
final style = cupertino
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
: Theme.of(context).textTheme.labelSmall!;
@@ -36,49 +31,40 @@ class FloatingDestinationLabels extends StatelessWidget {
role: SemanticsRole.tabBar,
container: true,
explicitChildNodes: true,
child: DecoratedBox(
decoration: BoxDecoration(
color: surface,
borderRadius: BorderRadius.circular(16),
),
child: Padding(
padding: const EdgeInsets.all(8),
child: BackdropGroup(
backdropKey: backdrop,
child: Wrap(
alignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 8,
runSpacing: 8,
children: [
for (var index = 0; index < labels.length; index++)
GestureDetector(
key: ValueKey('destination-label-${labels[index]}'),
excludeFromSemantics: true,
onTap: () => onTap(index),
child: TextFieldTapRegion(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
buttonBuilder(index),
ExcludeSemantics(
child: Text(
labels[index],
style: style.copyWith(
color: color,
fontWeight: index == selected
? FontWeight.w600
: style.fontWeight,
),
),
child: Padding(
padding: const EdgeInsets.all(8),
child: Wrap(
alignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 8,
runSpacing: 8,
children: [
for (var index = 0; index < labels.length; index++)
GestureDetector(
key: ValueKey('destination-label-${labels[index]}'),
excludeFromSemantics: true,
onTap: () => onTap(index),
child: TextFieldTapRegion(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
buttonBuilder(index),
ExcludeSemantics(
child: Text(
labels[index],
style: style.copyWith(
color: color,
fontWeight: index == selected
? FontWeight.w600
: style.fontWeight,
),
],
),
),
),
],
),
],
),
),
),
),
],
),
),
);