Merge commit 'b556e76778001e36621b3cadfd38b06b9cf2b476' into pipelines/run-20261111-2114-finish-remaining-material-only-probe-hos-0220

This commit is contained in:
2026-11-11 21:38:41 +00:00
31 changed files with 581 additions and 635 deletions
@@ -108,7 +108,10 @@ class GraphStageNode extends StatelessWidget {
// coloured, smaller text in the status's own hue.
final color = status == null
? null
: runStatusColor(graphStatusState(status)).resolveFrom(context);
: runStatusColor(
graphStatusState(status),
Theme.of(context).colorScheme,
);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -238,7 +238,10 @@ class PipelineListPanel extends StatelessWidget {
? null
: AppListStatusDot(
key: Key('pipeline-status-${pipeline.id}'),
color: runStatusColor(badge.state).resolveFrom(context),
color: runStatusColor(
badge.state,
Theme.of(context).colorScheme,
),
semanticLabel: runStateLabel(badge.state),
),
subtitle: Text(
@@ -280,10 +283,7 @@ class PipelineListPanel extends StatelessWidget {
/// The pipeline's initial on a tint picked from its id, so neighbouring
/// pipelines are told apart at a glance.
Widget _pipelineIdentityIcon(
BuildContext context,
PipelineSummary pipeline,
) {
Widget _pipelineIdentityIcon(BuildContext context, PipelineSummary pipeline) {
final scheme = Theme.of(context).colorScheme;
final colors = [scheme.primary, scheme.secondary, scheme.tertiary];
return Semantics(
@@ -1,4 +1,4 @@
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/layout/app_list_avatar.dart';
@@ -116,7 +116,7 @@ class RunTimelineRow extends StatelessWidget {
context,
visit.outcome,
)
: runStatusColor(_state).resolveFrom(context);
: runStatusColor(_state, Theme.of(context).colorScheme);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
@@ -145,7 +145,7 @@ class RunTimelineRow extends StatelessWidget {
divider: divider,
onTap: onTap,
leading: AppListAvatar(
foreground: runStatusColor(state).resolveFrom(context),
foreground: runStatusColor(state, Theme.of(context).colorScheme),
child: RunStatusIcon(
state: state,
label: visit.status.isEmpty ? 'Status unavailable' : visit.status,
@@ -94,7 +94,7 @@ class _FactGrid extends StatelessWidget {
}
Widget _pill(BuildContext context, VisitFact fact) {
final color = runStatusColor(_stateOf(fact)).resolveFrom(context);
final color = runStatusColor(_stateOf(fact), Theme.of(context).colorScheme);
return DecoratedBox(
decoration: ShapeDecoration(
color: color.withValues(alpha: 0.16),
+1 -1
View File
@@ -126,7 +126,7 @@ class RunListRow extends StatelessWidget {
onLongPress: selecting ? null : onLongPress,
selectionControl: selecting ? _checkbox(context) : null,
leading: AppListAvatar(
foreground: runStatusColor(state).resolveFrom(context),
foreground: runStatusColor(state, Theme.of(context).colorScheme),
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
),
title: Text(title),
+3 -2
View File
@@ -59,7 +59,7 @@ class RunPathMini extends StatelessWidget {
width: 14,
height: 10,
decoration: BoxDecoration(
color: runStatusColor(stage.state).resolveFrom(context),
color: runStatusColor(stage.state, Theme.of(context).colorScheme),
borderRadius: BorderRadius.circular(3),
),
);
@@ -83,7 +83,8 @@ class RunPathMini extends StatelessWidget {
shape: BoxShape.circle,
color: runStatusColor(
end == '#success' ? 'succeeded' : 'failed',
).resolveFrom(context),
Theme.of(context).colorScheme,
),
),
),
],
@@ -14,9 +14,9 @@ import 'runs_controller.dart';
/// Opens the runs' usage and charts on their own page.
Future<void> openRunsStats(BuildContext context, RunsController controller) {
final page = RunsStatsPage(controller: controller);
return Navigator.of(context).push<void>(
MaterialPageRoute<void>(builder: (_) => page),
);
return Navigator.of(
context,
).push<void>(MaterialPageRoute<void>(builder: (_) => page));
}
/// Usage totals, runs by status (a pie) and runs per day for the last week.
@@ -92,7 +92,10 @@ class RunsStatsPage extends StatelessWidget {
painter: _PiePainter([
for (final entry in byState.entries)
(
runStatusColor(entry.key).resolveFrom(context),
runStatusColor(
entry.key,
Theme.of(context).colorScheme,
),
entry.value,
),
]),
@@ -1,5 +1,4 @@
import 'dart:ui' show SemanticsRole;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Content-driven main navigation captions keep names visible without scaling
@@ -21,12 +20,8 @@ class FloatingDestinationLabels extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface;
final style = cupertino
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
: Theme.of(context).textTheme.labelSmall!;
final color = Theme.of(context).colorScheme.onSurface;
final style = Theme.of(context).textTheme.labelSmall!;
return Semantics(
role: SemanticsRole.tabBar,
container: true,
+19 -50
View File
@@ -1,6 +1,5 @@
import 'dart:ui' show SemanticsRole;
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
@@ -73,40 +72,24 @@ class FloatingTabButton extends StatelessWidget {
role: SemanticsRole.tab,
selected: selected,
button: true,
label: cupertino || kIsWeb ? label : '$label\n${_tabLabel(context)}',
hint: cupertino ? _tabLabel(context) : null,
label: kIsWeb ? label : '$label\n${_tabLabel(context)}',
// Switching tabs does not unfocus a text field (the composer).
child: TextFieldTapRegion(
child: cupertino
? button
: Tooltip(
message: label,
excludeFromSemantics: true,
child: button,
),
child: Tooltip(
message: label,
excludeFromSemantics: true,
child: button,
),
),
),
);
}
String _tabLabel(BuildContext context) => cupertino
? CupertinoLocalizations.of(
context,
).tabSemanticsLabel(tabIndex: index + 1, tabCount: count)
: MaterialLocalizations.of(
context,
).tabLabel(tabIndex: index + 1, tabCount: count);
String _tabLabel(BuildContext context) => MaterialLocalizations.of(
context,
).tabLabel(tabIndex: index + 1, tabCount: count);
({Color tint, Color selectedIcon, Color icon}) _colors(BuildContext context) {
if (cupertino) {
final active = CupertinoTheme.of(context).primaryColor;
return (
tint: active.withValues(alpha: cupertinoTintOpacity),
selectedIcon: active,
// Secondary-label translucency over glass falls below contrast.
icon: CupertinoColors.label.resolveFrom(context),
);
}
final scheme = Theme.of(context).colorScheme;
return (
tint: scheme.secondaryContainer,
@@ -125,30 +108,16 @@ class FloatingTabButton extends StatelessWidget {
color: colors.tint.withValues(alpha: colors.tint.a * t),
shape: const CircleBorder(),
);
final Widget fill = cupertino
? DecoratedBox(
key: fillKey,
decoration: decoration,
child: MouseRegion(
cursor: kIsWeb ? SystemMouseCursors.click : MouseCursor.defer,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onTap,
),
),
)
// Painted on the glass's Material, under the ink, so the ripple
// shows over the selected tint too.
: Ink(
key: fillKey,
decoration: decoration,
child: InkResponse(
onTap: onTap,
customBorder: const CircleBorder(),
containedInkWell: true,
highlightShape: BoxShape.circle,
),
);
final Widget fill = Ink(
key: fillKey,
decoration: decoration,
child: InkResponse(
onTap: onTap,
customBorder: const CircleBorder(),
containedInkWell: true,
highlightShape: BoxShape.circle,
),
);
Widget glyph = IconTheme.merge(
data: IconThemeData(
size: iconSize,
+4 -6
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'glass_pill.dart';
@@ -20,11 +19,10 @@ abstract final class GlassBarMetrics {
static const double fieldEdgeGap = 4;
/// The square target of one control: the platform's minimum touch target.
static double controlExtent(bool cupertino) =>
cupertino ? kMinInteractiveDimensionCupertino : kMinInteractiveDimension;
static double controlExtent(bool cupertino) => kMinInteractiveDimension;
/// The icon drawn inside a control's target.
static double iconSize(bool cupertino) => cupertino ? 30 : 28;
static double iconSize(bool cupertino) => 28;
/// The space between a control's icon and the edge of its target.
static double iconInset(bool cupertino) =>
@@ -44,8 +42,8 @@ abstract final class GlassBarMetrics {
minHeight: controlExtent(false),
);
/// The Cupertino minimum size of one control.
static Size cupertinoMinimumSize() => Size.square(controlExtent(true));
/// Compatibility helper for callers still passing the old control family.
static Size cupertinoMinimumSize() => Size.square(controlExtent(false));
}
/// A [GlassPill] padded by [GlassBarMetrics.edgeGap] on every side around
+4 -14
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'glass_surface.dart';
@@ -68,16 +67,9 @@ class GlassPill extends StatelessWidget {
final textDirection = Directionality.maybeOf(context);
final Color base;
final Color edge;
if (cupertino) {
// Grey 5 stays visibly raised over both the black dark canvas and the
// white light canvas; Grey 6 disappears into either one when blurred.
base = CupertinoColors.systemGrey5.resolveFrom(context);
edge = CupertinoColors.separator.resolveFrom(context);
} else {
final scheme = Theme.of(context).colorScheme;
base = scheme.surfaceContainerHigh;
edge = scheme.outlineVariant;
}
final scheme = Theme.of(context).colorScheme;
base = scheme.surfaceContainerHigh;
edge = scheme.outlineVariant;
final opaque = fill ?? (solid ? base : base.withValues(alpha: fillOpacity));
final color = opaque.withValues(alpha: opaque.a * reveal);
final look = GlassLook.forFill(opaque);
@@ -86,9 +78,7 @@ class GlassPill extends StatelessWidget {
final border = shape.copyWith(
side: BorderSide(color: faded(edge, solid ? 1 : 0.6), width: 0.5),
);
Widget content = cupertino
? child
: Material(type: MaterialType.transparency, child: child);
Widget content = Material(type: MaterialType.transparency, child: child);
if (!solid) {
// The highlight lies on the fill under the content; the rim is drawn
// over the content (and its ink) so the edge stays clean.
+4 -16
View File
@@ -1,8 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'host.dart';
/// A native-themed affordance for a draggable pane divider.
class AdaptiveResizeGrip extends StatelessWidget {
const AdaptiveResizeGrip({
@@ -18,31 +15,22 @@ class AdaptiveResizeGrip extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
return RotatedBox(
quarterTurns: axis == Axis.vertical ? 1 : 0,
child: DecoratedBox(
decoration: BoxDecoration(
color: cupertino
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainerHigh,
color: Theme.of(context).colorScheme.surfaceContainerHigh,
borderRadius: BorderRadius.circular(8),
border: emphasized
? Border.all(
color: cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary,
)
? Border.all(color: Theme.of(context).colorScheme.primary)
: null,
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: compact ? 6 : 8),
child: Icon(
cupertino ? CupertinoIcons.minus : Icons.drag_handle,
Icons.drag_handle,
size: compact ? 12 : 18,
color: cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';
@@ -104,9 +103,7 @@ class _SegmentedPressState extends State<SegmentedPress>
Color _tint(BuildContext context) {
if (widget.tint case final tint?) return tint;
return widget.cupertino
? CupertinoColors.label.resolveFrom(context)
: Theme.of(context).colorScheme.onSurface;
return Theme.of(context).colorScheme.onSurface;
}
@override
@@ -1,5 +1,4 @@
import 'app_menu_anchor.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// The key of a [SegmentedBar]'s More button, shown when its actions do not
@@ -85,20 +84,6 @@ class SegmentedMoreButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (cupertino) {
return Semantics(
button: true,
label: label,
excludeSemantics: true,
child: CupertinoButton(
key: segmentedMoreKey,
padding: EdgeInsets.zero,
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
onPressed: () => _showSheet(context),
child: const Icon(CupertinoIcons.ellipsis),
),
);
}
return AppMenuAnchor(
menuChildren: [
for (final entry in entries)
@@ -137,46 +122,4 @@ class SegmentedMoreButton extends StatelessWidget {
),
);
}
Future<void> _showSheet(BuildContext context) async {
final picked = await _sheet<SegmentedOverflowEntry>(context, [
for (final entry in entries)
if (entry.onPressed != null || entry.choices.isNotEmpty)
(entry.label, false, entry),
]);
if (picked == null || !context.mounted) return;
if (picked.choices.isEmpty) {
picked.onPressed?.call();
return;
}
final choice = await _sheet<SegmentedMenuChoice>(context, [
for (final choice in picked.choices)
(choice.label, choice.selected, choice),
], title: picked.label);
choice?.onSelected();
}
Future<T?> _sheet<T>(
BuildContext context,
List<(String, bool, T)> items, {
String? title,
}) => showCupertinoModalPopup<T>(
context: context,
builder: (sheet) => CupertinoActionSheet(
title: title == null ? null : Text(title),
actions: [
for (final (label, selected, value) in items)
CupertinoActionSheetAction(
// The current choice is the sheet's default (bold) action.
isDefaultAction: selected,
onPressed: () => Navigator.of(sheet).pop(value),
child: Semantics(selected: selected, child: Text(label)),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.of(sheet).pop(),
child: const Text('Cancel'),
),
),
);
}
+4 -42
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'glass_pill.dart';
@@ -6,8 +5,7 @@ import 'segmented_bar_motion.dart';
/// The smallest height of every piece of a [SegmentedBar]: the platform's
/// minimum touch target, so a round Back is a circle.
double segmentedPieceHeight(bool cupertino) =>
cupertino ? kMinInteractiveDimensionCupertino : kMinInteractiveDimension;
double segmentedPieceHeight(bool cupertino) => kMinInteractiveDimension;
/// One rounded piece of a segmented bar: a [GlassPill] at least the
/// platform's touch-target size.
@@ -42,8 +40,7 @@ class SegmentedPill extends StatelessWidget {
}
}
/// The platform's own Back for a segmented bar: Material [BackButton],
/// Cupertino [CupertinoNavigationBarBackButton]. A null [onPressed] keeps the
/// The app's Material Back button for a segmented bar. A null [onPressed] keeps the
/// stock action (pop the route).
class SegmentedBackButton extends StatelessWidget {
const SegmentedBackButton({
@@ -56,9 +53,7 @@ class SegmentedBackButton extends StatelessWidget {
final VoidCallback? onPressed;
@override
Widget build(BuildContext context) => cupertino
? CupertinoNavigationBarBackButton(onPressed: onPressed)
: BackButton(onPressed: onPressed);
Widget build(BuildContext context) => BackButton(onPressed: onPressed);
}
/// What a bar implies on the leading edge when the page gave none, matching
@@ -68,17 +63,6 @@ Widget? impliedSegmentedLeading(BuildContext context, bool cupertino) {
final route = ModalRoute.of(context);
if (route == null) return null;
final dialog = route is PageRoute && route.fullscreenDialog;
if (cupertino) {
if (!route.canPop) return null;
if (dialog) {
return CupertinoButton(
padding: const EdgeInsets.symmetric(horizontal: 16),
onPressed: () => route.navigator?.maybePop(),
child: Text(CupertinoLocalizations.of(context).cancelButtonLabel),
);
}
return const SegmentedBackButton(cupertino: true);
}
if (!route.impliesAppBarDismissal) return null;
return dialog ? const CloseButton() : const BackButton();
}
@@ -89,17 +73,6 @@ Widget? impliedSegmentedLeading(BuildContext context, bool cupertino) {
required bool cupertino,
Color? foreground,
}) {
if (cupertino) {
final text = CupertinoTheme.of(context).textTheme;
return (
text.textStyle.copyWith(fontWeight: FontWeight.w600, color: foreground),
text.textStyle.copyWith(
fontSize: 13,
color:
foreground ?? CupertinoColors.secondaryLabel.resolveFrom(context),
),
);
}
final theme = Theme.of(context);
return (
(theme.textTheme.titleSmall ?? const TextStyle()).copyWith(
@@ -277,18 +250,7 @@ class SegmentedTitlePill extends StatelessWidget {
body = Semantics(
button: true,
label: semanticLabel,
child: cupertino
? CupertinoButton(
key: buttonKey,
padding: EdgeInsets.zero,
minimumSize: Size.zero,
onPressed: onPressed,
child: DefaultTextStyle.merge(
style: titleStyle,
child: content,
),
)
: InkWell(key: buttonKey, onTap: onPressed, child: content),
child: InkWell(key: buttonKey, onTap: onPressed, child: content),
);
}
final titleAction = this.titleAction;
+4 -2
View File
@@ -11,7 +11,7 @@ class BarIconButton extends StatelessWidget {
const BarIconButton({
super.key,
required this.icon,
required this.cupertinoIcon,
this.cupertinoIcon,
required this.label,
required this.onPressed,
this.selected = false,
@@ -21,7 +21,9 @@ class BarIconButton extends StatelessWidget {
});
final IconData icon;
final IconData cupertinoIcon;
/// Retained for source compatibility; Material rendering always uses [icon].
final IconData? cupertinoIcon;
/// The tooltip and accessible name.
final String label;
+13 -11
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// The shared status glyph whose tooltip and accessible name say the state.
@@ -21,7 +20,7 @@ class RunStatusIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = runStatusColor(state).resolveFrom(context);
final color = runStatusColor(state, Theme.of(context).colorScheme);
return Tooltip(
message: label,
child: Semantics(
@@ -35,14 +34,17 @@ class RunStatusIcon extends StatelessWidget {
}
/// The dynamic colour for a run state, shared by every status glyph.
CupertinoDynamicColor runStatusColor(String state) => switch (state) {
'succeeded' => CupertinoColors.systemGreen,
'failed' => CupertinoColors.systemRed,
'running' || 'active' => CupertinoColors.systemBlue,
'waiting' => CupertinoColors.systemYellow,
'interrupted' => CupertinoColors.systemOrange,
_ => CupertinoColors.systemGrey,
};
Color runStatusColor(String state, [ColorScheme? colorScheme]) {
final scheme = colorScheme ?? const ColorScheme.light();
return switch (state) {
'succeeded' => scheme.tertiary,
'failed' => scheme.error,
'running' || 'active' => scheme.primary,
'waiting' => scheme.secondary,
'interrupted' => scheme.tertiary,
_ => scheme.onSurfaceVariant,
};
}
IconData _materialIcon(String state) => switch (state) {
'succeeded' => Icons.check_circle_outline,
@@ -65,7 +67,7 @@ class RunStatusKicker extends StatelessWidget {
@override
Widget build(BuildContext context) {
final color = runStatusColor(state).resolveFrom(context);
final color = runStatusColor(state, Theme.of(context).colorScheme);
return Row(
key: const Key('run-status-kicker'),
mainAxisSize: MainAxisSize.min,
+13
View File
@@ -0,0 +1,13 @@
# Populated desktop review fixtures
The full-app fake gateway's `chats=2&header=1` scenario now supplies model and
permission-mode catalogs as well as thinking levels. Selections are validated
and retained per chat, without contacting providers or changing real settings.
This closes the earlier selector review's unsupported-catalog limitation.
- Fixture tests: 2 passed; explicit tool-file analysis: clean.
- Full-app web probe build: passed.
- Inspected populated model, permission, and thinking menus at 1600×1000, dark
theme. All use the shared anchored Material choice surface and checked rows.
- Final broad desktop review still follows integrated cleanup; these captures
are focused fixture verification, not a claim of completed overall review.
@@ -0,0 +1,21 @@
# Material cleanup: shared UI primitives
- Removed live Cupertino rendering from glass pills, resize grips, segmented
overflow, segmented press feedback, segmented pieces, floating tab buttons,
and destination labels. Existing `cupertino` compatibility arguments remain
where other lanes still pass them, but they no longer select a renderer.
- Replaced run status dynamic colors with `ColorScheme` roles and updated every
production caller. The status helper keeps an optional scheme for pure tests.
- Focused verification: `tool/memwatch/full.sh` over the seven named Material
and status/graph tests: 47 passed, 0 failed, peak 1555 MB.
- Removed obsolete Cupertino variants from the run-path and segmented-bar
mirrored tests; Material color-scheme roles and Material host/localizations
are now the only assertions in those fixtures. Focused rerun: 14 passed,
0 failed.
- `tool/analyze.sh`: clean, 0 errors/warnings/infos.
- Removed the obsolete CupertinoApp variants from
`floating_tab_motion_test.dart`; the Material motion coverage now runs under
`MaterialApp` only. Focused rerun of the floating-tab, segmented-bar, and
run-path tests: 16 passed, 0 failed.
- No browser capture was performed; these changes preserve existing Material
geometry and interaction paths rather than redesigning visuals.
@@ -1,4 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/graph/domain/run_graph_state.dart';
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
@@ -26,8 +26,9 @@ void main() {
expect(graphStatusState('running · 2m'), 'running');
expect(graphStatusState('waiting'), 'waiting');
expect(graphStatusState('mystery'), 'unknown');
expect(runStatusColor('succeeded'), CupertinoColors.systemGreen);
expect(runStatusColor('waiting'), CupertinoColors.systemYellow);
expect(runStatusColor('canceled'), CupertinoColors.systemGrey);
const scheme = ColorScheme.light();
expect(runStatusColor('succeeded', scheme), scheme.tertiary);
expect(runStatusColor('waiting', scheme), scheme.secondary);
expect(runStatusColor('canceled', scheme), scheme.onSurfaceVariant);
});
}
@@ -42,14 +42,10 @@ void main() {
.whereType<Color>()
.map((color) => color.toARGB32())
.toList();
final context = tester.element(find.byKey(const Key('run-path-mini')));
expect(
colors,
contains(runStatusColor('succeeded').resolveFrom(context).toARGB32()),
);
expect(
colors,
contains(runStatusColor('failed').resolveFrom(context).toARGB32()),
);
final scheme = Theme.of(
tester.element(find.byKey(const Key('run-path-mini'))),
).colorScheme;
expect(colors, contains(runStatusColor('succeeded', scheme).toARGB32()));
expect(colors, contains(runStatusColor('failed', scheme).toARGB32()));
});
}
+61
View File
@@ -0,0 +1,61 @@
import 'package:flutter_test/flutter_test.dart';
import '../../tool/perf/chat_catalog_fixture.dart';
void main() {
test('catalogs are populated and selection is isolated per chat', () {
final fixture = ChatCatalogFixture();
expect(
fixture.reply({'type': 'chat_models'})!['chat_models'],
hasLength(2),
);
expect(fixture.reply({'type': 'chat_modes'})!['chat_modes'], hasLength(3));
expect(
fixture.reply({
'type': 'chat_model',
'chat_model': {
'session_id': 'a',
'provider': 'openai',
'model': 'openai/gpt-5.6-luna',
},
})!['type'],
'chat_model',
);
expect(
fixture.reply({
'type': 'chat_mode',
'chat_mode': {'session_id': 'a', 'mode': 'plan'},
})!['type'],
'chat_mode',
);
expect(fixture.rowFields('a')['model'], 'openai/gpt-5.6-luna');
expect(fixture.rowFields('a')['mode_name'], 'Plan only');
expect(fixture.rowFields('b')['model'], 'openai/gpt-6.1');
expect(fixture.rowFields('b')['mode'], 'default');
});
test('invalid selections do not mutate catalog state', () {
final fixture = ChatCatalogFixture();
final before = fixture.rowFields('a');
expect(
fixture.reply({
'type': 'chat_mode',
'chat_mode': {'session_id': 'a', 'mode': 'not-a-mode'},
})!['type'],
'error',
);
expect(
fixture.reply({
'type': 'chat_model',
'chat_model': {
'session_id': 'a',
'provider': 'unknown',
'model': 'unknown',
},
})!['type'],
'error',
);
expect(fixture.rowFields('a'), before);
expect(fixture.reply({'type': 'chat_messages'}), isNull);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
@@ -54,11 +53,7 @@ void main() {
),
child: child,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body)),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
await tester.pumpAndSettle();
}
@@ -80,18 +75,17 @@ void main() {
(name: 'phone 560, 5 tabs', size: const Size(560, 844), count: 5),
];
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
{
const cupertino = false;
const host = 'Material';
final diameter = FloatingDestinationBar.buttonSize(cupertino: cupertino);
final gap = FloatingDestinationBar.buttonGap(cupertino: cupertino);
final iconSize = cupertino
? FloatingDestinationBar.cupertinoIconSize
: FloatingDestinationBar.materialIconSize;
final iconSize = FloatingDestinationBar.materialIconSize;
test('$host: buttons are larger than the old 44/42 circle, hit targets '
'meet the platform minimum', () {
expect(diameter, cupertino ? 50 : 52);
expect(diameter, greaterThanOrEqualTo(cupertino ? 44 : 48));
expect(diameter, 52);
expect(diameter, greaterThanOrEqualTo(48));
expect(gap, inInclusiveRange(10, 12));
});
+189 -204
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
@@ -39,25 +38,18 @@ void main() {
addTearDown(tester.view.reset);
}
Widget app(bool cupertino, Widget body) => cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body));
Widget app(Widget body) => MaterialApp(home: Scaffold(body: body));
/// A bar of [count] tabs whose tap selects.
Future<void> pumpBar(
WidgetTester tester, {
required bool cupertino,
int count = 3,
}) async {
Future<void> pumpBar(WidgetTester tester, {int count = 3}) async {
var selected = 0;
await tester.pumpWidget(
app(
cupertino,
StatefulBuilder(
builder: (context, setState) => Align(
alignment: Alignment.bottomCenter,
child: FloatingDestinationBar(
cupertino: cupertino,
cupertino: false,
currentIndex: selected,
onTap: (index) => setState(() => selected = index),
items: items(count),
@@ -102,205 +94,198 @@ void main() {
return (decoration! as ShapeDecoration).color!.a;
}
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
final size = FloatingDestinationBar.buttonSize(cupertino: cupertino);
final iconSize = cupertino
? FloatingDestinationBar.cupertinoIconSize
: FloatingDestinationBar.materialIconSize;
final host = 'Material';
final size = FloatingDestinationBar.buttonSize(cupertino: false);
final iconSize = FloatingDestinationBar.materialIconSize;
testWidgets('$host: each button pops in on its own, staggered, from '
'0.6 to full size', (tester) async {
animate(tester, on: true);
await pumpBar(tester, cupertino: cupertino);
for (var index = 0; index < 3; index += 1) {
final tab = find.byKey(tabKey(index));
expect(opacityOf(tester, tab), 0);
final rest = index == 0
? FloatingDestinationBar.selectedButtonSize(cupertino: cupertino)
: size;
expect(widthOf(tester, tab), moreOrLessEquals(rest * 0.6));
}
await tester.pump(const Duration(milliseconds: 130));
final first = widthOf(tester, find.byKey(tabKey(0)));
final last = widthOf(tester, find.byKey(tabKey(2)));
expect(first, greaterThan(last + 4), reason: 'staggered');
expect(opacityOf(tester, find.byKey(tabKey(0))), greaterThan(0.9));
expect(opacityOf(tester, find.byKey(tabKey(2))), lessThan(0.2));
await tester.pumpAndSettle();
for (var index = 0; index < 3; index += 1) {
final tab = find.byKey(tabKey(index));
expect(opacityOf(tester, tab), 1);
// Tab 0 is selected, so it settles at the larger size.
expect(
widthOf(tester, tab),
index == 0
? FloatingDestinationBar.selectedButtonSize(cupertino: cupertino)
: size,
);
}
});
testWidgets('$host: the entrance does not replay when the selection '
'changes', (tester) async {
animate(tester, on: true);
await pumpBar(tester, cupertino: cupertino);
await tester.pumpAndSettle();
for (final target in [1, 2, 0]) {
await tester.tap(find.byKey(tabKey(target)));
for (var frame = 0; frame < 12; frame += 1) {
await tester.pump(const Duration(milliseconds: 25));
for (var index = 0; index < 3; index += 1) {
final tab = find.byKey(tabKey(index));
expect(opacityOf(tester, tab), 1, reason: 'tab $index faded');
// The selection grows and shrinks buttons between their two
// sizes and the press sinks the tapped one a little; a replayed
// pop would start at 0.6.
expect(
widthOf(tester, tab),
greaterThan(size * 0.9),
reason: 'tab $index popped again',
);
}
}
await tester.pumpAndSettle();
}
});
testWidgets('$host: a new set of tabs pops in again', (tester) async {
animate(tester, on: true);
var count = 3;
late StateSetter update;
await tester.pumpWidget(
app(
cupertino,
StatefulBuilder(
builder: (context, setState) {
update = setState;
return Align(
alignment: Alignment.bottomCenter,
child: FloatingDestinationBar(
cupertino: cupertino,
currentIndex: 0,
onTap: (_) {},
items: items(count),
),
);
},
),
),
);
await tester.pumpAndSettle();
expect(opacityOf(tester, find.byKey(tabKey(2))), 1);
update(() => count = 4);
await tester.pump();
expect(opacityOf(tester, find.byKey(tabKey(3))), 0);
expect(opacityOf(tester, find.byKey(tabKey(2))), 0);
await tester.pumpAndSettle();
expect(opacityOf(tester, find.byKey(tabKey(3))), 1);
expect(widthOf(tester, find.byKey(tabKey(3))), size);
});
testWidgets('$host: the selection tint cross-fades to the new button, '
'whose icon takes the selected colour and bounces', (tester) async {
animate(tester, on: true);
await pumpBar(tester, cupertino: cupertino);
await tester.pumpAndSettle();
final tint = fillAlpha(tester, 0);
expect(tint, greaterThan(0.1));
expect(fillAlpha(tester, 1), 0);
expect(fillAlpha(tester, 2), 0);
await tester.tap(find.byKey(tabKey(2)));
await tester.pump();
await tester.pump(const Duration(milliseconds: 80));
expect(fillAlpha(tester, 2), inExclusiveRange(0, tint));
expect(fillAlpha(tester, 0), inExclusiveRange(0, tint));
// The icon grows within its button (which the tap's press sinks).
expect(
iconWidth(tester, 2) * size / widthOf(tester, find.byKey(tabKey(2))),
greaterThan(iconSize * 1.04),
);
expect(iconWidth(tester, 1), moreOrLessEquals(iconSize));
await tester.pumpAndSettle();
expect(fillAlpha(tester, 2), tint);
expect(fillAlpha(tester, 0), 0);
// At rest the selected icon is a little larger than the others.
expect(
iconWidth(tester, 2),
moreOrLessEquals(
iconSize *
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino) /
FloatingDestinationBar.buttonSize(cupertino: cupertino),
),
);
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
expect(iconWidth(tester, 1), moreOrLessEquals(iconSize));
final context = tester.element(find.byKey(tabKey(2)));
final selectedColour = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.onSecondaryContainer;
expect(
IconTheme.of(tester.element(find.byIcon(icons[2]))).color,
isSameColorAs(selectedColour),
);
expect(
IconTheme.of(tester.element(find.byIcon(icons[0]))).color,
isNot(isSameColorAs(selectedColour)),
);
});
testWidgets('$host: a press sinks the button and it springs back', (
tester,
) async {
animate(tester, on: true);
await pumpBar(tester, cupertino: cupertino);
await tester.pumpAndSettle();
final tab = find.byKey(tabKey(1));
final gesture = await tester.startGesture(tester.getCenter(tab));
await tester.pump();
await tester.pump(const Duration(milliseconds: 120));
expect(widthOf(tester, tab), lessThan(size * 0.97));
// Tab 0 is selected, so it is the larger button; the press leaves it.
expect(
widthOf(tester, find.byKey(tabKey(0))),
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino),
);
await gesture.up();
await tester.pumpAndSettle();
// The tap selected it: it springs back to the selected size.
testWidgets('$host: each button pops in on its own, staggered, from '
'0.6 to full size', (tester) async {
animate(tester, on: true);
await pumpBar(tester);
for (var index = 0; index < 3; index += 1) {
final tab = find.byKey(tabKey(index));
expect(opacityOf(tester, tab), 0);
final rest = index == 0
? FloatingDestinationBar.selectedButtonSize(cupertino: false)
: size;
expect(widthOf(tester, tab), moreOrLessEquals(rest * 0.6));
}
await tester.pump(const Duration(milliseconds: 130));
final first = widthOf(tester, find.byKey(tabKey(0)));
final last = widthOf(tester, find.byKey(tabKey(2)));
expect(first, greaterThan(last + 4), reason: 'staggered');
expect(opacityOf(tester, find.byKey(tabKey(0))), greaterThan(0.9));
expect(opacityOf(tester, find.byKey(tabKey(2))), lessThan(0.2));
await tester.pumpAndSettle();
for (var index = 0; index < 3; index += 1) {
final tab = find.byKey(tabKey(index));
expect(opacityOf(tester, tab), 1);
// Tab 0 is selected, so it settles at the larger size.
expect(
widthOf(tester, tab),
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino),
index == 0
? FloatingDestinationBar.selectedButtonSize(cupertino: false)
: size,
);
});
}
});
testWidgets('$host: under reduced motion the tint jumps and the buttons '
'neither pop nor bounce', (tester) async {
animate(tester, on: false);
await pumpBar(tester, cupertino: cupertino);
await tester.pump();
expect(opacityOf(tester, find.byKey(tabKey(1))), 1);
expect(widthOf(tester, find.byKey(tabKey(1))), size);
final tint = fillAlpha(tester, 0);
await tester.tap(find.byKey(tabKey(2)));
await tester.pump();
await tester.pump();
expect(fillAlpha(tester, 2), tint);
expect(fillAlpha(tester, 0), 0);
// No bounce, and the selected icon jumps straight to its larger size.
expect(
iconWidth(tester, 2),
moreOrLessEquals(
iconSize *
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino) /
FloatingDestinationBar.buttonSize(cupertino: cupertino),
testWidgets('$host: the entrance does not replay when the selection '
'changes', (tester) async {
animate(tester, on: true);
await pumpBar(tester);
await tester.pumpAndSettle();
for (final target in [1, 2, 0]) {
await tester.tap(find.byKey(tabKey(target)));
for (var frame = 0; frame < 12; frame += 1) {
await tester.pump(const Duration(milliseconds: 25));
for (var index = 0; index < 3; index += 1) {
final tab = find.byKey(tabKey(index));
expect(opacityOf(tester, tab), 1, reason: 'tab $index faded');
// The selection grows and shrinks buttons between their two
// sizes and the press sinks the tapped one a little; a replayed
// pop would start at 0.6.
expect(
widthOf(tester, tab),
greaterThan(size * 0.9),
reason: 'tab $index popped again',
);
}
}
await tester.pumpAndSettle();
}
});
testWidgets('$host: a new set of tabs pops in again', (tester) async {
animate(tester, on: true);
var count = 3;
late StateSetter update;
await tester.pumpWidget(
app(
StatefulBuilder(
builder: (context, setState) {
update = setState;
return Align(
alignment: Alignment.bottomCenter,
child: FloatingDestinationBar(
cupertino: false,
currentIndex: 0,
onTap: (_) {},
items: items(count),
),
);
},
),
);
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
});
}
),
);
await tester.pumpAndSettle();
expect(opacityOf(tester, find.byKey(tabKey(2))), 1);
update(() => count = 4);
await tester.pump();
expect(opacityOf(tester, find.byKey(tabKey(3))), 0);
expect(opacityOf(tester, find.byKey(tabKey(2))), 0);
await tester.pumpAndSettle();
expect(opacityOf(tester, find.byKey(tabKey(3))), 1);
expect(widthOf(tester, find.byKey(tabKey(3))), size);
});
testWidgets('$host: the selection tint cross-fades to the new button, '
'whose icon takes the selected colour and bounces', (tester) async {
animate(tester, on: true);
await pumpBar(tester);
await tester.pumpAndSettle();
final tint = fillAlpha(tester, 0);
expect(tint, greaterThan(0.1));
expect(fillAlpha(tester, 1), 0);
expect(fillAlpha(tester, 2), 0);
await tester.tap(find.byKey(tabKey(2)));
await tester.pump();
await tester.pump(const Duration(milliseconds: 80));
expect(fillAlpha(tester, 2), inExclusiveRange(0, tint));
expect(fillAlpha(tester, 0), inExclusiveRange(0, tint));
// The icon grows within its button (which the tap's press sinks).
expect(
iconWidth(tester, 2) * size / widthOf(tester, find.byKey(tabKey(2))),
greaterThan(iconSize * 1.04),
);
expect(iconWidth(tester, 1), moreOrLessEquals(iconSize));
await tester.pumpAndSettle();
expect(fillAlpha(tester, 2), tint);
expect(fillAlpha(tester, 0), 0);
// At rest the selected icon is a little larger than the others.
expect(
iconWidth(tester, 2),
moreOrLessEquals(
iconSize *
FloatingDestinationBar.selectedButtonSize(cupertino: false) /
FloatingDestinationBar.buttonSize(cupertino: false),
),
);
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
expect(iconWidth(tester, 1), moreOrLessEquals(iconSize));
final context = tester.element(find.byKey(tabKey(2)));
final selectedColour = Theme.of(context).colorScheme.onSecondaryContainer;
expect(
IconTheme.of(tester.element(find.byIcon(icons[2]))).color,
isSameColorAs(selectedColour),
);
expect(
IconTheme.of(tester.element(find.byIcon(icons[0]))).color,
isNot(isSameColorAs(selectedColour)),
);
});
testWidgets('$host: a press sinks the button and it springs back', (
tester,
) async {
animate(tester, on: true);
await pumpBar(tester);
await tester.pumpAndSettle();
final tab = find.byKey(tabKey(1));
final gesture = await tester.startGesture(tester.getCenter(tab));
await tester.pump();
await tester.pump(const Duration(milliseconds: 120));
expect(widthOf(tester, tab), lessThan(size * 0.97));
// Tab 0 is selected, so it is the larger button; the press leaves it.
expect(
widthOf(tester, find.byKey(tabKey(0))),
FloatingDestinationBar.selectedButtonSize(cupertino: false),
);
await gesture.up();
await tester.pumpAndSettle();
// The tap selected it: it springs back to the selected size.
expect(
widthOf(tester, tab),
FloatingDestinationBar.selectedButtonSize(cupertino: false),
);
});
testWidgets('$host: under reduced motion the tint jumps and the buttons '
'neither pop nor bounce', (tester) async {
animate(tester, on: false);
await pumpBar(tester);
await tester.pump();
expect(opacityOf(tester, find.byKey(tabKey(1))), 1);
expect(widthOf(tester, find.byKey(tabKey(1))), size);
final tint = fillAlpha(tester, 0);
await tester.tap(find.byKey(tabKey(2)));
await tester.pump();
await tester.pump();
expect(fillAlpha(tester, 2), tint);
expect(fillAlpha(tester, 0), 0);
// No bounce, and the selected icon jumps straight to its larger size.
expect(
iconWidth(tester, 2),
moreOrLessEquals(
iconSize *
FloatingDestinationBar.selectedButtonSize(cupertino: false) /
FloatingDestinationBar.buttonSize(cupertino: false),
),
);
expect(iconWidth(tester, 0), moreOrLessEquals(iconSize));
});
testWidgets('switching the shell tabs never replays the main '
"bar's entrance", (tester) async {
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/pop_entrance.dart';
@@ -26,17 +25,13 @@ void main() {
actions: actions,
actionsKey: actionsKey,
);
final Widget home = cupertino
? CupertinoPageScaffold(
navigationBar: bar,
child: const SizedBox.expand(),
)
: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
);
final app = cupertino ? CupertinoApp(home: home) : MaterialApp(home: home);
final app = MaterialApp(
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
),
);
return MediaQuery(
data: MediaQueryData(disableAnimations: reduced),
child: app,
@@ -60,9 +55,10 @@ void main() {
const begin = Motion.tabEntranceScaleBegin;
const step = Motion.tabEntranceStagger;
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
final icon = cupertino ? CupertinoIcons.refresh : Icons.refresh;
{
const cupertino = false;
const host = 'Material';
const icon = Icons.refresh;
Widget action(String key) =>
IconButton(key: Key(key), icon: Icon(icon), onPressed: () {});
final a = find.byKey(const Key('a'));
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -30,17 +29,13 @@ void main() {
),
actions: actions,
);
final Widget home = cupertino
? CupertinoPageScaffold(
navigationBar: bar,
child: const SizedBox.expand(),
)
: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
);
final app = cupertino ? CupertinoApp(home: home) : MaterialApp(home: home);
final app = MaterialApp(
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
),
);
return MediaQuery(
data: MediaQueryData(disableAnimations: reduced),
child: app,
@@ -74,9 +69,10 @@ void main() {
final back = find.byKey(const Key('back'));
final title = find.text('Runs');
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
final icon = cupertino ? CupertinoIcons.refresh : Icons.refresh;
{
const cupertino = false;
const host = 'Material';
const icon = Icons.refresh;
Widget action(String key) =>
IconButton(key: Key(key), icon: Icon(icon), onPressed: () {});
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -15,25 +14,12 @@ const _names = ['Needs you', 'Usage', 'Filter', 'Sort', 'Select'];
Key _key(String name) => ValueKey('action.$name');
/// An icon action like the list bars' own, at the host's touch target.
Widget _icon(bool cupertino, String name, VoidCallback onPressed) => cupertino
? Semantics(
button: true,
label: name,
excludeSemantics: true,
child: CupertinoButton(
key: _key(name),
padding: EdgeInsets.zero,
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
onPressed: onPressed,
child: const Icon(CupertinoIcons.circle),
),
)
: IconButton(
key: _key(name),
tooltip: name,
onPressed: onPressed,
icon: const Icon(Icons.circle_outlined),
);
Widget _icon(bool cupertino, String name, VoidCallback onPressed) => IconButton(
key: _key(name),
tooltip: name,
onPressed: onPressed,
icon: const Icon(Icons.circle_outlined),
);
/// The Runs bar's shape: a bell that always stays, then four that may move.
List<Widget> _actions(bool cupertino, List<String> pressed) => [
@@ -52,22 +38,14 @@ List<Widget> _actions(bool cupertino, List<String> pressed) => [
];
Widget _app(bool cupertino, SegmentedBar bar, {Brightness? brightness}) =>
cupertino
? CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: CupertinoPageScaffold(
navigationBar: bar,
child: const SizedBox.expand(),
),
)
: MaterialApp(
theme: ThemeData(brightness: brightness ?? Brightness.light),
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
),
);
MaterialApp(
theme: ThemeData(brightness: brightness ?? Brightness.light),
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
),
);
/// Pumps the bar and the frame its More menu settles in.
Future<void> _pump(WidgetTester tester, Widget app) async {
@@ -87,8 +65,9 @@ bool _whole(WidgetTester tester, String text) {
}
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
{
const cupertino = false;
const host = 'Material';
for (final width in [240.0, 270.0, 320.0]) {
for (final brightness in Brightness.values) {
testWidgets('$host ${brightness.name} ${width.toInt()}px: the title '
@@ -126,7 +105,7 @@ void main() {
for (final name in shown) tester.getRect(find.byKey(_key(name))),
tester.getRect(more),
];
final target = cupertino ? 44.0 : 48.0;
const target = 48.0;
for (final (index, rect) in rects.indexed) {
expect(rect.width, greaterThanOrEqualTo(target));
expect(rect.height, greaterThanOrEqualTo(target));
+40 -77
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -69,52 +68,28 @@ void main() {
testWidgets('320px at 2x text lays out without overflow', (tester) async {
_size(tester, 320, scale: 2);
for (final cupertino in [false, true]) {
final bar = SegmentedBar(
cupertino: cupertino,
leading: SegmentedBackButton(cupertino: cupertino, onPressed: () {}),
title: 'A long conversation title',
subtitle: 'a-working-folder',
subtitleIcon: Icons.folder_outlined,
onTitlePressed: () {},
actions: cupertino
? [
CupertinoButton(
onPressed: () {},
child: const Text(
'gpt-5.6-luna',
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
]
: [
_modelAction('gpt-5.6-luna'),
IconButton(onPressed: () {}, icon: const Icon(Icons.refresh)),
],
);
// A Cupertino bar over content (the conversation's own) scales its
// text; as a navigation bar the scaffold turns scaling off.
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
child: SegmentedBarOverlay(
bar: bar,
child: const SizedBox.expand(),
),
),
)
: MaterialApp(
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
),
),
);
expect(tester.takeException(), isNull, reason: 'cupertino: $cupertino');
}
final bar = SegmentedBar(
cupertino: false,
leading: SegmentedBackButton(cupertino: false, onPressed: () {}),
title: 'A long conversation title',
subtitle: 'a-working-folder',
subtitleIcon: Icons.folder_outlined,
onTitlePressed: () {},
actions: [
_modelAction('gpt-5.6-luna'),
IconButton(onPressed: () {}, icon: const Icon(Icons.refresh)),
],
);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
),
),
);
expect(tester.takeException(), isNull);
});
testWidgets('taps between the pieces reach the content behind', (
@@ -173,48 +148,36 @@ void main() {
testWidgets('pieces are frosted glass, solid under high contrast', (
tester,
) async {
Widget app(bool highContrast) => CupertinoApp(
Widget app(bool highContrast) => MaterialApp(
home: MediaQuery(
data: MediaQueryData(highContrast: highContrast),
child: const CupertinoPageScaffold(
navigationBar: SegmentedBar(cupertino: true, title: 'Glass'),
child: SizedBox.expand(),
child: Scaffold(
appBar: const SegmentedBar(cupertino: false, title: 'Glass'),
body: const SizedBox.expand(),
),
),
);
await tester.pumpWidget(app(false));
expect(find.byType(GlassPill), findsOneWidget);
expect(find.byType(BackdropFilter), findsOneWidget);
// The Cupertino bar draws no Material widget.
expect(find.byType(Material), findsNothing);
expect(find.byType(Material), findsWidgets);
await tester.pumpWidget(app(true));
expect(find.byType(BackdropFilter), findsNothing);
});
testWidgets('Material and Cupertino titles use semibold text', (
tester,
) async {
for (final cupertino in [false, true]) {
await tester.pumpWidget(
cupertino
? const CupertinoApp(
home: CupertinoPageScaffold(
navigationBar: SegmentedBar(cupertino: true, title: 'Title'),
child: SizedBox.expand(),
),
)
: const MaterialApp(
home: Scaffold(
appBar: SegmentedBar(cupertino: false, title: 'Title'),
body: SizedBox.expand(),
),
),
);
expect(
tester.widget<Text>(find.text('Title')).style?.fontWeight,
FontWeight.w600,
);
}
testWidgets('Material titles use semibold text', (tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
appBar: SegmentedBar(cupertino: false, title: 'Title'),
body: SizedBox.expand(),
),
),
);
expect(
tester.widget<Text>(find.text('Title')).style?.fontWeight,
FontWeight.w600,
);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
@@ -18,31 +17,22 @@ void main() {
const fieldKey = Key('field');
Widget field(bool cupertino) => cupertino
? const CupertinoTextField(key: fieldKey, placeholder: 'Find')
: const TextField(key: fieldKey);
const field = TextField(key: fieldKey);
Rect pillOf(WidgetTester tester, Finder child) => tester.getRect(
find.ancestor(of: child, matching: find.byType(GlassPill)).first,
);
Widget page(bool cupertino, SegmentedBar bar) => cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
navigationBar: bar,
child: const SizedBox.expand(),
),
)
: MaterialApp(
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
),
);
Widget page(SegmentedBar bar) => MaterialApp(
home: Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: const SizedBox.expand(),
),
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
{
const host = 'Material';
testWidgets('$host: the widget replaces the title and fills a phone bar', (
tester,
@@ -50,11 +40,10 @@ void main() {
setSize(tester, 390);
await tester.pumpWidget(
page(
cupertino,
SegmentedBar(
cupertino: cupertino,
cupertino: false,
title: 'Search',
titleWidget: field(cupertino),
titleWidget: field,
titleWidgetMaxWidth: 840,
),
),
@@ -81,15 +70,11 @@ void main() {
setSize(tester, 1200);
await tester.pumpWidget(
page(
cupertino,
SegmentedBar(
cupertino: cupertino,
cupertino: false,
title: 'Search',
leading: SegmentedBackButton(
cupertino: cupertino,
onPressed: () {},
),
titleWidget: field(cupertino),
leading: SegmentedBackButton(cupertino: false, onPressed: () {}),
titleWidget: field,
titleWidgetMaxWidth: 600,
actions: const [Icon(Icons.info_outline, key: Key('action'))],
),
+99
View File
@@ -0,0 +1,99 @@
import 'package:pipelines_app/core/api_gateway.dart';
/// Local-only catalogs for exercising all three header menus with `header=1`.
/// No provider or production permission setting is read or changed.
class ChatCatalogFixture {
static const models = <JsonMap>[
{'id': 'openai/gpt-6.1', 'provider': 'openai', 'name': 'GPT 6.1'},
{'id': 'openai/gpt-5.6-luna', 'provider': 'openai', 'name': 'Luna'},
];
static const modes = <JsonMap>[
{
'id': 'default',
'name': 'Ask for permission',
'description': 'Ask before actions that require approval.',
},
{
'id': 'plan',
'name': 'Plan only',
'description': 'Inspect and plan without applying changes.',
},
{
'id': 'auto',
'name': 'Auto approve',
'description': 'Fixture-only automatic approval mode.',
},
];
final Map<String, JsonMap> _model = {};
final Map<String, String> _mode = {};
JsonMap rowFields(String sessionId) {
final model = _model[sessionId] ?? models.first;
final mode = _mode[sessionId] ?? 'default';
return {
'model': model['id'],
'model_provider': model['provider'],
if (_model.containsKey(sessionId)) 'model_selection': 'next_turn',
'mode': mode,
'mode_name': modes.firstWhere((item) => item['id'] == mode)['name'],
};
}
JsonMap? reply(JsonMap request) {
switch (request['type']) {
case 'chat_models':
return {'type': 'chat_models', 'chat_models': models};
case 'chat_modes':
final body = request['chat_query'];
final session = body is Map ? '${body['session_id'] ?? ''}' : '';
return {
'type': 'chat_modes',
'chat_modes': modes,
'chat_mode': {'mode': rowFields(session)['mode']},
};
case 'chat_model':
final body = request['chat_model'];
if (body is! Map) return _invalid;
final session = '${body['session_id'] ?? ''}';
final model = models
.where(
(item) =>
item['id'] == body['model'] &&
item['provider'] == body['provider'],
)
.firstOrNull;
if (session.isEmpty || model == null) return _invalid;
_model[session] = model;
return {
'type': 'chat_model',
'chat_model': {
'session_id': session,
'provider': model['provider'],
'model': model['id'],
'selection': 'next_turn',
},
};
case 'chat_mode':
final body = request['chat_mode'];
if (body is! Map) return _invalid;
final session = '${body['session_id'] ?? ''}';
final mode = '${body['mode'] ?? ''}';
if (session.isEmpty || !modes.any((item) => item['id'] == mode)) {
return _invalid;
}
_mode[session] = mode;
return {
'type': 'chat_mode',
'chat_mode': {'session_id': session, 'mode': mode},
};
default:
return null;
}
}
static const _invalid = <String, dynamic>{
'type': 'error',
'error': 'Unknown chat catalog fixture selection.',
};
}
+7 -3
View File
@@ -23,6 +23,7 @@
import 'package:pipelines_app/core/api_gateway.dart';
import 'chat_effort_fixture.dart';
import 'chat_catalog_fixture.dart';
import 'chat_new_session_fixture.dart';
import 'chat_turn_diff_fixture.dart';
import 'chat_question_fixture.dart';
@@ -77,6 +78,7 @@ const _colorTitles = [
const _colorStarred = {0, 1, 3};
const _colorNames = ['teal', 'purple', null, 'amber', 'red', null, 'blue'];
final Map<String, String?> _pickedColors = {};
final _chatCatalog = ChatCatalogFixture();
JsonMap _chatRow(int i) {
final id = perfChatId(i);
@@ -86,9 +88,7 @@ JsonMap _chatRow(int i) {
'title': 'Fixture chat ${i + 1}',
'directory': '/workspace/demo',
if (_params['header'] == '1') ...{
'model': 'openai/gpt-6.1',
'mode': 'default',
'mode_name': 'Ask for permission',
..._chatCatalog.rowFields(id),
...chatEffortRowFields(id),
},
// Server-shaped handoff facts (chat_sessions rows carry them).
@@ -245,6 +245,10 @@ JsonMap? perfChatReply(JsonMap request) {
final shell = chatShellReply(request);
if (shell != null) return shell;
final id = request['id'];
if (_params['header'] == '1') {
final catalog = _chatCatalog.reply(request);
if (catalog != null) return {'id': id, ...catalog};
}
switch ('${request['type']}') {
case 'chat_effort':
return {'id': id, ...chatEffortReply(request)};