Give glass control bars equal end and edge gaps

Inside a glass bar the first and last controls now keep the same gap from
the pill's sides as from its top and bottom, from shared GlassBarMetrics
(48/44 targets, 8 edge gap). Applies to the artifact viewer bar (hugs its
actions without a pager), the chevron pagers (position text inset like an
icon), and the chat composer's Cupertino Send/Stop (centred circle).
Run 7 in the full-app probe now records change captures for diff captures.
This commit is contained in:
2026-11-02 18:35:37 +00:00
parent 37b67c84df
commit 4d9ee1ea78
10 changed files with 597 additions and 83 deletions
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/glass_bar.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/artifact_record.dart';
import '../domain/artifact_url.dart';
@@ -236,7 +237,6 @@ class ArtifactIconAction extends StatelessWidget {
required this.cupertinoIcon,
required this.onPressed,
this.busy = false,
this.inBar = false,
});
final String label;
@@ -245,10 +245,6 @@ class ArtifactIconAction extends StatelessWidget {
final VoidCallback? onPressed;
final bool busy;
/// Sized like the top bar's other actions (a standard icon button), so the
/// bar's round pill is centred on it; compact otherwise.
final bool inBar;
@override
Widget build(BuildContext context) {
if (usesCupertinoHost(context)) {
@@ -256,18 +252,20 @@ class ArtifactIconAction extends StatelessWidget {
button: true,
label: label,
child: CupertinoButton(
padding: inBar ? EdgeInsets.zero : const EdgeInsets.all(8),
minimumSize: const Size(44, 44),
// One square touch target, like the top bar's other actions, so a
// round pill is centred on it and a glass bar's edge gaps hold.
padding: EdgeInsets.zero,
minimumSize: GlassBarMetrics.cupertinoMinimumSize(),
onPressed: onPressed,
child: busy
? const CupertinoActivityIndicator(radius: 9)
: Icon(cupertinoIcon, size: 30),
: Icon(cupertinoIcon, size: GlassBarMetrics.iconSize(true)),
),
);
}
return IconButton(
tooltip: label,
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
constraints: GlassBarMetrics.materialConstraints(),
padding: EdgeInsets.zero,
onPressed: onPressed,
icon: busy
@@ -276,7 +274,7 @@ class ArtifactIconAction extends StatelessWidget {
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Icon(icon, size: 28),
: Icon(icon, size: GlassBarMetrics.iconSize(false)),
);
}
}
@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/glass_pill.dart';
import '../../../ui/adaptive/glass_bar.dart';
import '../actions/artifact_file_actions.dart';
import '../actions/artifact_file_bridge.dart';
import '../domain/artifact_preview.dart';
@@ -122,33 +122,32 @@ class ArtifactViewerBody extends StatelessWidget {
bar: SafeArea(
top: false,
minimum: const EdgeInsets.all(8),
child: SizedBox(
height: 56,
child: GlassPill(
// Without a pager the bar is as wide as its actions, so its last
// control keeps the same gap from the bar's end as the first.
child: Align(
alignment: AlignmentDirectional.centerStart,
heightFactor: 1,
child: GlassControlBar(
cupertino: usesCupertinoHost(context),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
child: Row(
key: const Key('artifact-viewer-actions'),
children: [
if (resolved != null && !resolved.external)
ArtifactFileActions(
key: ValueKey<String>(
'viewer-files-${page.group.stageKey}\u0000'
'${page.group.visit}\u0000${page.artifact.url}',
),
artifact: page.artifact,
resolved: resolved,
fetch: fetch,
bridge: fileBridge,
compact: true,
),
if (resolved != null)
_Actions(
resolved: resolved,
onOpen: onOpen,
onCopy: onCopy,
child: Row(
key: const Key('artifact-viewer-actions'),
mainAxisSize: count > 1 ? MainAxisSize.max : MainAxisSize.min,
children: [
if (resolved != null && !resolved.external)
ArtifactFileActions(
key: ValueKey<String>(
'viewer-files-${page.group.stageKey}\u0000'
'${page.group.visit}\u0000${page.artifact.url}',
),
artifact: page.artifact,
resolved: resolved,
fetch: fetch,
bridge: fileBridge,
compact: true,
),
if (resolved != null)
_Actions(resolved: resolved, onOpen: onOpen, onCopy: onCopy),
if (count > 1)
Expanded(
child: _Pager(
index: index,
@@ -157,8 +156,7 @@ class ArtifactViewerBody extends StatelessWidget {
onNext: onNext,
),
),
],
),
],
),
),
),
@@ -383,7 +381,6 @@ class ArtifactViewerInfoAction extends StatelessWidget {
Widget build(BuildContext context) {
return ArtifactIconAction(
key: const Key('artifact-info'),
inBar: true,
label: 'Details',
icon: Icons.info_outline,
cupertinoIcon: CupertinoIcons.info,
@@ -10,7 +10,7 @@ import 'change_style.dart';
import 'file_diff_viewer.dart';
import 'visit_pager.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/glass_pill.dart';
import '../../../ui/adaptive/glass_bar.dart';
import '../../../ui/adaptive/host.dart';
/// The run's Changes surface: an honest final-state summary followed by the
@@ -247,7 +247,7 @@ class _ChangesViewerState extends State<ChangesViewer> {
child: Padding(
padding: const EdgeInsets.all(8),
child: IntrinsicWidth(
child: GlassPill(
child: GlassControlBar(
cupertino: usesCupertinoHost(context),
child: pager,
),
@@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
import '../../../ui/navigation/chevron_pager.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/glass_pill.dart';
import '../../../ui/adaptive/glass_bar.dart';
import '../domain/change_kind.dart';
import '../domain/change_wording.dart';
import '../domain/file_change.dart';
@@ -315,7 +315,7 @@ class _FileDiffPageState extends State<FileDiffPage> {
child: SafeArea(
top: false,
minimum: const EdgeInsets.all(8),
child: GlassPill(cupertino: cupertino, child: pager),
child: GlassControlBar(cupertino: cupertino, child: pager),
),
),
child: viewer,
@@ -21,6 +21,7 @@ import 'chat_command_actions.dart';
import 'chat_command_palette.dart';
import 'chat_composer_controller.dart';
import '../ui/transcript/chat_attachment_frame.dart';
import '../../../ui/adaptive/glass_bar.dart';
import '../../../ui/adaptive/glass_pill.dart';
import 'chat_reading_width.dart';
import 'composer_focus_restore.dart';
@@ -764,7 +765,12 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(28)),
),
child: Padding(padding: const EdgeInsets.all(4), child: child),
// The end controls keep the same gap from the pill's sides as from its
// bottom (and its top while the field is one line).
child: Padding(
padding: const EdgeInsets.all(GlassBarMetrics.fieldEdgeGap),
child: child,
),
);
/// The attach control: a host button that opens the picker, disabled when the
@@ -781,6 +787,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
child: CupertinoButton(
key: const Key('chat-composer-attach'),
padding: EdgeInsets.zero,
minimumSize: GlassBarMetrics.cupertinoMinimumSize(),
onPressed: onPressed,
child: const Icon(CupertinoIcons.add),
),
@@ -1091,16 +1098,30 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
button: true,
label: label,
excludeSemantics: true,
child: CupertinoButton.filled(
key: key,
sizeStyle: CupertinoButtonSize.small,
color: stop ? CupertinoColors.systemRed.resolveFrom(context) : null,
onPressed: enabled ? press : null,
child: stop
? const ChatStopIcon(
child: Icon(CupertinoIcons.stop_fill, size: 18),
)
: const Icon(CupertinoIcons.arrow_up, size: 18),
// A filled circle centred in a full touch target, like Material's
// filled icon button, so it keeps the pill's edge gap on every side.
child: SizedBox.square(
dimension: GlassBarMetrics.controlExtent(true),
child: Center(
child: CupertinoButton.filled(
key: key,
sizeStyle: CupertinoButtonSize.small,
padding: EdgeInsets.zero,
minimumSize: Size.square(GlassBarMetrics.filledExtent(true)),
borderRadius: BorderRadius.circular(
GlassBarMetrics.filledExtent(true) / 2,
),
color: stop
? CupertinoColors.systemRed.resolveFrom(context)
: null,
onPressed: enabled ? press : null,
child: stop
? const ChatStopIcon(
child: Icon(CupertinoIcons.stop_fill, size: 18),
)
: const Icon(CupertinoIcons.arrow_up, size: 18),
),
),
),
);
}
+71
View File
@@ -0,0 +1,71 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'glass_pill.dart';
/// The shared geometry of a floating glass control bar: a [GlassPill] holding
/// a row of icon controls (a viewer's actions, a pager, a canvas's controls).
///
/// Like the floating tab bar, the first and last controls keep the same gap
/// from the pill's sides as every control keeps from its top and bottom, so
/// a control at either end sits concentric with the pill's round cap.
/// Neighbouring controls touch target to target: their icons are spaced by
/// the targets' own padding, the same everywhere along the bar.
abstract final class GlassBarMetrics {
/// The gap between the controls' targets and every edge of the pill.
static const double edgeGap = 8;
/// The tighter gap of a bar around a text field (the chat composer), so
/// the field keeps its width; its end controls keep it on every side too.
static const double fieldEdgeGap = 4;
/// The square target of one control: the platform's minimum touch target.
static double controlExtent(bool cupertino) =>
cupertino ? kMinInteractiveDimensionCupertino : kMinInteractiveDimension;
/// The icon drawn inside a control's target.
static double iconSize(bool cupertino) => cupertino ? 30 : 28;
/// The space between a control's icon and the edge of its target.
static double iconInset(bool cupertino) =>
(controlExtent(cupertino) - iconSize(cupertino)) / 2;
/// The visible circle of a filled control (Send) inside its target: the
/// Material filled icon button's 40 in 48, and the same inset on Cupertino.
static double filledExtent(bool cupertino) => controlExtent(cupertino) - 8;
/// The pill's height around one row of controls.
static double height(bool cupertino) =>
controlExtent(cupertino) + 2 * edgeGap;
/// The Material target constraints of one control.
static BoxConstraints materialConstraints() => BoxConstraints(
minWidth: controlExtent(false),
minHeight: controlExtent(false),
);
/// The Cupertino minimum size of one control.
static Size cupertinoMinimumSize() => Size.square(controlExtent(true));
}
/// A [GlassPill] padded by [GlassBarMetrics.edgeGap] on every side around
/// [child], a row of controls each [GlassBarMetrics.controlExtent] tall.
class GlassControlBar extends StatelessWidget {
const GlassControlBar({
super.key,
required this.cupertino,
required this.child,
});
final bool cupertino;
final Widget child;
@override
Widget build(BuildContext context) => GlassPill(
cupertino: cupertino,
child: Padding(
padding: const EdgeInsets.all(GlassBarMetrics.edgeGap),
child: child,
),
);
}
+30 -29
View File
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/glass_bar.dart';
import '../adaptive/host.dart';
/// Previous and next as chevrons in one row at the bottom right, with the
@@ -49,13 +50,13 @@ class ChevronPager extends StatelessWidget {
child: CupertinoButton(
key: key,
padding: EdgeInsets.zero,
minimumSize: const Size(44, 44),
minimumSize: GlassBarMetrics.cupertinoMinimumSize(),
onPressed: onPressed,
child: Icon(
previous
? CupertinoIcons.chevron_left
: CupertinoIcons.chevron_right,
size: 30,
size: GlassBarMetrics.iconSize(true),
),
),
);
@@ -63,26 +64,27 @@ class ChevronPager extends StatelessWidget {
return IconButton(
key: key,
tooltip: label,
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
constraints: GlassBarMetrics.materialConstraints(),
padding: EdgeInsets.zero,
onPressed: onPressed,
icon: Icon(
previous ? Icons.chevron_left : Icons.chevron_right,
size: 28,
size: GlassBarMetrics.iconSize(false),
),
);
}
return Padding(
// The surrounding glass pill supplies the edge gap. Keeping this row's
// horizontal padding at zero also leaves room for four 48px controls on
// a narrow phone at large text sizes.
padding: EdgeInsets.zero,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Flexible(
fit: FlexFit.tight,
// The surrounding glass bar supplies the edge gap ([GlassBarMetrics]).
// The position keeps an icon's inset on each side, so it sits as far from
// the bar's edge and from the chevrons as an icon would.
final inset = GlassBarMetrics.iconInset(cupertino);
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Flexible(
fit: FlexFit.tight,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: inset),
child: Text(
'${index + 1} of $count',
key: positionKey,
@@ -90,21 +92,20 @@ class ChevronPager extends StatelessWidget {
overflow: TextOverflow.ellipsis,
),
),
const SizedBox(width: 0),
chevron(
key: previousKey,
previous: true,
label: previousLabel,
onPressed: onPrevious,
),
chevron(
key: nextKey,
previous: false,
label: nextLabel,
onPressed: onNext,
),
],
),
),
chevron(
key: previousKey,
previous: true,
label: previousLabel,
onPressed: onPrevious,
),
chevron(
key: nextKey,
previous: false,
label: nextLabel,
onPressed: onNext,
),
],
);
}
}