9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
166 lines
4.8 KiB
Dart
166 lines
4.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/segmented_bar.dart';
|
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
|
import 'graph_viewport.dart';
|
|
import 'graph_viewport_controller.dart';
|
|
|
|
/// Builds the same canvas for another viewport, with the selection that
|
|
/// presentation is showing.
|
|
typedef GraphExpandedCanvasBuilder =
|
|
Widget Function(
|
|
BuildContext context,
|
|
String? selectedStage,
|
|
ValueChanged<String> onSelected,
|
|
);
|
|
|
|
/// A native full-screen presentation of one graph canvas.
|
|
///
|
|
/// It fits the graph into the larger box (as the web does when its panel
|
|
/// expands), keeps the selected node selected, and lets a tap in the larger
|
|
/// canvas update that selection through [onSelected]. Closing pops the route;
|
|
/// the inline canvas was never changed, so it returns to its previous state.
|
|
class GraphExpandedView extends StatefulWidget {
|
|
const GraphExpandedView({
|
|
super.key,
|
|
required this.contentSize,
|
|
required this.canvasBuilder,
|
|
required this.title,
|
|
required this.onSelected,
|
|
this.selectedStage,
|
|
this.header,
|
|
});
|
|
|
|
/// The measured graph extent, as in the inline canvas.
|
|
final Size contentSize;
|
|
|
|
final GraphExpandedCanvasBuilder canvasBuilder;
|
|
|
|
/// The presentation's native title, e.g. `Run graph`.
|
|
final String title;
|
|
|
|
/// Reports a node activated in the expanded canvas.
|
|
final ValueChanged<String> onSelected;
|
|
|
|
/// Optional fixed content above the canvas, e.g. a legend that explains the
|
|
/// graph's marks. It stays outside the pan/zoom transform.
|
|
final Widget? header;
|
|
|
|
final String? selectedStage;
|
|
|
|
@override
|
|
State<GraphExpandedView> createState() => _GraphExpandedViewState();
|
|
}
|
|
|
|
class _GraphExpandedViewState extends State<GraphExpandedView> {
|
|
final GraphViewportController _controller = GraphViewportController();
|
|
late String? _selected = widget.selectedStage;
|
|
|
|
@override
|
|
void didUpdateWidget(GraphExpandedView oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (widget.selectedStage != oldWidget.selectedStage) {
|
|
_selected = widget.selectedStage;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _select(String key) {
|
|
setState(() => _selected = key);
|
|
widget.onSelected(key);
|
|
}
|
|
|
|
void _close() => Navigator.of(context).maybePop();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final viewport = GraphViewport(
|
|
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.
|
|
child: widget.canvasBuilder(context, _selected, _select),
|
|
);
|
|
final body = widget.header == null
|
|
? viewport
|
|
: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
widget.header!,
|
|
Expanded(child: viewport),
|
|
],
|
|
);
|
|
return Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: SegmentedBar(
|
|
title: widget.title,
|
|
automaticallyImplyLeading: false,
|
|
leading: SegmentedBackButton(onPressed: _close),
|
|
actions: [_GraphFitButton(onPressed: _controller.fitToViewport)],
|
|
),
|
|
body: BelowTopBar(child: body),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _GraphFitButton extends StatelessWidget {
|
|
const _GraphFitButton({required this.onPressed});
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => MergeSemantics(
|
|
child: Semantics(
|
|
button: true,
|
|
label: graphFitLabel,
|
|
child: 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
|
|
/// content size and a builder that draws the same canvas for the supplied
|
|
/// selection. The expanded canvas fits that size; the inline canvas is
|
|
/// untouched.
|
|
Future<void> openGraphExpanded(
|
|
BuildContext context, {
|
|
required Size contentSize,
|
|
required GraphExpandedCanvasBuilder canvasBuilder,
|
|
required String title,
|
|
required ValueChanged<String> onSelected,
|
|
String? selectedStage,
|
|
Widget? header,
|
|
}) {
|
|
final page = GraphExpandedView(
|
|
contentSize: contentSize,
|
|
canvasBuilder: canvasBuilder,
|
|
title: title,
|
|
onSelected: onSelected,
|
|
selectedStage: selectedStage,
|
|
header: header,
|
|
);
|
|
final route = MaterialPageRoute<void>(
|
|
fullscreenDialog: true,
|
|
builder: (_) => page,
|
|
);
|
|
return Navigator.of(context).push(route);
|
|
}
|