WIP compact
This commit is contained in:
@@ -347,7 +347,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
child: ShellRailScope(
|
||||
shown: rail,
|
||||
bodyWidth: rail
|
||||
? media.size.width - kNavigationRailSpace
|
||||
? media.size.width - navigationRailSpaceOf(context)
|
||||
: null,
|
||||
child: scaffold,
|
||||
),
|
||||
|
||||
@@ -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
|
||||
@@ -66,6 +75,7 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final index = shellTabDestinations.indexOf(selected);
|
||||
final surface = 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.
|
||||
@@ -75,11 +85,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,
|
||||
@@ -90,12 +101,19 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _rail(int index, Color surface, {required bool pinSettings}) =>
|
||||
NavigationRail(
|
||||
Widget _rail(
|
||||
int index,
|
||||
Color surface,
|
||||
DesignDensity density, {
|
||||
required bool pinSettings,
|
||||
}) => NavigationRail(
|
||||
key: const ValueKey('shell.navigation-rail'),
|
||||
backgroundColor: surface,
|
||||
minWidth: kNavigationRailWidth,
|
||||
labelType: NavigationRailLabelType.all,
|
||||
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]),
|
||||
@@ -119,6 +137,7 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
scrollable: true,
|
||||
trailingAtBottom: pinSettings,
|
||||
trailing: _SettingsRailItem(
|
||||
density: density,
|
||||
selected: selected == AppDestination.settings,
|
||||
onTap: () => onSelected(AppDestination.settings),
|
||||
),
|
||||
@@ -130,8 +149,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;
|
||||
|
||||
@@ -146,6 +170,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,
|
||||
@@ -155,28 +206,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,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/theme/app_design_tokens.dart';
|
||||
import 'window_kind.dart';
|
||||
|
||||
const double windowCornerRadius = 12;
|
||||
|
||||
/// A floating window's corners under the design at [context]:
|
||||
/// [windowCornerRadius], or a dense design's own corners.
|
||||
BorderRadius windowCorners(BuildContext context) => AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(const BorderRadius.all(Radius.circular(windowCornerRadius)));
|
||||
|
||||
/// 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
|
||||
@@ -45,10 +56,11 @@ class WindowFrame extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final colors = theme.colorScheme;
|
||||
final dense = AppDesignTokens.of(context).density.dense;
|
||||
return Material(
|
||||
elevation: 8,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
borderRadius: BorderRadius.circular(windowCornerRadius),
|
||||
borderRadius: windowCorners(context),
|
||||
color: colors.surfaceContainer,
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
@@ -63,7 +75,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,
|
||||
@@ -91,7 +103,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'),
|
||||
@@ -104,11 +116,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,
|
||||
@@ -137,7 +153,7 @@ class WindowOutline extends StatelessWidget {
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: colors.outlineVariant),
|
||||
borderRadius: BorderRadius.circular(windowCornerRadius),
|
||||
borderRadius: windowCorners(context),
|
||||
),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'window_frame.dart'
|
||||
show
|
||||
WindowOutline,
|
||||
WindowResizeGrip,
|
||||
windowCornerRadius,
|
||||
windowCorners,
|
||||
windowTitleBarHeight;
|
||||
import 'window_scope.dart';
|
||||
|
||||
@@ -122,15 +122,15 @@ class WindowPageBox extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final body = WindowBodyScope.maybeOf(context);
|
||||
if (body == null) return child;
|
||||
const radius = Radius.circular(windowCornerRadius);
|
||||
final corners = windowCorners(context);
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fromRect(
|
||||
rect: body,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomLeft: radius,
|
||||
bottomRight: radius,
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: corners.bottomLeft,
|
||||
bottomRight: corners.bottomRight,
|
||||
),
|
||||
child: MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
|
||||
Reference in New Issue
Block a user