Glass: liquid-glass look for every glass surface

GlassPill (segmented bars, floating tabs, composer, viewer control bars,
top strips) now composes blur with a saturation boost in one backdrop
filter, paints a soft top highlight, a thin luminous gradient rim and an
outer-only depth shadow, tuned separately for light and dark fills
(GlassLook in glass_surface.dart). Fill opacity 0.84 -> 0.78; blur stays
at sigma 4 and one filter per piece. High contrast keeps the solid piece.
This commit is contained in:
2026-11-03 16:11:24 +00:00
parent 5f51bbf53b
commit 9283220c82
3 changed files with 312 additions and 24 deletions
@@ -0,0 +1,58 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/glass_surface.dart';
Widget _pill({Brightness brightness = Brightness.light, bool solid = false}) =>
MaterialApp(
theme: ThemeData(brightness: brightness),
home: MediaQuery(
data: MediaQueryData(highContrast: solid),
child: const Center(
child: GlassPill(cupertino: false, child: Text('Runs')),
),
),
);
List<CustomPainter> _painters(WidgetTester tester) => [
for (final paint in tester.widgetList<CustomPaint>(
find.ancestor(of: find.text('Runs'), matching: find.byType(CustomPaint)),
)) ...[?paint.painter, ?paint.foregroundPainter],
];
void main() {
testWidgets('a piece has its highlight, rim and shadow, and one backdrop '
'read that blurs and saturates', (tester) async {
await tester.pumpWidget(_pill());
final painters = _painters(tester);
expect(painters.whereType<GlassHighlightPainter>(), hasLength(1));
expect(painters.whereType<GlassRimPainter>(), hasLength(1));
expect(painters.whereType<GlassShadowPainter>(), hasLength(1));
final layers = tester.layers.whereType<BackdropFilterLayer>().toList();
expect(layers, hasLength(1));
expect(layers.single.filter, GlassLook.backdrop(GlassPill.blurSigma));
});
testWidgets('light and dark fills get their own look', (tester) async {
await tester.pumpWidget(_pill());
final light = _painters(tester).whereType<GlassRimPainter>().single;
expect(light.top, GlassLook.light.rimTop);
await tester.pumpWidget(_pill(brightness: Brightness.dark));
await tester.pumpAndSettle();
final dark = _painters(tester).whereType<GlassRimPainter>().single;
expect(dark.top, GlassLook.dark.rimTop);
expect(GlassLook.forFill(Colors.white), same(GlassLook.light));
expect(GlassLook.forFill(Colors.black), same(GlassLook.dark));
});
testWidgets('high contrast keeps a solid piece without blur or sheen', (
tester,
) async {
await tester.pumpWidget(_pill(solid: true));
expect(_painters(tester).whereType<GlassHighlightPainter>(), isEmpty);
expect(_painters(tester).whereType<GlassRimPainter>(), isEmpty);
expect(_painters(tester).whereType<GlassShadowPainter>(), isEmpty);
expect(tester.layers.whereType<BackdropFilterLayer>(), isEmpty);
});
}