Merge main (Compact design) into Glass
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user