377ff04aaf
Replace the single glass pill (host NavigationBar/CupertinoTabBar with one gliding highlight) with a row of separate circular GlassPill buttons, 52/50 px with 12/10 px gaps, at the same bottom-right place. The selected button fills with the host selection tint and cross-fades; each button pops in on its own, staggered, only when the bar appears or its tabs change; presses sink like the top bar's. Tab semantics, keys, tooltips and badges are kept; the row shares one BackdropGroup for its blurs.
156 lines
5.4 KiB
Dart
156 lines
5.4 KiB
Dart
import 'dart:ui' show SemanticsRole;
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
|
|
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
|
|
/// Every bottom tab bar shows icons only, yet each tab keeps its name for
|
|
/// assistive technology (and a Material tooltip), its selected state and its
|
|
/// test key; the icons within a bar, and against the shell's tabs a detail's
|
|
/// bar floats above, are distinct.
|
|
void main() {
|
|
Widget host(bool cupertino, Widget bar) {
|
|
final body = Align(alignment: Alignment.bottomCenter, child: bar);
|
|
return cupertino
|
|
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
|
: MaterialApp(home: Scaffold(body: body));
|
|
}
|
|
|
|
final bars = <String, (Widget, List<(String, String)>)>{
|
|
'run detail': (
|
|
RunDetailTabStrip(selected: RunDetailTab.summary, onSelected: (_) {}),
|
|
[
|
|
for (final tab in renderedRunDetailTabs)
|
|
('run-detail-tab-${tab.name}', tab.label),
|
|
],
|
|
),
|
|
'stage page': (
|
|
RunVisitSectionStrip(
|
|
selected: RunVisitSection.summary,
|
|
onSelected: (_) {},
|
|
),
|
|
[
|
|
for (final section in shownVisitSections)
|
|
('run-visit-tab-${section.name}', section.label),
|
|
],
|
|
),
|
|
'pipeline detail': (
|
|
PipelineDetailTabs(
|
|
selected: PipelineDetailTab.summary,
|
|
onSelected: (_) {},
|
|
),
|
|
[
|
|
for (final tab in PipelineDetailTab.values)
|
|
('pipeline-detail-tab-${tab.name}', tab.label),
|
|
],
|
|
),
|
|
};
|
|
|
|
for (final cupertino in [false, true]) {
|
|
final name = cupertino ? 'Cupertino' : 'Material';
|
|
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
|
|
testWidgets('$name $label tabs are icons named for assistive '
|
|
'technology', (tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(host(cupertino, bar));
|
|
await tester.pumpAndSettle();
|
|
|
|
final floating = find.byType(FloatingDestinationBar);
|
|
// No label is drawn at all.
|
|
expect(
|
|
find.descendant(of: floating, matching: find.byType(Text)),
|
|
findsNothing,
|
|
);
|
|
for (final (index, (key, tabLabel)) in tabs.indexed) {
|
|
final finder = find.byKey(ValueKey(key));
|
|
final node = tester.getSemantics(finder);
|
|
expect(node.label, startsWith(tabLabel), reason: key);
|
|
expect(
|
|
node,
|
|
isSemantics(
|
|
isSelected: index == 0,
|
|
hasSelectedState: true,
|
|
isButton: true,
|
|
hasTapAction: true,
|
|
),
|
|
reason: key,
|
|
);
|
|
expect(node.role, SemanticsRole.tab, reason: key);
|
|
// "Tab n of m", as the host navigation controls announce it: in the
|
|
// Material label, the Cupertino hint.
|
|
final position = 'Tab ${index + 1} of ${tabs.length}';
|
|
expect(
|
|
cupertino ? node.hint : node.label,
|
|
contains(position),
|
|
reason: key,
|
|
);
|
|
// Material names the tab in its tooltip too.
|
|
if (!cupertino) {
|
|
expect(
|
|
find.descendant(
|
|
of: finder,
|
|
matching: find.byWidgetPredicate(
|
|
(widget) => widget is Tooltip && widget.message == tabLabel,
|
|
),
|
|
),
|
|
findsOneWidget,
|
|
reason: key,
|
|
);
|
|
}
|
|
// A hit target at least the platform minimum.
|
|
expect(
|
|
tester.getSize(finder).shortestSide,
|
|
greaterThanOrEqualTo(cupertino ? 44 : 48),
|
|
);
|
|
}
|
|
// The tabs make up one tab bar.
|
|
final tabBar = tester.getSemantics(
|
|
find.byKey(FloatingDestinationBar.rowKey),
|
|
);
|
|
expect(tabBar.role, SemanticsRole.tabBar);
|
|
// Distinct glyphs within the bar.
|
|
final icons = tester
|
|
.widgetList<Icon>(
|
|
find.descendant(of: floating, matching: find.byType(Icon)),
|
|
)
|
|
.map((icon) => icon.icon)
|
|
.toSet();
|
|
expect(icons.length, greaterThanOrEqualTo(tabs.length));
|
|
semantics.dispose();
|
|
});
|
|
}
|
|
}
|
|
|
|
test('detail tab icons differ from the shell tabs they float above', () {
|
|
final shell = {
|
|
for (final destination in shellTabDestinations) ...[
|
|
destinationDetails(destination).icon,
|
|
destinationDetails(destination).cupertinoIcon,
|
|
],
|
|
};
|
|
final details = [
|
|
for (final tab in renderedRunDetailTabs) ...[tab.icon, tab.cupertinoIcon],
|
|
for (final section in shownVisitSections) ...[
|
|
section.icon,
|
|
section.cupertinoIcon,
|
|
],
|
|
for (final tab in PipelineDetailTab.values) ...[
|
|
tab.icon,
|
|
tab.cupertinoIcon,
|
|
],
|
|
];
|
|
for (final icon in details) {
|
|
expect(shell.contains(icon), isFalse, reason: '$icon');
|
|
}
|
|
});
|
|
}
|