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
@@ -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),
],