Glass: subtler frosted look instead of a metallic sheen
Top highlight, rim and shadow are much fainter in both themes, the highlight fades out sooner (0.55 -> 0.4), the backdrop saturation boost drops from 1.6 to 1.25 and the fill opacity rises from 0.78 to 0.82. One backdrop filter per piece and the solid high-contrast piece stay.
This commit is contained in:
@@ -7,7 +7,7 @@ import 'glass_surface.dart';
|
||||
/// blurred and its colour lifted inside the piece's [shape], under a
|
||||
/// translucent fill in the host's raised surface role (Material
|
||||
/// `surfaceContainerHigh`, Cupertino `systemGrey5`), a soft highlight along
|
||||
/// its top, a thin luminous rim over a hairline border, and a soft shadow
|
||||
/// its top, a faint rim over a hairline border, and a soft shadow
|
||||
/// outside it ([GlassLook], tuned for light and dark fills).
|
||||
///
|
||||
/// Under the system's high-contrast setting the fill is solid, nothing is
|
||||
@@ -42,7 +42,7 @@ class GlassPill extends StatelessWidget {
|
||||
static const double blurSigma = 4;
|
||||
|
||||
/// How much of the fill covers the blurred content.
|
||||
static const double fillOpacity = 0.78;
|
||||
static const double fillOpacity = 0.82;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -4,7 +4,11 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
/// The look of a frosted [GlassPill]-style surface, tuned once for light and
|
||||
/// dark fills: how the content behind is filtered, the soft specular
|
||||
/// highlight along its top edge, its luminous rim and its depth shadow.
|
||||
/// highlight along its top edge, its faint rim and its depth shadow.
|
||||
///
|
||||
/// The look is clean frosted glass, not polished metal: the highlight only
|
||||
/// lifts the top of the fill a little, the rim reads as a faint edge with a
|
||||
/// gentle top-to-bottom falloff (not a bevel), and the shadow is a soft lift.
|
||||
///
|
||||
/// Every value is chosen for a surface that keeps text and icons readable at
|
||||
/// WCAG AA over whatever scrolls behind it: the fill still covers most of the
|
||||
@@ -20,19 +24,19 @@ class GlassLook {
|
||||
|
||||
/// The look over a light fill (the light theme's raised surface).
|
||||
static const GlassLook light = GlassLook._(
|
||||
highlight: Color(0xA6FFFFFF),
|
||||
rimTop: Color(0xE6FFFFFF),
|
||||
rimBottom: Color(0x33FFFFFF),
|
||||
shadow: Color(0x24000000),
|
||||
highlight: Color(0x2EFFFFFF),
|
||||
rimTop: Color(0x59FFFFFF),
|
||||
rimBottom: Color(0x26FFFFFF),
|
||||
shadow: Color(0x14000000),
|
||||
);
|
||||
|
||||
/// The look over a dark fill (the dark theme's raised surface, a dark
|
||||
/// viewer's pieces).
|
||||
static const GlassLook dark = GlassLook._(
|
||||
highlight: Color(0x1FFFFFFF),
|
||||
rimTop: Color(0x47FFFFFF),
|
||||
rimBottom: Color(0x0DFFFFFF),
|
||||
shadow: Color(0x59000000),
|
||||
highlight: Color(0x0AFFFFFF),
|
||||
rimTop: Color(0x1FFFFFFF),
|
||||
rimBottom: Color(0x0AFFFFFF),
|
||||
shadow: Color(0x40000000),
|
||||
);
|
||||
|
||||
/// The look for a surface filled with [fill]: dark below mid luminance.
|
||||
@@ -52,18 +56,18 @@ class GlassLook {
|
||||
|
||||
/// How far down the surface the top highlight reaches, as a fraction of
|
||||
/// its height.
|
||||
static const double highlightExtent = 0.55;
|
||||
static const double highlightExtent = 0.4;
|
||||
|
||||
/// The width of the luminous rim, inside the surface's edge.
|
||||
/// The width of the faint rim, inside the surface's edge.
|
||||
static const double rimWidth = 1;
|
||||
|
||||
/// The shadow's blur and how far below the surface it falls.
|
||||
static const double shadowSigma = 3;
|
||||
static const Offset shadowOffset = Offset(0, 1.5);
|
||||
static const double shadowSigma = 4;
|
||||
static const Offset shadowOffset = Offset(0, 1);
|
||||
|
||||
/// How much the backdrop's colour is boosted after blurring, so a colour
|
||||
/// behind the glass still reads through its fill.
|
||||
static const double saturation = 1.6;
|
||||
static const double saturation = 1.25;
|
||||
|
||||
/// The backdrop filter: a blur of [sigma], then the saturation boost. Both
|
||||
/// are one filter (one backdrop read) on every renderer.
|
||||
@@ -121,8 +125,8 @@ class GlassHighlightPainter extends CustomPainter {
|
||||
textDirection != oldDelegate.textDirection;
|
||||
}
|
||||
|
||||
/// The thin luminous rim of a glass surface of [shape]: a stroke just inside
|
||||
/// its edge, bright along the top and faint along the bottom, painted over
|
||||
/// The thin rim of a glass surface of [shape]: a faint stroke just inside
|
||||
/// its edge, a little brighter along the top than along the bottom, painted over
|
||||
/// the surface's content (ink included) so it stays a clean edge.
|
||||
class GlassRimPainter extends CustomPainter {
|
||||
const GlassRimPainter({
|
||||
|
||||
@@ -46,6 +46,17 @@ void main() {
|
||||
expect(GlassLook.forFill(Colors.black), same(GlassLook.dark));
|
||||
});
|
||||
|
||||
test('the look stays subtle frosted glass, not a metallic sheen', () {
|
||||
for (final look in [GlassLook.light, GlassLook.dark]) {
|
||||
expect(look.highlight.a, lessThanOrEqualTo(0.2));
|
||||
expect(look.rimTop.a, lessThanOrEqualTo(0.35));
|
||||
expect(look.rimTop.a - look.rimBottom.a, lessThanOrEqualTo(0.2));
|
||||
expect(look.shadow.a, lessThanOrEqualTo(0.26));
|
||||
}
|
||||
expect(GlassLook.highlightExtent, lessThanOrEqualTo(0.4));
|
||||
expect(GlassLook.saturation, inInclusiveRange(1.0, 1.3));
|
||||
});
|
||||
|
||||
testWidgets('high contrast keeps a solid piece without blur or sheen', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user