Glass design: frosted panes over a soft gradient (WIP)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 23:21:05 +00:00
parent 9436067bf2
commit 8ca3d3e467
37 changed files with 1901 additions and 67 deletions
@@ -0,0 +1,139 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/domain/chat_transcript.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_markdown_view.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_bubble.dart';
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart';
import 'package:pipelines_app/ui/theme/app_design.dart';
import 'package:pipelines_app/ui/theme/app_design_tokens.dart';
JsonMap _row(JsonMap message) => transcriptRows([message]).single;
final JsonMap _operator = _row({
'id': 'u1',
'role': 'user',
'parts': [
{'type': 'text', 'text': 'Fix the Windows paths.'},
],
});
JsonMap _tool(String id, String name) => {
'type': 'tool',
'id': id,
'name': name,
'state': {
'status': 'completed',
'input': {'command': 'go test ./...'},
},
};
final JsonMap _agent = _row({
'id': 'a1',
'role': 'assistant',
'parts': [
_tool('t1', 'Bash'),
_tool('t2', 'Read'),
{
'type': 'text',
'text': 'Fixed the separators.\n\n```go\nreturn filepath.Join(a, b)\n```',
},
],
});
final JsonMap _followup = _row({
'id': 'f1',
'role': 'user',
'origin': 'followup',
'client': 'Agent follow-up',
'parts': [
{'type': 'text', 'text': 'Check whether run 42 finished.'},
],
});
Widget _host(AppDesign design, List<JsonMap> rows, {Brightness? brightness}) =>
MaterialApp(
theme: brightness == Brightness.dark ? design.dark() : design.light(),
home: Scaffold(
body: ChatBubbleColor(
name: 'teal',
child: ListView(
children: [
for (final row in rows)
ChatMessageView(row: row, textBuilder: chatMarkdownText),
],
),
),
),
);
ShapeBorder _bubbleShape(WidgetTester tester) => tester
.widget<Material>(
find
.descendant(
of: find.byType(ChatUserBubble),
matching: find.byType(Material),
)
.first,
)
.shape!;
void main() {
for (final brightness in Brightness.values) {
testWidgets('Glass ($brightness): the operator turn is a frosted pill '
'tinted with the chat colour, under a glass edge', (tester) async {
await tester.pumpWidget(
_host(AppDesign.glass, [_operator], brightness: brightness),
);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(_bubbleShape(tester), isA<GlassBorder>());
final fill = tester
.widget<Material>(
find
.descendant(
of: find.byType(ChatUserBubble),
matching: find.byType(Material),
)
.first,
)
.color!;
expect(fill.a, lessThan(1), reason: 'translucent glass');
// Tinted towards the chat's teal: more green than red.
expect(fill.g, greaterThan(fill.r));
});
}
testWidgets('Glass draws the agent turn with its tools chip, code card and '
'follow-up note as glass, without errors', (tester) async {
await tester.pumpWidget(
_host(AppDesign.glass, [_operator, _agent, _followup]),
);
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(find.textContaining('Fixed the separators'), findsOneWidget);
expect(find.byKey(const Key('chat-code-body')), findsOneWidget);
final note = tester.widget<Material>(
find.byKey(const Key('chat-automated-prompt')),
);
expect(note.shape, isA<GlassBorder>());
final glass = Theme.of(
tester.element(find.byType(ListView)),
).extension<AppDesignTokens>()!.glass!;
expect(note.color, glass.card);
});
testWidgets('Classic keeps its bubble and notes (no glass edges)', (
tester,
) async {
await tester.pumpWidget(
_host(AppDesign.standard, [_operator, _agent, _followup]),
);
await tester.pumpAndSettle();
expect(_bubbleShape(tester), isA<RoundedRectangleBorder>());
final note = tester.widget<Material>(
find.byKey(const Key('chat-automated-prompt')),
);
expect(note.shape, isA<RoundedRectangleBorder>());
});
}