Merge branch 'main' into worktree-agent-abb9404cc062f4b30

# Conflicts:
#	app/lib/application/app.dart
#	app/lib/application/detached/detached_app.dart
#	app/lib/application/pipelines_root.dart
#	app/lib/ui/theme/app_design.dart
#	app/test/ui/theme/compact_switch_test.dart
#	app/test/ui/theme/high_contrast_design_test.dart
This commit is contained in:
2026-12-04 01:19:44 +00:00
39 changed files with 1977 additions and 73 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
import '../ui/theme/design_focus_ring.dart';
import '../ui/adaptive/window_margins.dart';
import '../ui/theme/app_design_controller.dart';
import '../ui/theme/glass_backdrop.dart';
import '../ui/theme/app_font_controller.dart';
import '../ui/theme/design_screen_overlay.dart';
import '../ui/scale/ui_scale.dart';
@@ -95,7 +96,9 @@ class MyApp extends StatelessWidget {
DesignScreenOverlay(
child: DesignFocusRing(
child: UiScaleHost(
child: WindowMargins(child: child ?? const SizedBox.shrink()),
child: WindowMargins(
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
),
),
),
);
@@ -16,6 +16,7 @@ import '../../ui/scale/ui_scale.dart';
import '../../ui/theme/app_font_controller.dart';
import '../../ui/theme/app_design_controller.dart';
import '../../ui/theme/design_screen_overlay.dart';
import '../../ui/theme/glass_backdrop.dart';
import '../app_route.dart';
import '../app_session.dart';
import '../app_terminals.dart';
@@ -227,7 +228,9 @@ class _DetachedWindowAppState extends State<DetachedWindowApp> {
builder: (context, child) => DesignScreenOverlay(
child: DesignFocusRing(
child: UiScaleHost(
child: WindowMargins(child: child ?? const SizedBox.shrink()),
child: WindowMargins(
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
),
),
),
),
+4 -1
View File
@@ -18,6 +18,7 @@ import '../features/settings/saved_servers_section.dart';
import '../features/settings/settings_store.dart';
import '../ui/scale/ui_scale.dart';
import '../ui/theme/app_design_controller.dart';
import '../ui/theme/glass_backdrop.dart';
import '../ui/theme/app_font_controller.dart';
import '../ui/theme/design_screen_overlay.dart';
import 'detached/detached_app.dart';
@@ -389,7 +390,9 @@ class _PipelinesRootState extends State<PipelinesRoot> {
builder: (context, child) => DesignScreenOverlay(
child: DesignFocusRing(
child: UiScaleHost(
child: WindowMargins(child: child ?? const SizedBox.shrink()),
child: WindowMargins(
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
),
),
),
),
@@ -41,7 +41,9 @@ class DiffSearchBar extends StatelessWidget {
borderRadius: AppDesignTokens.of(
context,
).denseCorners(BorderRadius.circular(28)),
color: Theme.of(context).colorScheme.surfaceContainerHigh,
color: AppDesignTokens.of(
context,
).solidFill(Theme.of(context).colorScheme.surfaceContainerHigh),
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 4, 4),
child: Row(
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'chat_find_controller.dart';
import '../../../ui/theme/app_design_tokens.dart';
import 'chat_find_controller.dart';
/// The chat's find bar, like the terminal's: the query field, the match
/// count, Match case, the older/newer and close buttons. Matches count from
@@ -68,7 +68,9 @@ class _ChatFindBarState extends State<ChatFindBar> {
return TextFieldTapRegion(
child: Material(
elevation: 3,
color: scheme.surfaceContainerHigh,
color: AppDesignTokens.of(
context,
).solidFill(scheme.surfaceContainerHigh),
borderRadius: AppDesignTokens.of(
context,
).denseCorners(BorderRadius.circular(8)),
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import '../../../core/servers/server_context.dart';
import '../../../ui/adaptive/app_popups.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../ui/theme/app_design_tokens.dart';
import '../../../ui/adaptive/segmented_bar_overflow.dart';
import 'chat_bar_tint.dart';
import '../workspace/chat_workspace_pane_scope.dart';
@@ -165,8 +166,25 @@ class ChatThreadHeader extends StatelessWidget {
],
bottomPadding: compact ? 8 : 16,
);
return ColoredBox(
color: Theme.of(context).colorScheme.surface,
// A glass design's header is part of the pane's glass: no band, a
// soft fade from the pane's solid tone at the top edge, so what
// scrolls under the bar dissolves rather than shows through.
final glass = AppDesignTokens.of(context).glass;
return DecoratedBox(
decoration: glass == null
? BoxDecoration(color: Theme.of(context).colorScheme.surface)
: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
glass.solid.withValues(alpha: 0.92),
glass.solid.withValues(alpha: 0.6),
glass.solid.withValues(alpha: 0),
],
stops: const [0, 0.6, 1],
),
),
child: tint == null
? bar
: ChatBarTintScope(
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'chat_shell_terminal_find.dart';
import '../../../ui/theme/app_design_tokens.dart';
import 'chat_shell_terminal_find.dart';
/// The terminal's find bar: the query field (Enter finds the next match,
/// Shift+Enter the previous, Esc closes), the match count, Match case and
@@ -69,7 +69,9 @@ class _ChatShellTerminalFindBarState extends State<ChatShellTerminalFindBar> {
return TextFieldTapRegion(
child: Material(
elevation: 3,
color: scheme.surfaceContainerHigh,
color: AppDesignTokens.of(
context,
).solidFill(scheme.surfaceContainerHigh),
borderRadius: AppDesignTokens.of(
context,
).denseCorners(BorderRadius.circular(8)),
@@ -6,6 +6,7 @@ import 'package:xterm/xterm.dart';
import '../../../ui/text/monospace.dart';
import '../../../ui/text/terminal_symbols_font.dart';
import '../../../ui/theme/app_design_tokens.dart';
import '../../terminal/terminal_layout.dart';
import '../conversation/chat_card_styles.dart';
import 'chat_shell_terminal_palette.dart';
@@ -18,8 +19,9 @@ const double chatShellTerminalCurrentMatchAlpha = 0.4;
/// The terminal's background: the theme's lowest surface, the most
/// contrast its colours can have in either brightness.
Color chatShellTerminalBackground(BuildContext context) =>
Theme.of(context).colorScheme.surfaceContainerLowest;
Color chatShellTerminalBackground(BuildContext context) => AppDesignTokens.of(
context,
).solidFill(Theme.of(context).colorScheme.surfaceContainerLowest);
/// The terminal's colours from the host theme: its lowest surface as
/// background, the body text colour as foreground, the accent as cursor and
@@ -49,9 +49,12 @@ class ChatStackDisc extends StatelessWidget {
// A raised dark design lifts the disc a tone, as Material's dark
// elevation does, so the pile's layers read where a shadow cannot.
final dark = Theme.of(context).brightness == Brightness.dark;
final base = tokens.panelFill(
scheme,
dark ? scheme.surfaceContainerHighest : scheme.surface,
// Opaque under a glass design too, whose containers are translucent.
final base = tokens.solidFill(
tokens.panelFill(
scheme,
dark ? scheme.surfaceContainerHighest : scheme.surface,
),
);
final ring = this.ring;
final shape = chatStackShape(tokens);
@@ -198,7 +201,9 @@ class ChatStackLabel extends StatelessWidget {
final tokens = AppDesignTokens.of(context);
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final base = tokens.panelFill(scheme, scheme.surfaceContainerHigh);
final base = tokens.solidFill(
tokens.panelFill(scheme, scheme.surfaceContainerHigh),
);
final color = this.color;
final dark = theme.brightness == Brightness.dark;
// A design with a contrast floor marks the chat's colour with a bold
@@ -76,7 +76,9 @@ class ChatSessionRow extends StatelessWidget {
final shade = chatColorShade(context, chatSessionColor(session));
final marker = shade ?? accent;
final tint = AppListRow.tintFor(context, shade);
final background = Theme.of(context).scaffoldBackgroundColor;
final background =
AppDesignTokens.of(context).glass?.solid ??
Theme.of(context).scaffoldBackgroundColor;
// On a phone the chat's page grows out of this row and shrinks back
// into it; the surface it starts from is the row's tint over the list.
return ContainerTransformSource(
@@ -33,6 +33,8 @@ IconData _icon(ChatPromptOrigin origin) => switch (origin) {
_ => Icons.swap_horiz,
};
const BorderRadius _noteCorners = BorderRadius.all(Radius.circular(16));
/// A prompt the agent or the server sent on the operator's behalf. It is not
/// the operator's filled bubble: a quiet outlined card on the agent's side,
/// headed by what sent it (and, for a follow-up, when the agent scheduled it
@@ -81,6 +83,7 @@ class ChatAutomatedPromptCard extends StatelessWidget {
final tokens = AppDesignTokens.of(context);
final density = tokens.density;
final transcript = tokens.transcript;
final glass = tokens.glass;
final card = transcript == TranscriptStyle.cells
? NotebookScheduledCell(
tag: chatAutomatedPromptTag(prompt.origin),
@@ -100,7 +103,7 @@ class ChatAutomatedPromptCard extends StatelessWidget {
? _terminalLine(context, label, detail)
: Material(
key: const Key('chat-automated-prompt'),
color: scheme.surfaceContainerLow,
color: glass?.card ?? scheme.surfaceContainerLow,
clipBehavior: Clip.antiAlias,
// A boxed transcript frames it in the design's corners and
// stroke, in the secondary ink, so it reads apart from the
@@ -113,10 +116,16 @@ class ChatAutomatedPromptCard extends StatelessWidget {
width: tokens.stroke,
),
)
// A glass design's note is a small glass card with a
// light top edge.
: glass != null
? GlassBorder(
borderRadius: tokens.corners(_noteCorners),
highlight: glass.highlight,
edge: glass.edge,
)
: RoundedRectangleBorder(
borderRadius: tokens.corners(
const BorderRadius.all(Radius.circular(16)),
),
borderRadius: tokens.corners(_noteCorners),
side: BorderSide(color: scheme.outlineVariant),
),
child: Padding(
@@ -181,12 +181,23 @@ class ChatCodeCopyRegion extends StatelessWidget {
),
),
);
final glass = AppDesignTokens.of(context).glass;
return DecoratedBox(
position: DecorationPosition.foreground,
decoration: BoxDecoration(
border: Border.all(color: scheme.outlineVariant),
borderRadius: corners,
),
// A glass design's code block is an inset glass card: a light top
// edge falling off into a faint hairline.
decoration: glass == null
? BoxDecoration(
border: Border.all(color: scheme.outlineVariant),
borderRadius: corners,
)
: ShapeDecoration(
shape: GlassBorder(
borderRadius: corners,
highlight: glass.highlight,
edge: glass.edge,
),
),
child: ClipRRect(
borderRadius: corners,
child: ColoredBox(
@@ -60,6 +60,10 @@ class ChatUserBubble extends StatelessWidget {
case TranscriptStyle.bubbles:
break;
}
// A glass design's bubble is a frosted pill: its translucent fill tinted
// with the chat's colour, under a light top edge (no blur: a bubble
// scrolls, so it never filters what is behind it).
final glass = AppDesignTokens.of(context).glass;
// A Material surface (not a bare DecoratedBox) so a disclosure ListTile
// inside the bubble keeps its ink and background. A dense design draws
// a tighter bubble in its own corners.
@@ -71,7 +75,13 @@ class ChatUserBubble extends StatelessWidget {
Theme.of(context).colorScheme.surfaceContainerHighest,
),
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(borderRadius: tokens.corners(_radius)),
shape: glass == null
? RoundedRectangleBorder(borderRadius: tokens.corners(_radius))
: GlassBorder(
borderRadius: tokens.corners(_radius),
highlight: glass.highlight,
edge: glass.edge,
),
child: Padding(
padding: density.dense
? EdgeInsets.symmetric(
@@ -202,8 +202,21 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
final button = TextButton(
key: const Key('chat-turn-activity'),
style: TextButton.styleFrom(
minimumSize: Size(0, dense ? math.max(28, density.minTouchRow) : 48),
padding: dense
minimumSize: Size(
0,
dense
? math.max(28, density.minTouchRow)
// A glass chip is slim on a pointer device.
: tokens.glass != null && compact
? 36
: 48,
),
padding: tokens.glass != null && !dense
? const EdgeInsets.symmetric(
horizontal: chatAgentContentInset,
vertical: 6,
)
: dense
? const EdgeInsets.symmetric(
horizontal: chatAgentContentInset,
vertical: 4,
@@ -211,6 +224,16 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
: const EdgeInsets.all(chatAgentContentInset),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
alignment: AlignmentDirectional.centerStart,
// A glass design draws the line as a slim glass chip.
backgroundColor: tokens.glass?.card,
shape: switch (tokens.glass) {
final glass? => GlassBorder(
borderRadius: const BorderRadius.all(Radius.circular(12)),
highlight: glass.highlight,
edge: glass.edge,
),
null => null,
},
),
onPressed: _open,
child: content,
@@ -92,6 +92,9 @@ class _ChatTurnChipState extends State<ChatTurnChip> {
),
],
);
final corners = AppDesignTokens.of(
context,
).corners(BorderRadius.circular(8));
return Semantics(
button: true,
expanded: _open,
@@ -102,24 +105,42 @@ class _ChatTurnChipState extends State<ChatTurnChip> {
excludeSemantics: true,
child: Padding(
padding: const EdgeInsets.only(top: 2),
child: InkWell(
key: widget.chipKey,
borderRadius: AppDesignTokens.of(
context,
).corners(BorderRadius.circular(8)),
onTap: _show,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: chatAgentContentInset,
vertical: AppDesignTokens.of(context).density.space(6),
child: _glass(
context,
corners,
InkWell(
key: widget.chipKey,
borderRadius: corners,
onTap: _show,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: chatAgentContentInset,
vertical: AppDesignTokens.of(context).density.space(6),
),
child: content,
),
child: content,
),
),
),
);
}
/// Under a glass design the chip is a slim glass card (a tint and a
/// light top edge); elsewhere it is the bare ink row.
Widget _glass(BuildContext context, BorderRadius corners, Widget chip) {
final glass = AppDesignTokens.of(context).glass;
if (glass == null) return chip;
return Material(
color: glass.card,
shape: GlassBorder(
borderRadius: corners,
highlight: glass.highlight,
edge: glass.edge,
),
child: chip,
);
}
Widget _label({int? maxLines, TextOverflow? overflow}) {
final style = chatTurnChipTextStyle(context, widget.color);
final spans = widget.labelSpans;
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../ui/adaptive/resize_grip.dart';
import '../../ui/theme/app_design_tokens.dart';
import '../chat/shell/chat_shell_terminal_theme.dart';
import 'terminal_body.dart';
import 'terminal_hub.dart';
@@ -162,7 +163,9 @@ class _TerminalPanelState extends State<TerminalPanel> {
),
),
);
final surface = Theme.of(context).colorScheme.surfaceContainerLow;
final surface = AppDesignTokens.of(
context,
).solidFill(Theme.of(context).colorScheme.surfaceContainerLow);
final divider = Theme.of(context).colorScheme.outlineVariant;
return Semantics(
container: true,
+22 -10
View File
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/motion/motion.dart';
import '../ui/theme/app_design_tokens.dart';
import 'detail_pane_navigator.dart';
import 'list_detail_policy.dart';
import 'list_pane_divider.dart';
@@ -13,6 +14,8 @@ import 'shell_bar.dart';
export 'list_detail_policy.dart';
const Color _clear = Color(0x00000000);
/// The system's own insets (status bar, navigation bar) as the shell saw
/// them, before its scaffold replaced them with its bars' heights.
///
@@ -164,6 +167,9 @@ class _ListDetailPanesState extends State<ListDetailPanes>
final key = ShellBarScope.maybeOf(context)?.destination.name ?? 'panes';
final media = MediaQuery.of(context);
final split = ShellBar.available(context);
// A glass design tints the list and the open item over its backdrop:
// the reading pane more strongly, so long text reads on an even ground.
final glass = AppDesignTokens.of(context).glass;
return ShellPaneSplit(
child: ListenableBuilder(
listenable: Listenable.merge([widths, _hidden]),
@@ -260,11 +266,14 @@ class _ListDetailPanesState extends State<ListDetailPanes>
excluding: listGone,
child: SizedBox.expand(
key: const ValueKey('list-detail-list'),
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-list',
child: widget.list,
child: ColoredBox(
color: glass?.pane ?? _clear,
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-list',
child: widget.list,
),
),
),
),
@@ -277,11 +286,14 @@ class _ListDetailPanesState extends State<ListDetailPanes>
width: bodyWidth,
child: SizedBox.expand(
key: const ValueKey('list-detail-body'),
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-body',
child: body,
child: ColoredBox(
color: glass?.detail ?? _clear,
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-body',
child: body,
),
),
),
),
+9 -2
View File
@@ -74,7 +74,10 @@ class ShellNavigationRail extends StatelessWidget {
@override
Widget build(BuildContext context) {
final index = shellTabDestinations.indexOf(selected);
final surface = Theme.of(context).colorScheme.surface;
// A glass design tints the rail over its backdrop instead.
final surface =
AppDesignTokens.of(context).glass?.rail ??
Theme.of(context).colorScheme.surface;
final density = AppDesignTokens.of(context).density;
// The surface runs under the top inset too: the padding only moves the
// rail's content below the system's top, so no unpainted strip shows above
@@ -175,7 +178,11 @@ class _SettingsRailItem extends StatelessWidget {
alignment: Alignment.center,
decoration: ShapeDecoration(
shape: AppDesignTokens.of(context).shape(const StadiumBorder()),
color: selected ? scheme.secondaryContainer : null,
// A glass design's rail marks its item with a bright glass slab.
color: selected
? AppDesignTokens.of(context).glass?.slab ??
scheme.secondaryContainer
: null,
),
child: Icon(item.icon, color: foreground),
);
+24 -9
View File
@@ -8,14 +8,15 @@ const double windowCornerRadius = 12;
/// A floating window's corners under the design at [context]:
/// [windowCornerRadius], a design's own window radius (High contrast's), or
/// a dense design's own corners.
/// a dense design's own corners, or a glass design's grown ones.
BorderRadius windowCorners(BuildContext context) {
final tokens = AppDesignTokens.of(context);
final radius = tokens.windowRadius;
if (radius != null) return BorderRadius.circular(radius);
return tokens.denseCorners(
const BorderRadius.all(Radius.circular(windowCornerRadius)),
);
const designed = BorderRadius.all(Radius.circular(windowCornerRadius));
return tokens.glass == null
? tokens.denseCorners(designed)
: tokens.corners(designed);
}
/// The height of a window's title bar: a compact row of icon buttons, taller
@@ -62,12 +63,15 @@ class WindowFrame extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colors = theme.colorScheme;
// A glass design's window is an opaque glass card (its content is not
// blurred, so nothing behind may show through).
final glass = AppDesignTokens.of(context).glass;
final dense = AppDesignTokens.of(context).density.dense;
return Material(
elevation: 8,
clipBehavior: Clip.antiAlias,
borderRadius: windowCorners(context),
color: colors.surfaceContainer,
color: glass?.solid ?? colors.surfaceContainer,
child: Align(
alignment: Alignment.topCenter,
child: SizedBox(
@@ -161,12 +165,23 @@ class WindowOutline extends StatelessWidget {
final side = tokens.stroke > 1
? tokens.frameSide ?? BorderSide(color: colors.outlineVariant)
: BorderSide(color: colors.outlineVariant);
final corners = windowCorners(context);
final glass = tokens.glass;
return IgnorePointer(
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.fromBorderSide(side),
borderRadius: windowCorners(context),
),
// A glass window's edge catches the light along its title bar.
decoration: glass == null
? BoxDecoration(
border: Border.fromBorderSide(side),
borderRadius: corners,
)
: ShapeDecoration(
shape: GlassBorder(
borderRadius: corners,
highlight: glass.highlight,
edge: colors.outlineVariant,
),
),
child: const SizedBox.expand(),
),
);
+11 -2
View File
@@ -71,9 +71,18 @@ class GlassPill extends StatelessWidget {
final Color base;
final Color edge;
final scheme = Theme.of(context).colorScheme;
base = tokens.panelFill(scheme, scheme.surfaceContainerHigh);
// A glass design names its bars' own tint (already translucent) and an
// opaque stand-in for high contrast.
final glass = tokens.glass;
base = glass == null
? tokens.panelFill(scheme, scheme.surfaceContainerHigh)
: solid
? glass.solid
: glass.bar;
edge = flat ? tokens.frame ?? scheme.outline : scheme.outlineVariant;
final opaque = fill ?? (solid ? base : base.withValues(alpha: fillOpacity));
final opaque =
fill ??
(solid || glass != null ? base : base.withValues(alpha: fillOpacity));
final color = opaque.withValues(alpha: opaque.a * reveal);
final look = GlassLook.forFill(opaque);
Color faded(Color c, [double by = 1]) =>
+19
View File
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../theme/app_design_tokens.dart';
import '../theme/high_contrast_palette.dart';
import 'app_list_avatar.dart';
import 'app_list_row_glow.dart';
/// Below this row width (a list pane squeezed beside its detail) a row is
/// compact: it keeps its avatar (a run's status) and its menu, so no row
@@ -251,6 +252,24 @@ class AppListRow extends StatelessWidget {
final themed = invertible
? Theme(data: theme, child: content)
: content;
final glass = AppDesignTokens.of(context).glass;
if (rowStyle == SelectedRowStyle.glow && glass != null) {
return AppListRowGlow(
glass: glass,
selected: selected,
accent: frameColor,
tint: tint,
mark: selected || (showAccentBorder && accent != null),
surfaceKey: appListRowSurfaceKey,
markKey: selected ? appListRowSelectionKey : appListRowAccentKey,
child: InkWell(
key: tapKey,
onTap: onTap,
onLongPress: onLongPress,
child: themed,
),
);
}
final surface = Material(
key: appListRowSurfaceKey,
color: inverted
+137
View File
@@ -0,0 +1,137 @@
import 'package:flutter/material.dart';
import '../theme/app_design_tokens.dart';
/// The corner radius of a glass list row's slab.
const double kAppListRowGlowRadius = 14;
/// The gap around a glass row's slab: from the pane's sides and between
/// neighbouring rows.
const EdgeInsets kAppListRowGlowMargin = EdgeInsets.symmetric(
horizontal: 8,
vertical: 2,
);
/// An AppListRow under [SelectedRowStyle.glow] (Glass): the row is a slab
/// inset in the list with rounded corners instead of a full-width band. A
/// coloured row is a faint tint of its colour with a short rounded mark at
/// its start; the open row is a brighter glass slab with a 1px ring and a
/// soft glow in its accent.
class AppListRowGlow extends StatelessWidget {
const AppListRowGlow({
super.key,
required this.glass,
required this.selected,
required this.accent,
required this.tint,
required this.mark,
required this.surfaceKey,
required this.markKey,
required this.child,
});
final GlassStyle glass;
final bool selected;
/// The open row's ring and glow colour, and a coloured row's mark.
final Color accent;
/// An unselected coloured row's fill, or null for a clear row.
final Color? tint;
/// Whether the row shows its accent mark (an open row, or a coloured row
/// that marks its colour).
final bool mark;
final Key surfaceKey;
final Key markKey;
/// The row's ink (its tap target and content).
final Widget child;
static const BorderRadius _corners = BorderRadius.all(
Radius.circular(kAppListRowGlowRadius),
);
@override
Widget build(BuildContext context) {
final fill = selected
? Color.alphaBlend(accent.withValues(alpha: 0.08), glass.slab)
: tint ?? const Color(0x00000000);
final slab = Material(
key: surfaceKey,
color: fill,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: _corners,
side: selected
? BorderSide(color: accent.withValues(alpha: 0.55))
: BorderSide.none,
),
child: mark
? CustomPaint(
key: markKey,
foregroundPainter: _MarkPainter(
accent.withValues(alpha: selected ? 1 : 0.8),
end: Directionality.of(context) == TextDirection.rtl,
),
child: child,
)
: child,
);
return Padding(
padding: kAppListRowGlowMargin,
child: DecoratedBox(
// The glow falls outside the slab; inside it the slab's own fill
// covers most of it.
decoration: BoxDecoration(
borderRadius: _corners,
// One small blur: a CPU rasteriser redraws it every frame.
boxShadow: selected
? [
BoxShadow(
color: accent.withValues(alpha: glass.glow),
blurRadius: 10,
offset: const Offset(0, 1),
),
]
: null,
),
child: slab,
),
);
}
}
/// The short rounded accent mark at a glass row's start, centred on its
/// height.
class _MarkPainter extends CustomPainter {
const _MarkPainter(this.color, {required this.end});
final Color color;
/// Whether the row's start is its right edge (right-to-left).
final bool end;
static const double _width = 3;
static const double _inset = 5;
@override
void paint(Canvas canvas, Size size) {
final height = (size.height * 0.42).clamp(12.0, 28.0);
final rect = Rect.fromLTWH(
end ? size.width - _inset - _width : _inset,
(size.height - height) / 2,
_width,
height,
);
canvas.drawRRect(
RRect.fromRectAndRadius(rect, const Radius.circular(_width / 2)),
Paint()..color = color,
);
}
@override
bool shouldRepaint(_MarkPainter oldDelegate) =>
oldDelegate.color != color || oldDelegate.end != end;
}
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../theme/app_design_tokens.dart';
import 'container_transform_flight.dart';
import 'container_transform_gestures.dart';
import 'container_transform_source.dart';
@@ -83,7 +84,10 @@ class ContainerTransformPageRoute<T> extends PageRoute<T>
closing: () =>
animation.status == AnimationStatus.reverse || popGestureInProgress,
tracking: () => popGestureInProgress,
pageColor: Theme.of(context).scaffoldBackgroundColor,
// A glass design's pages are clear; the flight grows an opaque page.
pageColor:
AppDesignTokens.of(context).glass?.solid ??
Theme.of(context).scaffoldBackgroundColor,
scrimColor: Theme.of(context).colorScheme.scrim,
child: child,
);
+22
View File
@@ -5,6 +5,7 @@ import 'app_theme.dart';
import 'compact_theme.dart';
import 'crt_palette.dart';
import 'crt_theme.dart';
import 'glass_theme.dart';
import 'high_contrast_theme.dart';
import 'notebook_theme.dart';
import 'paper_theme.dart';
@@ -80,6 +81,14 @@ enum AppDesign {
'Pure black and white, large type, thick borders and big targets.',
),
/// Translucent frosted panes over a soft gradient: rounded cards, light
/// glass edges and gentle depth.
glass(
'glass',
'Glass',
'Frosted panes over a soft gradient, rounded cards and gentle depth.',
),
/// Terminal's structure on a monochrome tube: green phosphor shades, square
/// frames, a faint glow and static scanlines; [retroCrtAmber] is the same
/// design in amber.
@@ -150,6 +159,7 @@ enum AppDesign {
(compact, _) => compactTheme(brightness, fontFamily: fontFamily),
(notebook, _) => notebookTheme(brightness, fontFamily: fontFamily),
(highContrast, _) => highContrastTheme(brightness, fontFamily: fontFamily),
(glass, _) => glassTheme(brightness, fontFamily: fontFamily),
(retroCrt || retroCrtAmber, _) => crtTheme(crtPhosphor!, this, brightness),
};
@@ -235,6 +245,18 @@ enum AppDesign {
Color(0xFF000000),
Color(0xFF0040A0),
),
glass =>
dark
? const DesignSwatch(
Color(0xFF101220),
Color(0xFFE9E9F4),
Color(0xFFB9B0FF),
)
: const DesignSwatch(
Color(0xFFF2F3FA),
Color(0xFF1A1A2B),
Color(0xFF5546C7),
),
retroCrt || retroCrtAmber => () {
final ramp = CrtRamp(crtPhosphor!, brightness);
return DesignSwatch(ramp.page, ramp.text, ramp.accent);
+7 -2
View File
@@ -46,8 +46,9 @@ enum ComposerStyle {
cell,
}
/// How a list (AppListRow) marks the row that is open. Every style keeps
/// the leading bar in the row's accent; they differ in the fill and frame.
/// How a list (AppListRow) marks the row that is open. Every style but
/// [glow] keeps the leading bar in the row's accent; they differ in the fill
/// and frame.
enum SelectedRowStyle {
/// Material's tonal `secondaryContainer` fill (Classic).
tonal,
@@ -59,6 +60,10 @@ enum SelectedRowStyle {
/// The accent washed over the page, without a frame (Paper).
washed,
/// A brighter glass slab inset in the list, in the design's corners, with
/// a soft glow ring in the accent instead of a leading bar (Glass).
glow,
/// The row inverted: the ink as its fill and the page as its text, with a
/// thick bar (High contrast).
inverted,
+39 -4
View File
@@ -2,8 +2,11 @@ import 'package:flutter/material.dart';
import 'app_design.dart';
import 'app_design_styles.dart';
import 'glass_style.dart';
export 'app_design_styles.dart';
export 'glass_border.dart';
export 'glass_style.dart';
/// The muted ANSI-style accents a design names for status and roles. The
/// Classic design leaves them to its colour scheme; Terminal sets them, and
@@ -74,6 +77,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
this.minContrast,
this.windowRadius,
this.snapSwitch = false,
this.glass,
this.density = DesignDensity.comfortable,
});
@@ -162,6 +166,11 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
/// designs to blend from ([AppDesignController.themeAnimationDuration]).
final bool snapSwitch;
/// A glass design's translucent surfaces: the backdrop behind the app, the
/// panes' and bars' tints, the inset cards' fill and edge, and how its
/// corners grow. Null for an opaque design (every surface keeps its fill).
final GlassStyle? glass;
/// How tightly the interface is packed: spacing, icon and avatar sizes,
/// the rail and the window title bar ([DesignDensity.compact] for Compact).
final DesignDensity density;
@@ -188,16 +197,29 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
/// [designed] as this design draws it: the widget's own shape, or a
/// rectangle with [radius] corners.
/// A glass design keeps the widget's shape with its corners grown
/// ([GlassStyle.corner]); a stadium or circle stays one.
OutlinedBorder shape(OutlinedBorder designed) {
final r = radius;
if (r == null) return designed;
return RoundedRectangleBorder(borderRadius: BorderRadius.circular(r));
if (r != null) {
return RoundedRectangleBorder(borderRadius: BorderRadius.circular(r));
}
final glass = this.glass;
if (glass != null && designed is RoundedRectangleBorder) {
final corners = designed.borderRadius;
if (corners is BorderRadius) {
return designed.copyWith(borderRadius: glass.corners(corners));
}
}
return designed;
}
/// [designed] corners, or [radius] corners under a design that sets it.
/// [designed] corners, or [radius] corners under a design that sets it,
/// or (glass) [designed] with each corner grown by [GlassStyle.corner].
BorderRadius corners(BorderRadius designed) {
final r = radius;
return r == null ? designed : BorderRadius.circular(r);
if (r != null) return BorderRadius.circular(r);
return glass?.corners(designed) ?? designed;
}
/// [designed] corners, or [radius] corners under a dense design: for the
@@ -210,6 +232,15 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
Color panelFill(ColorScheme scheme, Color designed) =>
flat ? panel ?? scheme.surfaceContainerLow : designed;
/// [fill] made opaque for a piece nothing may show through (a find bar
/// over the transcript, a terminal): under a glass design, whose container
/// colours are translucent, laid over its opaque [GlassStyle.solid];
/// unchanged elsewhere.
Color solidFill(Color fill) {
final glass = this.glass;
return glass == null ? fill : Color.alphaBlend(fill, glass.solid);
}
/// The hairline a flat design frames its panels with; null keeps none.
BorderSide? get frameSide {
final color = frame;
@@ -239,6 +270,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
double? minContrast,
double? windowRadius,
bool? snapSwitch,
GlassStyle? glass,
DesignDensity? density,
}) => AppDesignTokens(
design: design ?? this.design,
@@ -262,6 +294,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
minContrast: minContrast ?? this.minContrast,
windowRadius: windowRadius ?? this.windowRadius,
snapSwitch: snapSwitch ?? this.snapSwitch,
glass: glass ?? this.glass,
density: density ?? this.density,
);
@@ -292,6 +325,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
other.minContrast == minContrast &&
other.windowRadius == windowRadius &&
other.snapSwitch == snapSwitch &&
other.glass == glass &&
other.density == density;
@override
@@ -317,6 +351,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
minContrast,
windowRadius,
snapSwitch,
glass,
density,
]);
+116
View File
@@ -0,0 +1,116 @@
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'app_design_tokens.dart';
/// Paints a glass design's still gradient ([GlassStyle.backdrop]) behind
/// [child], the app's pages, whose scaffolds are clear under that design.
///
/// The gradient is its own layer behind a [RepaintBoundary]: it is recorded
/// when the window resizes or the design changes, never while content
/// scrolls or animates over it. Under any other design nothing is painted,
/// and the tree keeps the same shape, so switching designs never remounts
/// the app below.
class GlassBackdrop extends StatelessWidget {
const GlassBackdrop({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
final mesh = AppDesignTokens.of(context).glass?.backdrop;
return Stack(
fit: StackFit.expand,
children: [
RepaintBoundary(
child: CustomPaint(
key: const ValueKey('glass-backdrop'),
painter: mesh == null ? null : GlassMeshPainter(mesh),
),
),
child,
],
);
}
}
/// Paints a [GlassBackdropMesh]: its base, then each glow as a radial wash
/// that fades to nothing at its radius (a fraction of the longer side).
///
/// The mesh is smooth, so it is drawn once into a small image
/// ([meshImage], cached per mesh and window shape) and stretched over the
/// window: one filtered image draw per frame instead of a full-window
/// gradient per glow, which a CPU rasteriser redraws on every frame.
class GlassMeshPainter extends CustomPainter {
const GlassMeshPainter(this.mesh);
final GlassBackdropMesh mesh;
/// The cached image's longer side, in pixels.
static const int imageExtent = 96;
static final Map<(GlassBackdropMesh, int, int), ui.Image> _images = {};
/// [mesh] drawn at [imageExtent] along the longer side of a window shaped
/// like [size]; the same image for the same mesh and shape.
static ui.Image meshImage(GlassBackdropMesh mesh, Size size) {
final landscape = size.width >= size.height;
final ratio = landscape ? size.height / size.width : size.width / size.height;
final short = (imageExtent * ratio).round().clamp(8, imageExtent);
final width = landscape ? imageExtent : short;
final height = landscape ? short : imageExtent;
final key = (mesh, width, height);
final cached = _images[key];
if (cached != null) return cached;
// Only a few shapes are ever live (a window, a phone in two
// orientations); drop the oldest rather than grow.
if (_images.length >= 8) _images.remove(_images.keys.first);
final recorder = ui.PictureRecorder();
paintMesh(
Canvas(recorder),
Size(width.toDouble(), height.toDouble()),
mesh,
);
final picture = recorder.endRecording();
final image = picture.toImageSync(width, height);
picture.dispose();
return _images[key] = image;
}
/// Paints [mesh] over [size] directly: the base and each glow.
static void paintMesh(Canvas canvas, Size size, GlassBackdropMesh mesh) {
final rect = Offset.zero & size;
canvas.drawRect(rect, Paint()..color = mesh.base);
final reach = size.longestSide;
for (final glow in mesh.glows) {
final center = glow.center.withinRect(rect);
final radius = glow.radius * reach;
final paint = Paint()
..shader = RadialGradient(
colors: [
glow.color,
glow.color.withValues(alpha: glow.color.a * 0.55),
glow.color.withValues(alpha: 0),
],
stops: const [0, 0.45, 1],
).createShader(Rect.fromCircle(center: center, radius: radius));
canvas.drawRect(rect, paint);
}
}
@override
void paint(Canvas canvas, Size size) {
if (size.isEmpty) return;
final image = meshImage(mesh, size);
canvas.drawImageRect(
image,
Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble()),
Offset.zero & size,
Paint()..filterQuality = FilterQuality.low,
);
}
@override
bool shouldRepaint(GlassMeshPainter oldDelegate) => oldDelegate.mesh != mesh;
}
+137
View File
@@ -0,0 +1,137 @@
import 'package:flutter/painting.dart';
/// The edge of a glass surface: a rounded rectangle whose 1px line is a
/// light [highlight] along its top that falls off into a faint [edge] by
/// mid-height, like light catching the top of a pane of glass.
///
/// A [side] set on it (a focus ring, a widget's own outline through
/// `copyWith`) is drawn instead, as a [RoundedRectangleBorder] draws it.
/// Value-equal, so a theme holding it stays equal when rebuilt.
class GlassBorder extends OutlinedBorder {
const GlassBorder({
this.borderRadius = BorderRadius.zero,
required this.highlight,
required this.edge,
super.side,
});
final BorderRadius borderRadius;
/// The line's colour at the very top.
final Color highlight;
/// The line's colour from mid-height down.
final Color edge;
@override
EdgeInsetsGeometry get dimensions =>
EdgeInsets.all(side.style == BorderStyle.none ? 0 : side.strokeInset);
RRect _rrect(Rect rect) => borderRadius.toRRect(rect);
@override
Path getInnerPath(Rect rect, {TextDirection? textDirection}) => Path()
..addRRect(_rrect(rect).deflate(side.strokeInset).scaleRadii());
@override
Path getOuterPath(Rect rect, {TextDirection? textDirection}) =>
Path()..addRRect(_rrect(rect));
@override
void paintInterior(
Canvas canvas,
Rect rect,
Paint paint, {
TextDirection? textDirection,
}) {
canvas.drawRRect(_rrect(rect), paint);
}
@override
bool get preferPaintInterior => true;
@override
void paint(Canvas canvas, Rect rect, {TextDirection? textDirection}) {
if (rect.isEmpty) return;
if (side.style != BorderStyle.none && side.width > 0) {
canvas.drawRRect(
_rrect(rect).inflate(side.strokeOffset / 2),
side.toPaint(),
);
return;
}
if (highlight.a == 0 && edge.a == 0) return;
final line = _rrect(rect).deflate(0.5);
canvas.drawRRect(
line,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..shader = LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [highlight, edge, edge],
// The highlight falls off within the top corners' reach (at most
// the top 24px), not over a tall card's whole height.
stops: [0, (28 / rect.height).clamp(0.05, 0.5), 1],
).createShader(rect),
);
}
@override
GlassBorder copyWith({
BorderSide? side,
BorderRadius? borderRadius,
Color? highlight,
Color? edge,
}) => GlassBorder(
borderRadius: borderRadius ?? this.borderRadius,
highlight: highlight ?? this.highlight,
edge: edge ?? this.edge,
side: side ?? this.side,
);
@override
ShapeBorder scale(double t) => GlassBorder(
borderRadius: borderRadius * t,
highlight: highlight,
edge: edge,
side: side.scale(t),
);
@override
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
if (a is GlassBorder) return _lerp(a, this, t);
return super.lerpFrom(a, t);
}
@override
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
if (b is GlassBorder) return _lerp(this, b, t);
return super.lerpTo(b, t);
}
static GlassBorder _lerp(GlassBorder a, GlassBorder b, double t) =>
GlassBorder(
borderRadius: BorderRadius.lerp(a.borderRadius, b.borderRadius, t)!,
highlight: Color.lerp(a.highlight, b.highlight, t)!,
edge: Color.lerp(a.edge, b.edge, t)!,
side: BorderSide.lerp(a.side, b.side, t),
);
@override
bool operator ==(Object other) =>
other is GlassBorder &&
other.borderRadius == borderRadius &&
other.highlight == highlight &&
other.edge == edge &&
other.side == side;
@override
int get hashCode => Object.hash(borderRadius, highlight, edge, side);
@override
String toString() =>
'GlassBorder($borderRadius, highlight: $highlight, edge: $edge, '
'side: $side)';
}
+158
View File
@@ -0,0 +1,158 @@
import 'package:flutter/material.dart';
import 'glass_theme.dart';
const Color _clear = Color(0x00000000);
// Kept per colour: a tab indicator compares by identity, so a fresh one
// would make a rebuilt theme unequal to the last
// (test/perf/design_bench_test.dart).
final Map<(Color, Color, Color), Decoration> _tabIndicators = {};
final Map<(Color, Color), WidgetStateProperty<Color?>> _segmentFills = {};
/// [base] with Glass's controls: pill buttons without elevation, glass
/// menus and fields in the design's radii, pill chips with a glass edge,
/// a frosted segmented button, a soft tab slab and thin progress.
ThemeData glassControls(ThemeData base, GlassSurfaces surfaces) {
final scheme = base.colorScheme;
final style = surfaces.style;
ButtonStyle flatter(ButtonStyle? s) => (s ?? const ButtonStyle()).copyWith(
elevation: const WidgetStatePropertyAll(0),
shadowColor: const WidgetStatePropertyAll(_clear),
);
final menu = MenuStyle(
backgroundColor: WidgetStatePropertyAll(surfaces.floating),
elevation: const WidgetStatePropertyAll(6),
shadowColor: WidgetStatePropertyAll(style.shadow),
surfaceTintColor: const WidgetStatePropertyAll(_clear),
shape: WidgetStatePropertyAll(surfaces.edge(GlassRadii.card)),
padding: const WidgetStatePropertyAll(EdgeInsets.all(6)),
);
const itemShape = RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(GlassRadii.small)),
);
const fieldCorners = BorderRadius.all(Radius.circular(GlassRadii.field));
final pill = surfaces.edge(GlassRadii.card);
return base.copyWith(
menuTheme: MenuThemeData(style: menu),
dropdownMenuTheme: DropdownMenuThemeData(menuStyle: menu),
menuButtonTheme: MenuButtonThemeData(
style: MenuItemButton.styleFrom(shape: itemShape),
),
filledButtonTheme: FilledButtonThemeData(
style: flatter(base.filledButtonTheme.style),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: flatter(base.elevatedButtonTheme.style).copyWith(
backgroundColor: WidgetStatePropertyAll(scheme.surfaceContainerHigh),
shape: WidgetStatePropertyAll(pill),
),
),
outlinedButtonTheme: OutlinedButtonThemeData(
style: flatter(base.outlinedButtonTheme.style).copyWith(
side: WidgetStatePropertyAll(BorderSide(color: scheme.outline)),
),
),
textButtonTheme: TextButtonThemeData(
style: flatter(base.textButtonTheme.style),
),
segmentedButtonTheme: SegmentedButtonThemeData(
style: flatter(base.segmentedButtonTheme.style).copyWith(
side: WidgetStatePropertyAll(BorderSide(color: style.edge)),
backgroundColor:
_segmentFills[(
scheme.secondaryContainer,
scheme.surfaceContainerLow,
)] ??= WidgetStateProperty.resolveWith(
(states) => states.contains(WidgetState.selected)
? scheme.secondaryContainer
: scheme.surfaceContainerLow,
),
),
),
floatingActionButtonTheme: FloatingActionButtonThemeData(
elevation: 4,
focusElevation: 4,
hoverElevation: 6,
highlightElevation: 6,
backgroundColor: style.solid,
foregroundColor: scheme.primary,
shape: surfaces.edge(GlassRadii.card),
),
chipTheme: ChipThemeData(
backgroundColor: scheme.surfaceContainerLow,
selectedColor: scheme.secondaryContainer,
shape: pill,
side: BorderSide.none,
elevation: 0,
pressElevation: 0,
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
),
// Only the base border: a field that sets `InputBorder.none` (the
// composer, whose frame is its pill) keeps none in every state.
inputDecorationTheme: InputDecorationTheme(
filled: false,
border: OutlineInputBorder(
borderRadius: fieldCorners,
borderSide: BorderSide(color: scheme.outline.withValues(alpha: 0.5)),
),
),
searchBarTheme: SearchBarThemeData(
elevation: const WidgetStatePropertyAll(0),
shape: WidgetStatePropertyAll(pill),
backgroundColor: WidgetStatePropertyAll(scheme.surfaceContainerHigh),
surfaceTintColor: const WidgetStatePropertyAll(_clear),
padding: const WidgetStatePropertyAll(
EdgeInsets.symmetric(horizontal: 14),
),
),
listTileTheme: const ListTileThemeData(shape: itemShape),
expansionTileTheme: const ExpansionTileThemeData(
shape: Border(),
collapsedShape: Border(),
),
tabBarTheme: TabBarThemeData(
dividerColor: _clear,
labelColor: scheme.onSurface,
unselectedLabelColor: scheme.onSurfaceVariant,
indicatorSize: TabBarIndicatorSize.tab,
indicator:
_tabIndicators[(
scheme.secondaryContainer,
style.highlight,
style.edge,
)] ??= ShapeDecoration(
color: scheme.secondaryContainer,
shape: surfaces.edge(GlassRadii.small),
),
splashBorderRadius: const BorderRadius.all(
Radius.circular(GlassRadii.small),
),
),
checkboxTheme: const CheckboxThemeData(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(5)),
),
),
sliderTheme: SliderThemeData(
trackHeight: 4,
inactiveTrackColor: scheme.surfaceContainerHighest,
),
badgeTheme: BadgeThemeData(
backgroundColor: scheme.primary,
textColor: scheme.onPrimary,
padding: const EdgeInsets.symmetric(horizontal: 5),
),
progressIndicatorTheme: ProgressIndicatorThemeData(
color: scheme.primary,
linearTrackColor: scheme.surfaceContainerHighest,
circularTrackColor: _clear,
linearMinHeight: 3,
borderRadius: const BorderRadius.all(Radius.circular(2)),
),
scrollbarTheme: const ScrollbarThemeData(
radius: Radius.circular(4),
thickness: WidgetStatePropertyAll(6),
),
);
}
+159
View File
@@ -0,0 +1,159 @@
import 'package:flutter/material.dart';
import 'app_design_tokens.dart';
/// Glass's status accents over its light panes: clear, slightly cool hues
/// that keep AA contrast on the frosted white.
const AnsiAccents glassLightAccents = AnsiAccents(
green: Color(0xFF1F7A4D),
cyan: Color(0xFF087185),
yellow: Color(0xFF8A6200),
red: Color(0xFFB3261E),
magenta: Color(0xFF9A3B8E),
blue: Color(0xFF3B54C9),
);
/// Glass's status accents over its dark panes.
const AnsiAccents glassDarkAccents = AnsiAccents(
green: Color(0xFF7FD8A6),
cyan: Color(0xFF7FD3E6),
yellow: Color(0xFFF0CD7A),
red: Color(0xFFFF9C94),
magenta: Color(0xFFE6A3E0),
blue: Color(0xFFA8B8FF),
);
/// Light glass: a pale lavender, peach, sky and mint mesh under frosted
/// white panes. The list pane's veil (white at 32%) is baked into the mesh's
/// colours, so the rail and the list draw no tint of their own: one image
/// draw per frame, not a full-window blend on top of it.
const GlassStyle glassLightStyle = GlassStyle(
backdrop: GlassBackdropMesh(
base: Color(0xFFF2F3FA),
glows: [
GlassGlow(Alignment(-1, -1), 0.95, Color(0xFFE5DFFF)),
GlassGlow(Alignment(1, -0.85), 0.8, Color(0xFFFFE7DC)),
GlassGlow(Alignment(-0.8, 1), 0.85, Color(0xFFDAECFF)),
GlassGlow(Alignment(1, 1), 0.75, Color(0xFFDDF4EB)),
],
),
rail: Color(0x00000000),
pane: Color(0x00000000),
detail: Color(0x80FFFFFF),
bar: Color(0xB8FCFCFF),
solid: Color(0xFFF7F7FC),
card: Color(0x9EFFFFFF),
highlight: Color(0xFFFFFFFF),
edge: Color(0x1C2A2A66),
shadow: Color(0x1F2E2A66),
slab: Color(0xE6FFFFFF),
glow: 0.45,
);
/// Dark glass: a deep indigo, plum, teal and night-blue mesh under smoked
/// glass panes, the list pane's smoke (30%) baked into its colours.
const GlassStyle glassDarkStyle = GlassStyle(
backdrop: GlassBackdropMesh(
base: Color(0xFF101220),
glows: [
GlassGlow(Alignment(-1, -1), 0.95, Color(0xFF242254)),
GlassGlow(Alignment(1, -0.85), 0.8, Color(0xFF2F1B41)),
GlassGlow(Alignment(-0.8, 1), 0.85, Color(0xFF102E3D)),
GlassGlow(Alignment(1, 1), 0.75, Color(0xFF16254B)),
],
),
rail: Color(0x00000000),
pane: Color(0x00000000),
detail: Color(0x8C121524),
bar: Color(0xC2262A40),
solid: Color(0xFF1C1F31),
card: Color(0x80303552),
highlight: Color(0x47FFFFFF),
edge: Color(0x1AFFFFFF),
shadow: Color(0x66000000),
slab: Color(0xB8363B5C),
glow: 0.5,
);
/// Glass's colour scheme. The page roles ([ColorScheme.surface]) are opaque
/// (widgets blend with them), while the container roles are translucent
/// tints, so a settings group, a code block or a bubble is a pane of glass
/// over the backdrop rather than a grey block. One violet accent.
ColorScheme glassColorScheme(Brightness brightness) {
if (brightness == Brightness.dark) {
return const ColorScheme(
brightness: Brightness.dark,
primary: Color(0xFFB9B0FF),
onPrimary: Color(0xFF231B63),
primaryContainer: Color(0xFF3B3480),
onPrimaryContainer: Color(0xFFE4DFFF),
secondary: Color(0xFFC3C2DD),
onSecondary: Color(0xFF2B2B43),
secondaryContainer: Color(0x8C454A70),
onSecondaryContainer: Color(0xFFE4E3F7),
tertiary: Color(0xFFF2B8D8),
onTertiary: Color(0xFF4B1D39),
tertiaryContainer: Color(0xFF5E2E4C),
onTertiaryContainer: Color(0xFFFFD8EC),
error: Color(0xFFFFB4AB),
onError: Color(0xFF690005),
errorContainer: Color(0xFF93000A),
onErrorContainer: Color(0xFFFFDAD6),
surface: Color(0xFF141627),
onSurface: Color(0xFFE9E9F4),
onSurfaceVariant: Color(0xFFB9BAD0),
surfaceDim: Color(0xFF101220),
surfaceBright: Color(0xFF3A3E5C),
surfaceContainerLowest: Color(0x99101222),
surfaceContainerLow: Color(0x6B2A2E48),
surfaceContainer: Color(0x7A2E3250),
surfaceContainerHigh: Color(0x8C343857),
surfaceContainerHighest: Color(0x9E3C4163),
outline: Color(0xFF8A8BA6),
outlineVariant: Color(0x24FFFFFF),
shadow: Color(0xFF000000),
scrim: Color(0xFF05060C),
inverseSurface: Color(0xFFE9E9F4),
onInverseSurface: Color(0xFF22243A),
inversePrimary: Color(0xFF5546C7),
surfaceTint: Color(0x00000000),
);
}
return const ColorScheme(
brightness: Brightness.light,
primary: Color(0xFF5546C7),
onPrimary: Color(0xFFFFFFFF),
primaryContainer: Color(0xFFE3DEFF),
onPrimaryContainer: Color(0xFF1F1566),
secondary: Color(0xFF5B5B78),
onSecondary: Color(0xFFFFFFFF),
secondaryContainer: Color(0xB8E3E1F5),
onSecondaryContainer: Color(0xFF1C1C33),
tertiary: Color(0xFFA23B72),
onTertiary: Color(0xFFFFFFFF),
tertiaryContainer: Color(0xFFFFD8EA),
onTertiaryContainer: Color(0xFF3E0627),
error: Color(0xFFB3261E),
onError: Color(0xFFFFFFFF),
errorContainer: Color(0xFFFCDAD6),
onErrorContainer: Color(0xFF410E0B),
surface: Color(0xFFF1F1F9),
onSurface: Color(0xFF1A1A2B),
onSurfaceVariant: Color(0xFF4A4A63),
surfaceDim: Color(0xFFDCDCEA),
surfaceBright: Color(0xFFFFFFFF),
surfaceContainerLowest: Color(0xD9FFFFFF),
surfaceContainerLow: Color(0x8CFFFFFF),
surfaceContainer: Color(0x9EFBFBFF),
surfaceContainerHigh: Color(0xB3F6F6FC),
surfaceContainerHighest: Color(0xC7EDECF7),
outline: Color(0xFF7F7F99),
outlineVariant: Color(0x262A2A66),
shadow: Color(0xFF1E1A4D),
scrim: Color(0xFF0E0C26),
inverseSurface: Color(0xFF2A2A40),
onInverseSurface: Color(0xFFF1F1F9),
inversePrimary: Color(0xFFC5BCFF),
surfaceTint: Color(0x00000000),
);
}
+173
View File
@@ -0,0 +1,173 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
/// One soft glow of a [GlassBackdropMesh]: a radial wash of [color] centred
/// at [center] (alignment over the window) reaching [radius] of the window's
/// longer side, fading to nothing at its edge.
@immutable
class GlassGlow {
const GlassGlow(this.center, this.radius, this.color);
final Alignment center;
final double radius;
final Color color;
@override
bool operator ==(Object other) =>
other is GlassGlow &&
other.center == center &&
other.radius == radius &&
other.color == color;
@override
int get hashCode => Object.hash(center, radius, color);
}
/// The still gradient a glass design paints behind the whole app: a [base]
/// with a few large, soft [glows] laid over it, like a mesh gradient. It is
/// painted once per page and never animates.
@immutable
class GlassBackdropMesh {
const GlassBackdropMesh({required this.base, required this.glows});
final Color base;
final List<GlassGlow> glows;
@override
bool operator ==(Object other) =>
other is GlassBackdropMesh &&
other.base == base &&
listEquals(other.glows, glows);
@override
int get hashCode => Object.hash(base, Object.hashAll(glows));
}
/// A glass design's translucent surfaces ([AppDesignTokens.glass]): what it
/// paints behind the app, the tints of its panes and bars, the fill and edge
/// of the cards inset in them, the glow of an open row, and how far it grows
/// the corners widgets draw.
///
/// Only the bars, the composer and floating pieces blur what is behind them
/// (`GlassPill`); panes, cards and bubbles are tints over the backdrop, so
/// a list or a transcript scrolls without any backdrop filter.
@immutable
class GlassStyle {
const GlassStyle({
required this.backdrop,
required this.rail,
required this.pane,
required this.detail,
required this.bar,
required this.solid,
required this.card,
required this.highlight,
required this.edge,
required this.shadow,
required this.slab,
this.glow = 0.4,
this.cornerScale = 1.5,
this.cornerCap = 20,
});
/// The gradient behind every page.
final GlassBackdropMesh backdrop;
/// The navigation rail's tint over the backdrop; clear when the backdrop
/// already carries it.
final Color rail;
/// A list pane's tint over the backdrop; clear when the backdrop already
/// carries it (cheaper: no full-window blend per frame).
final Color pane;
/// The open item's (reading) pane: a stronger tint, so long text reads on
/// an even ground.
final Color detail;
/// The fill of a frosted bar, the composer and floating pieces, over the
/// blur of what is behind them.
final Color bar;
/// An opaque stand-in for the translucent fills where nothing may show
/// through (high contrast, a piece floating over unrelated content).
final Color solid;
/// The fill of a glass card inset in a pane: code blocks, follow-up notes,
/// the tool-activity chip.
final Color card;
/// The thin light line along a glass surface's top edge.
final Color highlight;
/// The faint hairline around the rest of a glass surface.
final Color edge;
/// The soft shadow under a raised glass surface.
final Color shadow;
/// The open list row's brighter slab.
final Color slab;
/// How strong an open row's glow ring is, as the accent's alpha.
final double glow;
/// How much a widget's own corner radius grows (outer > inner is kept:
/// every radius grows by the same factor), up to [cornerCap]; a radius
/// already past the cap is kept.
final double cornerScale;
final double cornerCap;
/// [radius] grown by [cornerScale] up to [cornerCap].
double corner(double radius) {
if (radius >= cornerCap) return radius;
final grown = radius * cornerScale;
return grown > cornerCap ? cornerCap : grown;
}
/// [designed] with every corner grown by [corner].
BorderRadius corners(BorderRadius designed) => BorderRadius.only(
topLeft: _grow(designed.topLeft),
topRight: _grow(designed.topRight),
bottomLeft: _grow(designed.bottomLeft),
bottomRight: _grow(designed.bottomRight),
);
Radius _grow(Radius r) => Radius.elliptical(corner(r.x), corner(r.y));
@override
bool operator ==(Object other) =>
other is GlassStyle &&
other.backdrop == backdrop &&
other.rail == rail &&
other.pane == pane &&
other.detail == detail &&
other.bar == bar &&
other.solid == solid &&
other.card == card &&
other.highlight == highlight &&
other.edge == edge &&
other.shadow == shadow &&
other.slab == slab &&
other.glow == glow &&
other.cornerScale == cornerScale &&
other.cornerCap == cornerCap;
@override
int get hashCode => Object.hash(
backdrop,
rail,
pane,
detail,
bar,
solid,
card,
highlight,
edge,
shadow,
slab,
glow,
cornerScale,
cornerCap,
);
}
+215
View File
@@ -0,0 +1,215 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'app_design.dart';
import 'app_design_tokens.dart';
import 'app_theme.dart';
import 'glass_controls.dart';
import 'glass_palette.dart';
/// Glass's corner radii, outer to inner: a floating sheet or dialog, then a
/// menu or card, then a field or a small card inside them, then a tooltip.
abstract final class GlassRadii {
static const double sheet = 20;
static const double card = 16;
static const double field = 14;
static const double small = 10;
}
/// The reading type: the interface sans a little roomier than Material's
/// body line, so long answers breathe on the glass.
const ReadingType glassReading = ReadingType(height: 1.55);
const Color _clear = Color(0x00000000);
/// Glass's surfaces for one brightness: the [GlassStyle] tints and the
/// glass edges every themed component shares.
class GlassSurfaces {
const GlassSurfaces(this.scheme, this.style);
final ColorScheme scheme;
final GlassStyle style;
bool get dark => scheme.brightness == Brightness.dark;
/// A floating piece's fill (menus, dialogs, sheets): nearly opaque, as
/// nothing behind it is blurred, so its text keeps its contrast over any
/// content.
Color get floating => style.solid.withValues(alpha: dark ? 0.96 : 0.94);
/// A glass edge in [radius] corners.
GlassBorder edge(double radius) => GlassBorder(
borderRadius: BorderRadius.all(Radius.circular(radius)),
highlight: style.highlight,
edge: style.edge,
);
/// The top-edge-only variant for a sheet rising from the bottom.
GlassBorder get sheetEdge => GlassBorder(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(GlassRadii.sheet),
),
highlight: style.highlight,
edge: style.edge,
);
}
/// The Glass design's theme: a soft mesh gradient behind the app
/// ([GlassBackdrop]), clear scaffolds, translucent container roles,
/// frosted bars, rounded floating pieces (14–20px) with a light top edge
/// and gentle layered shadows, the interface sans with a little more
/// weight in titles, and one violet accent. Bubbles, code blocks and cards
/// are tints over the backdrop: only bars, the composer and floating pieces
/// blur ([GlassPill]).
ThemeData glassTheme(Brightness brightness, {String? fontFamily}) {
final dark = brightness == Brightness.dark;
final scheme = glassColorScheme(brightness);
final style = dark ? glassDarkStyle : glassLightStyle;
final surfaces = GlassSurfaces(scheme, style);
final base = ThemeData(
platform: kIsWeb ? TargetPlatform.android : null,
colorScheme: scheme,
fontFamily: fontFamily,
// Clear: the backdrop behind the app shows through every page.
scaffoldBackgroundColor: _clear,
canvasColor: surfaces.floating,
pageTransitionsTheme: appPageTransitions,
dividerColor: scheme.outlineVariant,
shadowColor: style.shadow,
extensions: [
AppDesignTokens(
design: AppDesign.glass,
ansi: dark ? glassDarkAccents : glassLightAccents,
selectedRow: SelectedRowStyle.glow,
reading: glassReading,
glass: style,
// A live switch snaps: a blend half-way between clear glass pages
// and an opaque design re-rasterises the whole translucent stack
// every frame, and in the browser (skwasm) it could stall.
snapSwitch: true,
),
],
);
final text = glassTextTheme(base.textTheme);
return glassControls(
base.copyWith(
textTheme: text,
primaryTextTheme: glassTextTheme(base.primaryTextTheme),
appBarTheme: AppBarTheme(
backgroundColor: _clear,
foregroundColor: scheme.onSurface,
surfaceTintColor: _clear,
elevation: 0,
scrolledUnderElevation: 0,
),
// Only the glass edge and corners: each card variant keeps its own
// fill, so a selected graph node still reads apart.
cardTheme: CardThemeData(
elevation: 0,
shadowColor: _clear,
surfaceTintColor: _clear,
shape: surfaces.edge(GlassRadii.card),
),
dialogTheme: DialogThemeData(
backgroundColor: surfaces.floating,
surfaceTintColor: _clear,
elevation: 8,
shadowColor: style.shadow,
shape: surfaces.edge(GlassRadii.sheet),
),
bottomSheetTheme: BottomSheetThemeData(
backgroundColor: surfaces.floating,
modalBackgroundColor: surfaces.floating,
surfaceTintColor: _clear,
elevation: 8,
modalElevation: 8,
shadowColor: style.shadow,
shape: surfaces.sheetEdge,
dragHandleColor: scheme.outline,
),
popupMenuTheme: PopupMenuThemeData(
color: surfaces.floating,
surfaceTintColor: _clear,
elevation: 6,
shadowColor: style.shadow,
shape: surfaces.edge(GlassRadii.card),
),
snackBarTheme: SnackBarThemeData(
backgroundColor: scheme.inverseSurface.withValues(alpha: 0.94),
contentTextStyle: base.textTheme.bodyMedium?.copyWith(
color: scheme.onInverseSurface,
),
actionTextColor: scheme.inversePrimary,
elevation: 6,
behavior: SnackBarBehavior.floating,
shape: GlassBorder(
borderRadius: const BorderRadius.all(
Radius.circular(GlassRadii.field),
),
highlight: dark ? const Color(0x99FFFFFF) : const Color(0x4DFFFFFF),
edge: _clear,
),
),
tooltipTheme: TooltipThemeData(
decoration: ShapeDecoration(
color: scheme.inverseSurface.withValues(alpha: 0.92),
shape: GlassBorder(
borderRadius: const BorderRadius.all(
Radius.circular(GlassRadii.small),
),
highlight: dark ? const Color(0x80FFFFFF) : const Color(0x40FFFFFF),
edge: _clear,
),
),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
textStyle: base.textTheme.bodySmall?.copyWith(
color: scheme.onInverseSurface,
),
),
dividerTheme: DividerThemeData(
color: scheme.outlineVariant,
thickness: 1,
space: 1,
),
navigationRailTheme: NavigationRailThemeData(
backgroundColor: _clear,
elevation: 0,
indicatorColor: style.slab,
),
navigationBarTheme: NavigationBarThemeData(
backgroundColor: style.bar,
elevation: 0,
indicatorColor: scheme.secondaryContainer,
surfaceTintColor: _clear,
),
drawerTheme: DrawerThemeData(
backgroundColor: surfaces.floating,
surfaceTintColor: _clear,
elevation: 8,
shadowColor: style.shadow,
),
textSelectionTheme: TextSelectionThemeData(
cursorColor: scheme.primary,
selectionColor: scheme.primary.withValues(alpha: dark ? 0.35 : 0.22),
selectionHandleColor: scheme.primary,
),
),
surfaces,
);
}
/// [base] for Glass: the interface sans throughout, titles and labels a
/// step heavier (semibold) so they hold on a light, busy ground.
TextTheme glassTextTheme(TextTheme base) {
TextStyle? semibold(TextStyle? style) =>
style?.copyWith(fontWeight: FontWeight.w600);
return base.copyWith(
headlineLarge: semibold(base.headlineLarge),
headlineMedium: semibold(base.headlineMedium),
headlineSmall: semibold(base.headlineSmall),
titleLarge: semibold(base.titleLarge),
titleMedium: semibold(base.titleMedium),
titleSmall: semibold(base.titleSmall),
labelLarge: semibold(base.labelLarge),
);
}
+131
View File
@@ -0,0 +1,131 @@
# Glass design
Translucent frosted panes over a soft, still gradient (Settings > Design >
Glass): the opposite of Terminal. A pale lavender/peach/sky/mint mesh by day,
a deep indigo/plum/teal/night-blue one by night; panes are tints over it,
floating pieces are rounded glass cards with a light top edge and soft
layered shadows, and the open list row is a bright slab with a glow in its
chat colour. The interface sans throughout, titles and labels semibold.
## Tokens
One new token, `AppDesignTokens.glass` (`GlassStyle?`, null for every other
design, so nothing else changes), plus one new row style:
- `glass.backdrop` (`GlassBackdropMesh`: a base and four `GlassGlow`s): the
still gradient `GlassBackdrop` paints behind every page from the three
`MaterialApp.builder`s. Its own `RepaintBoundary`; under other designs it
paints nothing and keeps the same tree shape, so a live switch never
remounts the app.
- `glass.rail`, `glass.pane`, `glass.detail`: the tints of the navigation
rail, a list pane and the open item's reading pane (`ListDetailPanes`).
Glass bakes the list's veil into the mesh colours (rail and pane are
clear: no full-window blend per frame) and tints only the reading pane.
- The mesh is drawn once into a 96px image per window shape
(`GlassMeshPainter.meshImage`) and stretched with low filtering: one image
draw per frame. Four full-window radial gradients per frame cost about
twice Default's raster time on the CPU path and stalled the fixture.
- `glass.bar`: the frosted fill of `GlassPill` (bars, composer, floating
pieces) over its blur; `glass.solid` the opaque stand-in (high contrast,
floating windows, find bars, the terminal, phone stack discs, the container
transform's page) through `AppDesignTokens.solidFill`.
- `glass.card`, `glass.highlight`, `glass.edge`, `glass.shadow`: inset glass
cards (tool chip, follow-up notes) and the `GlassBorder` edge: a 1px line
that is `highlight` at the top and falls off into `edge` within the top
corners.
- `glass.slab`, `glass.glow`: the open row's slab and the alpha of its glow
ring (`SelectedRowStyle.glow`, `AppListRowGlow`).
- `glass.cornerScale` (1.5) / `cornerCap` (20): `tokens.corners()` and
`tokens.shape()` grow every widget's own radius by the same factor up to
the cap (8 -> 12, 12 -> 18, 16 -> 20, 28 stays), so the outer > inner
hierarchy holds; stadiums and circles stay.
- `SelectedRowStyle.glow`: the row is a slab inset 8px from the pane's sides
and 2px from its neighbours, 14px corners; a coloured row is its faint
tint with a short rounded mark; the open row is `slab` washed 8% with the
accent, a 1px ring at 55% and a 16px glow at `glass.glow`.
Glass also sets `snapSwitch` (main's token): a live switch into or out of
Glass snaps instead of blending clear pages with an opaque design's (the
blend stalled skwasm in the browser bench).
Glass keeps `transcript: bubbles`, `composer: pill`, `radius: null` (each
widget keeps its own shape, grown), `flat: false`, and sets ANSI accents and
a roomier reading line (`ReadingType(height: 1.55)`).
## Colour scheme
`glass_palette.dart`: the page roles (`surface`, `inverseSurface`) are
opaque, because widgets blend with them; the container roles
(`surfaceContainer*`, `secondaryContainer`, `outlineVariant`) are
translucent, so a settings group, a code block, a bubble or a chip is a pane
of glass over the backdrop instead of a grey block. Scaffolds are clear.
`test/ui/theme/glass_design_test.dart` checks body text >= 7:1, muted text
and the accent >= 4.5:1 on every pane over the base and each glow at full
strength, in light and dark.
## Surfaces themed
- Backdrop behind every page, the rail, list and reading panes.
- Bars, composer and floating pieces: `GlassPill` with the glass bar tint
(the only blur: sigma `GlassPill.blurSigma`, one grouped filter per piece,
as Classic already has). Panes, rows, bubbles, cards and the transcript
never blur.
- Dialogs (20px), sheets (20px top), menus and popup menus (16px, 6px inner
padding, 10px item corners), cards (16px, each variant keeps its fill),
tooltips (10px, inverse glass), snack bars (floating, 14px), the FAB, chips
(pill, glass edge), search bar, fields (14px), segmented buttons, tab
slab, sliders, badges, progress: `glass_theme.dart`, `glass_controls.dart`.
- Chat: operator bubbles are frosted pills (translucent container tinted
with the chat colour, glass edge); agent text on the pane; code blocks are
inset glass cards (12px, glass edge); the tool-activity chip is a slim
glass card; follow-up and auto-continue notes are small glass cards; the
chat header is clear so the pane runs to the top.
- The open list row (`AppListRowGlow`).
- Floating windows: opaque glass card, corners 18px (frame, outline and page
clip agree), outline a `GlassBorder` catching light along the title bar.
- Phone chat stack discs and labels stay opaque (`solidFill`); the usage ring
follows the circular Send button (`radius` is null).
## Still default
- Graph nodes keep `Card.filled` / `Card.outlined` (now with the glass edge
and 16px corners from the card theme); the edge hover card is the inverse
surface in grown corners.
- Graph nodes in dark read as near-black cards (`Card.outlined` keeps the
opaque `surface`).
- The phone chat page keeps the workspace's opaque `surface` behind its
panes (it backs the chat swipe motion).
- Sticky section headings and the run detail's Input/Output strips paint the
opaque `surface` (they hide what scrolls under them).
- Native desktop page slides (Linux, Windows, macOS/iOS Cupertino) show the
page below through a clear page during the 200 ms slide; web and Android
use the zoom transition.
## Perf
Widget budget (`test/perf/design_bench_test.dart`): passes. Glass:
`scrollRebuildsPerRow` 93.1 (Default 83.5), `scrollLayersPerFrame` 11.0
(11.2), `scrollSaveLayersPerFrame` 7.3 (7.4), `switchFramesPerSwitch` 4.5
(4.5), no unrelated theme rebuilds; layers {opacity 438, clipRect 60,
clipPath 163} vs Default {443, 60, 167}.
Browser (`design_bench.mjs --designs glass`, skwasm, 3 repeats, medians;
mean build / raster ms per frame, Glass vs Default):
| scenario | CPU (no --gpu) | GPU (--gpu) |
| --- | --- | --- |
| scroll | 8.94 / 39.86 vs 8.69 / 35.84 | 1.82 / 2.50 vs 1.94 / 2.58 |
| switch | 8.91 / 42.51 vs 8.49 / 34.95 | 2.27 / 3.49 vs 1.74 / 2.57 |
| runs | 1.43 / 9.39 vs 1.49 / 7.63 | 1.70 / 1.53 vs 1.77 / 1.52 |
| graph | 2.06 / 19.14 vs 2.31 / 15.79 | 1.14 / 2.15 vs 1.14 / 2.22 |
| design | 6.78 / 20.35 vs 14.57 / 24.40 | 3.91 / 2.09 vs 10.36 / 7.72 |
Both PASS; heap growth over 120 live switches 0.43 MB (Default 0.63); no
off-origin request beyond Default's own (Roboto, Noto Sans Symbols).
## Captures
`/tmp/glass-review/final-{light,dark}-{1440,560}/` (01 chat with tool chip,
bubbles, code card and the composer's usage ring, 02 activity dialog, 03
follow-up notes, 04 runs, 05 run 7, 06 run graph, 07 pipelines, 08
settings, 09 the design picker), recipe `/tmp/glass-review/cap.sh`.
@@ -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>());
});
}
@@ -0,0 +1,91 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/ui/layout/app_list_row_glow.dart';
import 'package:pipelines_app/ui/theme/app_design.dart';
import 'package:pipelines_app/ui/theme/app_design_tokens.dart';
Widget _host(AppDesign design, List<Widget> rows) => MaterialApp(
theme: design.light(),
home: Scaffold(body: ListView(children: rows)),
);
AppListRow _row(String key, {bool selected = false, Color? accent}) =>
AppListRow(
key: Key(key),
selected: selected,
accent: accent,
onTap: () {},
title: Text(key),
subtitle: const Text('a line of facts'),
);
Finder _in(String key, Finder finder) =>
find.descendant(of: find.byKey(Key(key)), matching: finder);
void main() {
testWidgets('Glass: the open row is a brighter slab with a ring and a '
'glow in its accent, inset with rounded corners', (tester) async {
const teal = Color(0xFF00796B);
await tester.pumpWidget(
_host(AppDesign.glass, [
_row('open', selected: true, accent: teal),
_row('coloured', accent: teal),
_row('plain'),
]),
);
final context = tester.element(find.byKey(const Key('open')));
final glass = AppDesignTokens.of(context).glass!;
expect(_in('open', find.byType(AppListRowGlow)), findsOneWidget);
final open = tester.widget<Material>(
_in('open', find.byKey(appListRowSurfaceKey)),
);
final shape = open.shape! as RoundedRectangleBorder;
expect(
shape.borderRadius,
const BorderRadius.all(Radius.circular(kAppListRowGlowRadius)),
);
expect(shape.side.color.r, closeTo(teal.r, 0.01));
// Brighter than the pane: the slab, washed a little with the accent.
expect(open.color, Color.alphaBlend(teal.withValues(alpha: 0.08), glass.slab));
final glow = tester
.widget<DecoratedBox>(
find
.ancestor(
of: _in('open', find.byKey(appListRowSurfaceKey)),
matching: find.byType(DecoratedBox),
)
.first,
)
.decoration as BoxDecoration;
expect(glow.boxShadow!.first.color, teal.withValues(alpha: glass.glow));
expect(_in('open', find.byKey(appListRowSelectionKey)), findsOneWidget);
// A coloured row is a faint tint with its mark; a plain row is clear.
final coloured = tester.widget<Material>(
_in('coloured', find.byKey(appListRowSurfaceKey)),
);
expect(coloured.color, AppListRow.tintFor(context, teal));
expect(_in('coloured', find.byKey(appListRowAccentKey)), findsOneWidget);
final plain = tester.widget<Material>(
_in('plain', find.byKey(appListRowSurfaceKey)),
);
expect(plain.color!.a, 0);
// The slab sits inset from the pane's sides.
final row = tester.getRect(find.byKey(const Key('open')));
final slab = tester.getRect(_in('open', find.byKey(appListRowSurfaceKey)));
expect(slab.left - row.left, kAppListRowGlowMargin.left);
expect(row.right - slab.right, kAppListRowGlowMargin.right);
});
testWidgets('other designs never draw a glass row', (tester) async {
for (final design in AppDesign.values.where((d) => d != AppDesign.glass)) {
await tester.pumpWidget(
_host(design, [_row('open', selected: true)]),
);
expect(find.byType(AppListRowGlow), findsNothing, reason: design.label);
}
});
}
@@ -108,7 +108,10 @@ void main() {
AppDesign.paper,
AppDesign.notebook,
AppDesign.highContrast,
// Glass snaps in and out (snapSwitch), to and from Compact too.
AppDesign.glass,
AppDesign.compact,
AppDesign.glass,
AppDesign.retroCrt,
AppDesign.retroCrtAmber,
]) {
+193
View File
@@ -0,0 +1,193 @@
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/theme/app_design.dart';
import 'package:pipelines_app/ui/theme/app_design_tokens.dart';
import 'package:pipelines_app/ui/theme/glass_backdrop.dart';
import 'package:pipelines_app/ui/theme/glass_palette.dart';
ThemeData _theme(AppDesign design, Brightness brightness) =>
brightness == Brightness.dark ? design.dark() : design.light();
AppDesignTokens _tokens(AppDesign design, Brightness brightness) =>
_theme(design, brightness).extension<AppDesignTokens>() ??
AppDesignTokens.standard;
double _contrast(Color a, Color b) {
final la = a.computeLuminance(), lb = b.computeLuminance();
return (math.max(la, lb) + 0.05) / (math.min(la, lb) + 0.05);
}
/// Every colour the backdrop can show at a point: its base and each glow at
/// full strength (the worst cases), composited under [tints] in order.
List<Color> _grounds(GlassStyle style, List<Color> tints) => [
for (final under in [
style.backdrop.base,
for (final glow in style.backdrop.glows)
Color.alphaBlend(glow.color, style.backdrop.base),
])
tints.fold(under, (ground, tint) => Color.alphaBlend(tint, ground)),
];
void main() {
test('Glass is listed with a stable id, a label and one line', () {
expect(AppDesign.values, contains(AppDesign.glass));
expect(AppDesign.fromId('glass'), AppDesign.glass);
expect(AppDesign.glass.label, 'Glass');
expect(AppDesign.glass.description, isNot(contains('\n')));
expect(AppDesign.glass.usesInterfaceFont, isTrue);
});
test('Glass tokens: bubbles and a pill composer on glass, a glowing open '
'row, no flat frames, corners grown with the hierarchy kept', () {
for (final brightness in Brightness.values) {
final theme = _theme(AppDesign.glass, brightness);
final tokens = theme.extension<AppDesignTokens>()!;
expect(tokens.design, AppDesign.glass);
expect(tokens.transcript, TranscriptStyle.bubbles);
expect(tokens.composer, ComposerStyle.pill);
expect(tokens.selectedRow, SelectedRowStyle.glow);
expect(tokens.flat, isFalse);
expect(tokens.radius, isNull);
expect(tokens.frame, isNull);
expect(tokens.snapSwitch, isTrue);
expect(tokens.ansi, isNotNull);
expect(tokens.reading.family, isNull, reason: 'the interface sans');
expect(tokens.reading.height, greaterThan(1.4));
final glass = tokens.glass!;
expect(glass, brightness == Brightness.dark ? glassDarkStyle : glassLightStyle);
// Outer > inner: each widget's own radius grows by the same factor up
// to the cap, so nesting order is kept.
expect(tokens.corners(BorderRadius.circular(4)), BorderRadius.circular(6));
expect(tokens.corners(BorderRadius.circular(8)), BorderRadius.circular(12));
expect(tokens.corners(BorderRadius.circular(16)), BorderRadius.circular(20));
expect(tokens.corners(BorderRadius.circular(28)), BorderRadius.circular(28));
expect(tokens.shape(const StadiumBorder()), const StadiumBorder());
expect(tokens.shape(const CircleBorder()), const CircleBorder());
expect(
tokens.shape(
const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(12)),
),
),
const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(18)),
),
);
// Pages are clear over the backdrop; floating pieces nearly opaque.
expect(theme.scaffoldBackgroundColor.a, 0);
expect(theme.dialogTheme.backgroundColor!.a, greaterThan(0.9));
expect(theme.popupMenuTheme.color!.a, greaterThan(0.9));
expect(theme.dialogTheme.shape, isA<GlassBorder>());
expect(theme.popupMenuTheme.shape, isA<GlassBorder>());
expect(theme.cardTheme.shape, isA<GlassBorder>());
// Containers are glass tints; the page roles stay opaque for blends.
expect(theme.colorScheme.surfaceContainerHigh.a, lessThan(1));
expect(theme.colorScheme.surface.a, 1);
expect(glass.solid.a, 1);
}
});
test('other designs keep their tokens and corners (no glass)', () {
for (final design in AppDesign.values.where((d) => d != AppDesign.glass)) {
for (final brightness in Brightness.values) {
final tokens = _tokens(design, brightness);
expect(tokens.glass, isNull, reason: design.label);
expect(tokens.selectedRow, isNot(SelectedRowStyle.glow));
final designed = BorderRadius.circular(8);
expect(
tokens.corners(designed),
tokens.radius == null ? designed : BorderRadius.circular(tokens.radius!),
);
expect(tokens.solidFill(const Color(0x80FFFFFF)), const Color(0x80FFFFFF));
expect(_theme(design, brightness).scaffoldBackgroundColor.a, 1);
}
}
expect(_tokens(AppDesign.standard, Brightness.light), AppDesignTokens.standard);
});
test('Glass body text keeps WCAG AA over every part of the backdrop', () {
for (final brightness in Brightness.values) {
final theme = _theme(AppDesign.glass, brightness);
final scheme = theme.colorScheme;
final glass = theme.extension<AppDesignTokens>()!.glass!;
final surfaces = <String, List<Color>>{
'rail': _grounds(glass, [glass.rail]),
'list pane': _grounds(glass, [glass.pane]),
'reading pane': _grounds(glass, [glass.detail]),
'card in the reading pane': _grounds(glass, [glass.detail, glass.card]),
'bubble': _grounds(glass, [
glass.detail,
scheme.surfaceContainerHighest,
]),
'bar': _grounds(glass, [glass.bar]),
'open row': _grounds(glass, [glass.pane, glass.slab]),
};
for (final MapEntry(key: name, value: grounds) in surfaces.entries) {
for (final ground in grounds) {
expect(
_contrast(scheme.onSurface, ground),
greaterThanOrEqualTo(7),
reason: '$brightness body text on the $name',
);
expect(
_contrast(scheme.onSurfaceVariant, ground),
greaterThanOrEqualTo(4.5),
reason: '$brightness muted text on the $name',
);
expect(
_contrast(scheme.primary, ground),
greaterThanOrEqualTo(4.5),
reason: '$brightness accent text on the $name',
);
}
}
}
});
testWidgets('the backdrop paints only under Glass and keeps one tree '
'shape for every design', (tester) async {
for (final design in AppDesign.values) {
await tester.pumpWidget(
MaterialApp(
theme: design.light(),
home: const GlassBackdrop(child: SizedBox.expand()),
),
);
await tester.pumpAndSettle();
final paint = tester.widget<CustomPaint>(
find.byKey(const ValueKey('glass-backdrop')),
);
if (design == AppDesign.glass) {
expect(paint.painter, isA<GlassMeshPainter>());
expect(
(paint.painter! as GlassMeshPainter).mesh,
glassLightStyle.backdrop,
);
} else {
expect(paint.painter, isNull, reason: design.label);
}
}
});
test('GlassBorder is value-equal, keeps a side it is given, and lerps', () {
const a = GlassBorder(
borderRadius: BorderRadius.all(Radius.circular(16)),
highlight: Color(0xFFFFFFFF),
edge: Color(0x22000000),
);
const b = GlassBorder(
borderRadius: BorderRadius.all(Radius.circular(16)),
highlight: Color(0xFFFFFFFF),
edge: Color(0x22000000),
);
expect(a, b);
expect(a.hashCode, b.hashCode);
final ring = a.copyWith(side: const BorderSide(width: 2));
expect(ring.side.width, 2);
expect(ring.borderRadius, a.borderRadius);
expect(ring.dimensions, const EdgeInsets.all(2));
expect(ShapeBorder.lerp(a, ring, 0.5), isA<GlassBorder>());
});
}
@@ -255,10 +255,11 @@ void main() {
expect(tokens.largeTargets, isFalse, reason: design.id);
expect(tokens.minContrast, isNull, reason: design.id);
expect(tokens.windowRadius, isNull, reason: design.id);
// Retro CRT snaps too: a blended text glow hung skwasm.
// Glass snaps too (its clear pages do not blend with an opaque
// design's), and Retro CRT (a blended text glow hung skwasm).
expect(
tokens.snapSwitch,
design.crtPhosphor != null,
design == AppDesign.glass || design.crtPhosphor != null,
reason: design.id,
);
expect(tokens.transcript, isNot(TranscriptStyle.boxed));
+5 -1
View File
@@ -168,7 +168,11 @@ void main() {
for (final brightness in Brightness.values) {
final theme = _theme(design, brightness);
final swatch = design.swatch(brightness);
expect(swatch.page, theme.scaffoldBackgroundColor, reason: '$design');
// A glass design's scaffold is clear: its page is its backdrop.
final page =
theme.extension<AppDesignTokens>()?.glass?.backdrop.base ??
theme.scaffoldBackgroundColor;
expect(swatch.page, page, reason: '$design');
expect(swatch.ink, theme.colorScheme.onSurface, reason: '$design');
expect(swatch.accent, theme.colorScheme.primary, reason: '$design');
}