Polish adaptive app chrome

This commit is contained in:
2026-10-31 06:02:02 +00:00
parent 06f6eda360
commit 480f8843eb
14 changed files with 228 additions and 53 deletions
@@ -230,9 +230,15 @@ class _ChangesViewerState extends State<ChangesViewer> {
bar: Align(
alignment: AlignmentDirectional.centerEnd,
heightFactor: 1,
widthFactor: 1,
child: Padding(
padding: const EdgeInsets.all(8),
child: GlassPill(cupertino: usesCupertinoHost(context), child: pager),
child: IntrinsicWidth(
child: GlassPill(
cupertino: usesCupertinoHost(context),
child: pager,
),
),
),
),
child: content,
@@ -60,6 +60,7 @@ class _ChatModeControlState extends State<ChatModeControl> {
final picker = _ChatModePicker(
load: () => repository.modes(widget.sessionId),
current: _mode,
currentName: _name,
cupertino: cupertino,
choose: (mode) async {
final applied = await repository.selectMode(widget.sessionId, mode.id);
@@ -95,6 +96,9 @@ class _ChatModeControlState extends State<ChatModeControl> {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final label = _name;
// At phone widths the title and a named mode cannot both remain useful.
// Keep the mode's shield, whose semantic label and picker still name it.
final iconOnly = cupertino && MediaQuery.sizeOf(context).width < 600;
final content = Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -103,8 +107,10 @@ class _ChatModeControlState extends State<ChatModeControl> {
? CupertinoIcons.shield_lefthalf_fill
: Icons.shield_outlined,
),
const SizedBox(width: 4),
Flexible(child: Text(label, overflow: TextOverflow.ellipsis)),
if (!iconOnly) ...[
const SizedBox(width: 4),
Flexible(child: Text(label, overflow: TextOverflow.ellipsis)),
],
],
);
const key = Key('chat-mode');
@@ -146,12 +152,14 @@ class _ChatModePicker extends StatefulWidget {
const _ChatModePicker({
required this.load,
required this.current,
required this.currentName,
required this.cupertino,
required this.choose,
});
final Future<({List<JsonMap> modes, String current})> Function() load;
final String current;
final String currentName;
final bool cupertino;
final Future<void> Function(_Mode mode) choose;
@@ -165,6 +173,23 @@ class _ChatModePickerState extends State<_ChatModePicker> {
bool _busy = false;
String? _error;
/// The session row has already named the selected mode. Some harnesses do
/// not return a catalog, so retain that known value in the picker rather
/// than opening an action sheet with no visible mode.
List<_Mode> get _visibleModes {
final modes = _modes;
if (modes == null ||
_current.isEmpty ||
widget.currentName.isEmpty ||
modes.any((mode) => mode.id == _current)) {
return modes ?? const [];
}
return [
...modes,
(id: _current, name: widget.currentName, description: ''),
];
}
@override
void initState() {
super.initState();
@@ -230,7 +255,8 @@ class _ChatModePickerState extends State<_ChatModePicker> {
Widget _materialSheet(BuildContext context) {
final theme = Theme.of(context);
final modes = _modes;
final modes = _visibleModes;
final loaded = _modes != null;
return SafeArea(
child: ListView(
key: const Key('chat-mode-sheet'),
@@ -248,7 +274,7 @@ class _ChatModePickerState extends State<_ChatModePicker> {
style: TextStyle(color: theme.colorScheme.error),
),
),
if (modes == null)
if (!loaded)
const Padding(
padding: EdgeInsets.all(16),
child: Center(child: CircularProgressIndicator()),
@@ -274,7 +300,8 @@ class _ChatModePickerState extends State<_ChatModePicker> {
Widget _cupertinoSheet(BuildContext context) {
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
final modes = _modes;
final modes = _visibleModes;
final loaded = _modes != null;
return CupertinoActionSheet(
key: const Key('chat-mode-sheet'),
title: const Text('Mode'),
@@ -285,11 +312,11 @@ class _ChatModePickerState extends State<_ChatModePicker> {
color: CupertinoColors.systemRed.resolveFrom(context),
),
)
: modes == null
: !loaded
? const CupertinoActivityIndicator()
: null,
actions: [
for (final mode in modes ?? const <_Mode>[])
for (final mode in modes)
CupertinoActionSheetAction(
key: ValueKey<String>('chat-mode-option-${mode.id}'),
onPressed: () => _choose(mode),
@@ -7,9 +7,6 @@ import '../../../ui/adaptive/floating_bar_layout.dart';
import 'graph_viewport.dart';
import 'graph_viewport_controller.dart';
/// The expanded presentation's close wording (`Close`).
const String graphExpandedClose = 'Close';
/// Builds the same canvas for another viewport, with the selection that
/// presentation is showing.
typedef GraphExpandedCanvasBuilder =
@@ -88,6 +85,7 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
key: const Key('graph-expanded-viewport'),
controller: _controller,
contentSize: widget.contentSize,
showControls: false,
// The larger box fits the whole graph, as the web does when its panel
// expands; a later resize re-fits until the reader pans or zooms, then
// only clamps.
@@ -107,13 +105,12 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
navigationBar: SegmentedBar(
cupertino: true,
automaticallyImplyLeading: false,
leading: SegmentedBackButton(cupertino: true, onPressed: _close),
title: widget.title,
actions: [
CupertinoButton(
key: const Key('graph-expanded-close'),
padding: const EdgeInsets.symmetric(horizontal: 16),
onPressed: _close,
child: const Text(graphExpandedClose),
_GraphFitButton(
cupertino: true,
onPressed: _controller.fitToViewport,
),
],
),
@@ -126,11 +123,11 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
cupertino: false,
title: widget.title,
automaticallyImplyLeading: false,
leading: SegmentedBackButton(cupertino: false, onPressed: _close),
actions: [
TextButton(
key: const Key('graph-expanded-close'),
onPressed: _close,
child: const Text(graphExpandedClose),
_GraphFitButton(
cupertino: false,
onPressed: _controller.fitToViewport,
),
],
),
@@ -139,6 +136,37 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
}
}
class _GraphFitButton extends StatelessWidget {
const _GraphFitButton({required this.cupertino, required this.onPressed});
final bool cupertino;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) => MergeSemantics(
child: Semantics(
button: true,
label: graphFitLabel,
child: cupertino
? CupertinoButton(
key: const Key('graph-fit'),
padding: const EdgeInsets.all(8),
onPressed: onPressed,
child: const ExcludeSemantics(child: Icon(CupertinoIcons.resize)),
)
: Tooltip(
message: graphFitLabel,
excludeFromSemantics: true,
child: IconButton(
key: const Key('graph-fit'),
onPressed: onPressed,
icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)),
),
),
),
);
}
/// Pushes [GraphExpandedView] with the host's native full-screen transition.
///
/// This is the seam a Graph tab or run detail can call: pass the measured
@@ -25,6 +25,7 @@ class GraphViewport extends StatefulWidget {
required this.contentSize,
required this.child,
this.onExpand,
this.showControls = true,
});
final GraphViewportController controller;
@@ -38,6 +39,10 @@ class GraphViewport extends StatefulWidget {
/// Opens the expanded presentation. Null hides the expand control.
final VoidCallback? onExpand;
/// Whether this canvas draws its own fit/expand pill. Full-screen graph
/// views place Fit in their top-bar actions instead.
final bool showControls;
@override
State<GraphViewport> createState() => _GraphViewportState();
}
@@ -111,31 +116,32 @@ class _GraphViewportState extends State<GraphViewport> {
),
),
),
PositionedDirectional(
top: 8,
end: 8,
child: GlassPill(
cupertino: usesCupertinoHost(context),
child: Wrap(
spacing: 2,
children: [
_ViewportButton(
buttonKey: const Key('graph-fit'),
icon: _fitIcon(context),
label: graphFitLabel,
onPressed: widget.controller.fitToViewport,
),
if (widget.onExpand != null)
if (widget.showControls)
PositionedDirectional(
top: 8,
end: 8,
child: GlassPill(
cupertino: usesCupertinoHost(context),
child: Wrap(
spacing: 2,
children: [
_ViewportButton(
buttonKey: const Key('graph-expand'),
icon: _expandIcon(context),
label: graphExpandLabel,
onPressed: widget.onExpand,
buttonKey: const Key('graph-fit'),
icon: _fitIcon(context),
label: graphFitLabel,
onPressed: widget.controller.fitToViewport,
),
],
if (widget.onExpand != null)
_ViewportButton(
buttonKey: const Key('graph-expand'),
icon: _expandIcon(context),
label: graphExpandLabel,
onPressed: widget.onExpand,
),
],
),
),
),
),
],
);
},
@@ -93,9 +93,15 @@ class _StageDefinitionViewState extends State<StageDefinitionView> {
const SizedBox(height: 16),
],
if (fields.any((field) => field.block)) ...[
MarkdownModeSwitch(
raw: _raw,
onChanged: (raw) => setState(() => _raw = raw),
Align(
alignment: AlignmentDirectional.centerStart,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 220),
child: MarkdownModeSwitch(
raw: _raw,
onChanged: (raw) => setState(() => _raw = raw),
),
),
),
const SizedBox(height: 16),
],
+2 -2
View File
@@ -254,10 +254,10 @@ class SegmentedBar extends StatelessWidget
end: Alignment.bottomCenter,
colors: [
background,
background.withValues(alpha: background.a * 0.85),
background.withValues(alpha: background.a * 0.95),
background.withValues(alpha: 0),
],
stops: const [0, 0.45, 1],
stops: const [0, 0.5, 1],
),
),
),
@@ -120,7 +120,8 @@ class SegmentedTitlePill extends StatelessWidget {
fontWeight: FontWeight.w600,
color: foreground,
);
subtitleStyle = text.tabLabelTextStyle.copyWith(
subtitleStyle = text.textStyle.copyWith(
fontSize: 13,
color:
foreground ?? CupertinoColors.secondaryLabel.resolveFrom(context),
);
+1 -1
View File
@@ -111,7 +111,7 @@ class StickySectionTitle extends StatelessWidget {
),
);
final row = Padding(
padding: const EdgeInsetsDirectional.only(start: 13, end: 8),
padding: const EdgeInsetsDirectional.only(start: 16, end: 8),
child: Row(
children: [
Expanded(