Merge main (Compact design) into Glass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 23:22:56 +00:00
93 changed files with 4110 additions and 313 deletions
+1 -1
View File
@@ -354,7 +354,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
child: ShellRailScope(
shown: rail,
bodyWidth: rail
? media.size.width - kNavigationRailSpace
? media.size.width - navigationRailSpaceOf(context)
: null,
child: scaffold,
),
+86 -54
View File
@@ -10,6 +10,15 @@ const double kNavigationRailWidth = 96;
/// The rail with its divider: what the rail takes from a wide window's width.
const double kNavigationRailSpace = kNavigationRailWidth + 1;
/// The rail's width under the design at [context]: [kNavigationRailWidth],
/// or a dense design's narrower, icon-only rail.
double navigationRailWidthOf(BuildContext context) =>
AppDesignTokens.of(context).density.railWidth;
/// The rail with its divider under the design at [context].
double navigationRailSpaceOf(BuildContext context) =>
navigationRailWidthOf(context) + 1;
/// The narrowest window that shows the destination rail: the list-detail
/// minimum for the body beside it, plus the rail and its divider (the space the
/// shell takes from the window). Narrower windows keep the floating destination
@@ -69,6 +78,7 @@ class ShellNavigationRail extends StatelessWidget {
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
// the rail's background.
@@ -78,11 +88,12 @@ class ShellNavigationRail extends StatelessWidget {
child: Padding(
padding: padding,
child: SizedBox(
width: kNavigationRailWidth,
width: density.railWidth,
child: LayoutBuilder(
builder: (context, constraints) => _rail(
index,
surface,
density,
pinSettings:
constraints.maxHeight >=
kNavigationRailPinnedSettingsMinHeight,
@@ -93,39 +104,46 @@ class ShellNavigationRail extends StatelessWidget {
);
}
Widget _rail(int index, Color surface, {required bool pinSettings}) =>
NavigationRail(
key: const ValueKey('shell.navigation-rail'),
backgroundColor: surface,
minWidth: kNavigationRailWidth,
labelType: NavigationRailLabelType.all,
selectedIndex: index < 0 ? null : index,
onDestinationSelected: (value) =>
onSelected(shellTabDestinations[value]),
destinations: [
for (final destination in shellTabDestinations)
NavigationRailDestination(
icon: KeyedSubtree(
key: ValueKey('shell.destination.${destination.name}'),
// The bar it replaces named each tab in a tooltip too.
// The destination's label already names it for assistive
// technology; the tooltip must not repeat it.
child: Tooltip(
message: destinationDetails(destination).label,
excludeFromSemantics: true,
child: icon(destination),
),
),
label: Text(destinationDetails(destination).label),
Widget _rail(
int index,
Color surface,
DesignDensity density, {
required bool pinSettings,
}) => NavigationRail(
key: const ValueKey('shell.navigation-rail'),
backgroundColor: surface,
minWidth: density.railWidth,
// An icon-only rail names each tab in its tooltip alone.
labelType: density.railLabels
? NavigationRailLabelType.all
: NavigationRailLabelType.none,
selectedIndex: index < 0 ? null : index,
onDestinationSelected: (value) => onSelected(shellTabDestinations[value]),
destinations: [
for (final destination in shellTabDestinations)
NavigationRailDestination(
icon: KeyedSubtree(
key: ValueKey('shell.destination.${destination.name}'),
// The bar it replaces named each tab in a tooltip too.
// The destination's label already names it for assistive
// technology; the tooltip must not repeat it.
child: Tooltip(
message: destinationDetails(destination).label,
excludeFromSemantics: true,
child: icon(destination),
),
],
scrollable: true,
trailingAtBottom: pinSettings,
trailing: _SettingsRailItem(
selected: selected == AppDestination.settings,
onTap: () => onSelected(AppDestination.settings),
),
label: Text(destinationDetails(destination).label),
),
);
],
scrollable: true,
trailingAtBottom: pinSettings,
trailing: _SettingsRailItem(
density: density,
selected: selected == AppDestination.settings,
onTap: () => onSelected(AppDestination.settings),
),
);
}
/// Settings at the rail's foot, drawn as a [NavigationRailDestination] is: an
@@ -133,8 +151,13 @@ class ShellNavigationRail extends StatelessWidget {
/// It is not a [NavigationRailDestination] itself because the rail's
/// destination list is the tabs, and `trailing` is what the rail pins.
class _SettingsRailItem extends StatelessWidget {
const _SettingsRailItem({required this.selected, required this.onTap});
const _SettingsRailItem({
required this.density,
required this.selected,
required this.onTap,
});
final DesignDensity density;
final bool selected;
final VoidCallback onTap;
@@ -149,6 +172,33 @@ class _SettingsRailItem extends StatelessWidget {
color: foreground,
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
);
final indicator = Container(
width: 56,
height: 32,
alignment: Alignment.center,
decoration: ShapeDecoration(
shape: AppDesignTokens.of(context).shape(const StadiumBorder()),
color: selected ? scheme.secondaryContainer : null,
),
child: Icon(item.icon, color: foreground),
);
final Widget mark = density.railLabels
? Column(
mainAxisSize: MainAxisSize.min,
children: [
indicator,
const SizedBox(height: 4),
Text(item.label, style: textStyle),
],
)
// An icon-only rail names Settings in a tooltip, as its tabs.
: Center(
child: Tooltip(
message: item.label,
excludeFromSemantics: true,
child: indicator,
),
);
return Semantics(
button: true,
selected: selected,
@@ -158,28 +208,10 @@ class _SettingsRailItem extends StatelessWidget {
key: const ValueKey('shell.destination.settings'),
onTap: onTap,
child: SizedBox(
width: kNavigationRailWidth,
width: density.railWidth,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 56,
height: 32,
alignment: Alignment.center,
decoration: ShapeDecoration(
shape: AppDesignTokens.of(
context,
).shape(const StadiumBorder()),
color: selected ? scheme.secondaryContainer : null,
),
child: Icon(item.icon, color: foreground),
),
const SizedBox(height: 4),
Text(item.label, style: textStyle),
],
),
padding: EdgeInsets.symmetric(vertical: density.space(12)),
child: mark,
),
),
),
+29 -15
View File
@@ -6,16 +6,25 @@ import 'window_kind.dart';
const double windowCornerRadius = 12;
/// A window's corner radius under the design at [context]: a glass design
/// grows it with its other corners.
double windowCornerRadiusOf(BuildContext context) =>
AppDesignTokens.of(context).glass?.corner(windowCornerRadius) ??
windowCornerRadius;
/// A floating window's corners under the design at [context]:
/// [windowCornerRadius], or a dense design's own corners, or a glass
/// design's grown ones.
BorderRadius windowCorners(BuildContext context) {
final tokens = AppDesignTokens.of(context);
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
/// with larger text.
double windowTitleBarHeight(BuildContext context) =>
MediaQuery.textScalerOf(context).scale(40).clamp(40.0, 64.0);
/// with larger text (a dense design's slimmer bar grows the same way).
double windowTitleBarHeight(BuildContext context) {
final height = AppDesignTokens.of(context).density.titleBarHeight;
return MediaQuery.textScalerOf(
context,
).scale(height).clamp(height, height + 24);
}
/// A floating window's card and title bar: the title (drag to move, double
/// click to maximise), the kind's actions, then Maximise and the X. The X
@@ -55,10 +64,11 @@ class WindowFrame extends StatelessWidget {
// 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: BorderRadius.circular(windowCornerRadiusOf(context)),
borderRadius: windowCorners(context),
color: glass?.solid ?? colors.surfaceContainer,
child: Align(
alignment: Alignment.topCenter,
@@ -73,7 +83,7 @@ class WindowFrame extends StatelessWidget {
),
child: Row(
children: [
Expanded(child: _title(theme)),
Expanded(child: _title(theme, dense)),
for (final action in actions)
IconButton(
tooltip: action.label,
@@ -101,7 +111,7 @@ class WindowFrame extends StatelessWidget {
);
}
Widget _title(ThemeData theme) => MouseRegion(
Widget _title(ThemeData theme, bool dense) => MouseRegion(
cursor: maximized ? SystemMouseCursors.basic : SystemMouseCursors.move,
child: GestureDetector(
key: const ValueKey('window-title'),
@@ -114,11 +124,15 @@ class WindowFrame extends StatelessWidget {
onPanEnd: maximized ? null : (_) => onMoveEnd(),
onDoubleTap: onToggleMaximized,
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 12, end: 8),
padding: EdgeInsetsDirectional.only(start: dense ? 8 : 12, end: 8),
child: Row(
children: [
Icon(icon, size: 18, color: theme.colorScheme.onSurfaceVariant),
const SizedBox(width: 8),
Icon(
icon,
size: dense ? 16 : 18,
color: theme.colorScheme.onSurfaceVariant,
),
SizedBox(width: dense ? 6 : 8),
Expanded(
child: Text(
title,
@@ -143,7 +157,7 @@ class WindowOutline extends StatelessWidget {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
final corners = BorderRadius.circular(windowCornerRadiusOf(context));
final corners = windowCorners(context);
final glass = AppDesignTokens.of(context).glass;
return IgnorePointer(
child: DecoratedBox(
+1 -1
View File
@@ -133,7 +133,7 @@ class _WindowHostState extends State<WindowHost> {
// right, so they never sit under the rail.
// The shell takes the rail and its divider (kNavigationRailSpace).
final leading = widget.reservesRail && showsNavigationRail(context)
? kNavigationRailSpace
? navigationRailSpaceOf(context)
: 0.0;
final bounds = Size(
constraints.maxWidth - leading,
+4 -8
View File
@@ -2,11 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'window_frame.dart'
show
WindowOutline,
WindowResizeGrip,
windowCornerRadiusOf,
windowTitleBarHeight;
show WindowOutline, WindowResizeGrip, windowCorners, windowTitleBarHeight;
import 'window_scope.dart';
/// A floating window's own page stack. Pages pushed from the window's
@@ -122,15 +118,15 @@ class WindowPageBox extends StatelessWidget {
Widget build(BuildContext context) {
final body = WindowBodyScope.maybeOf(context);
if (body == null) return child;
final radius = Radius.circular(windowCornerRadiusOf(context));
final corners = windowCorners(context);
return Stack(
children: [
Positioned.fromRect(
rect: body,
child: ClipRRect(
borderRadius: BorderRadius.only(
bottomLeft: radius,
bottomRight: radius,
bottomLeft: corners.bottomLeft,
bottomRight: corners.bottomRight,
),
child: MediaQuery(
data: MediaQuery.of(context).copyWith(