merge(app): land pipeline Graph tab after retained-deadline recovery
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'pipeline_models.dart';
|
||||
|
||||
/// Optional graph integration supplied by the later graph item (P2).
|
||||
///
|
||||
/// [onStageSelected] reports the graph's stage key with the pipeline identity
|
||||
/// this detail was loaded for, so a host can route to a stage view without the
|
||||
/// pipelines feature owning the graph.
|
||||
typedef PipelineGraphBuilder =
|
||||
Widget Function(
|
||||
BuildContext context,
|
||||
PipelineDetail detail,
|
||||
ValueChanged<String> onStageSelected,
|
||||
);
|
||||
|
||||
/// One stage selected in a hosted graph.
|
||||
class PipelineStageRef {
|
||||
const PipelineStageRef({
|
||||
required this.pipelineId,
|
||||
required this.version,
|
||||
required this.stageKey,
|
||||
});
|
||||
|
||||
final int pipelineId;
|
||||
final int version;
|
||||
final String stageKey;
|
||||
}
|
||||
@@ -116,6 +116,8 @@ class PipelineDetail extends PipelineSummary {
|
||||
required this.contentHash,
|
||||
required this.source,
|
||||
required this.versions,
|
||||
this.graph,
|
||||
this.shape,
|
||||
});
|
||||
|
||||
factory PipelineDetail.fromJson(PipelineJson json) {
|
||||
@@ -144,6 +146,8 @@ class PipelineDetail extends PipelineSummary {
|
||||
),
|
||||
)
|
||||
: const <PipelineVersion>[],
|
||||
graph: _jsonObject(json['graph']),
|
||||
shape: _jsonObject(json['shape']),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,6 +157,15 @@ class PipelineDetail extends PipelineSummary {
|
||||
final String source;
|
||||
final List<PipelineVersion> versions;
|
||||
|
||||
/// The exact definition graph this reply pinned for [resolvedVersion].
|
||||
///
|
||||
/// Raw JSON: its fields are never normalised here. Null means the reply
|
||||
/// carried no graph, which is not the same as a definition with no stages.
|
||||
final PipelineJson? graph;
|
||||
|
||||
/// The optional compact graph summary some replies add, kept verbatim.
|
||||
final PipelineJson? shape;
|
||||
|
||||
/// The concrete version this detail describes. A request for version 0 asks
|
||||
/// for latest, so the reply's own `version` is authoritative for display.
|
||||
int get resolvedVersion => version > 0 ? version : latestVersion;
|
||||
@@ -223,3 +236,7 @@ int? _optionalInt(Object? value) {
|
||||
}
|
||||
|
||||
String _string(Object? value) => value is String ? value : '';
|
||||
|
||||
/// A raw JSON object exactly as a reply carried it, or null when absent.
|
||||
PipelineJson? _jsonObject(Object? value) =>
|
||||
value is Map ? Map<String, dynamic>.from(value) : null;
|
||||
|
||||
@@ -2,14 +2,12 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
import 'pipeline_graph_hook.dart';
|
||||
import 'pipeline_repository.dart';
|
||||
import 'pipelines_controller.dart';
|
||||
import 'widgets/pipeline_controls.dart';
|
||||
import 'widgets/pipeline_detail_panel.dart';
|
||||
import 'widgets/pipeline_list_panel.dart';
|
||||
|
||||
export 'pipeline_graph_hook.dart';
|
||||
export 'pipeline_models.dart' show PipelineDetail, PipelineVersion;
|
||||
|
||||
/// Below this width the list and detail are separate pages; above it they sit
|
||||
@@ -19,9 +17,6 @@ const double kPipelinesWideBreakpoint = 720;
|
||||
/// The read-only Pipelines destination: list, filters/sort, detail, source and
|
||||
/// version history.
|
||||
///
|
||||
/// [graphBuilder] is the optional integration hook for the later graph item.
|
||||
/// Without it the Graph tab states that graph rendering is pending.
|
||||
///
|
||||
/// Standalone use keeps the screen's own native scaffolding. The application
|
||||
/// shell sets [embedded] because it already owns the one navigation bar, and
|
||||
/// supplies [syncToken] so a reconnect refreshes in place.
|
||||
@@ -29,15 +24,11 @@ class PipelinesScreen extends StatefulWidget {
|
||||
const PipelinesScreen({
|
||||
super.key,
|
||||
required this.gateway,
|
||||
this.graphBuilder,
|
||||
this.onStageSelected,
|
||||
this.embedded = false,
|
||||
this.syncToken = 0,
|
||||
});
|
||||
|
||||
final ApiGateway gateway;
|
||||
final PipelineGraphBuilder? graphBuilder;
|
||||
final ValueChanged<PipelineStageRef>? onStageSelected;
|
||||
|
||||
/// True under the application shell, which owns the single navigation bar.
|
||||
final bool embedded;
|
||||
@@ -90,12 +81,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
final wide = constraints.maxWidth >= kPipelinesWideBreakpoint;
|
||||
if (!wide) {
|
||||
return _controller.hasSelection
|
||||
? PipelineDetailPanel(
|
||||
controller: _controller,
|
||||
showBack: true,
|
||||
graphBuilder: widget.graphBuilder,
|
||||
onStageSelected: widget.onStageSelected,
|
||||
)
|
||||
? PipelineDetailPanel(controller: _controller, showBack: true)
|
||||
: PipelineListPanel(controller: _controller);
|
||||
}
|
||||
return Row(
|
||||
@@ -111,8 +97,6 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
child: PipelineDetailPanel(
|
||||
controller: _controller,
|
||||
showBack: false,
|
||||
graphBuilder: widget.graphBuilder,
|
||||
onStageSelected: widget.onStageSelected,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../pipeline_graph_hook.dart';
|
||||
import '../../graph/widgets/stage_definition_view.dart';
|
||||
import '../pipeline_models.dart';
|
||||
import '../pipeline_query.dart';
|
||||
import '../pipelines_controller.dart';
|
||||
import 'pipeline_controls.dart';
|
||||
import 'pipeline_detail_styles.dart';
|
||||
import 'pipeline_graph_tab.dart';
|
||||
import 'pipeline_summary_view.dart';
|
||||
import 'pipeline_tabs.dart';
|
||||
|
||||
/// The right/bottom pane: Summary, Source and the optional graph hook.
|
||||
/// The least height the selected tab keeps for its own content.
|
||||
///
|
||||
/// A header, banners and tabs that would leave the tab less than this may
|
||||
/// scroll instead: content-driven layout must not let scaled title text squeeze
|
||||
/// the tab away. Ordinary sizes never reach this reserve, so the header keeps
|
||||
/// its natural height there.
|
||||
const double kPipelineDetailMinContentHeight = 160;
|
||||
|
||||
/// The right/bottom pane: Summary, Graph, Source and version history.
|
||||
class PipelineDetailPanel extends StatefulWidget {
|
||||
const PipelineDetailPanel({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.showBack,
|
||||
this.graphBuilder,
|
||||
this.onStageSelected,
|
||||
});
|
||||
|
||||
final PipelinesController controller;
|
||||
final bool showBack;
|
||||
final PipelineGraphBuilder? graphBuilder;
|
||||
final ValueChanged<PipelineStageRef>? onStageSelected;
|
||||
|
||||
@override
|
||||
State<PipelineDetailPanel> createState() => _PipelineDetailPanelState();
|
||||
@@ -31,43 +38,127 @@ class PipelineDetailPanel extends StatefulWidget {
|
||||
class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
||||
PipelineDetailTab _tab = PipelineDetailTab.summary;
|
||||
|
||||
/// The node selected in the Graph tab, kept here (not in the tab) so a
|
||||
/// Summary/Source round trip cannot drop it. The web keeps its
|
||||
/// `pipelineGraphSelection` across in-place tab changes for the same reason.
|
||||
String? _graphSelection;
|
||||
|
||||
/// The pinned identity [_graphSelection] belongs to. A different pipeline or
|
||||
/// version is a different definition, so its mark is cleared.
|
||||
String? _graphPin;
|
||||
|
||||
PipelinesController get _controller => widget.controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final detail = _controller.detail;
|
||||
if (detail == null) return _withoutDetail(context);
|
||||
return ListView(
|
||||
key: const Key('pipeline-detail'),
|
||||
children: [
|
||||
_header(context, detail),
|
||||
if (_controller.detailLoading)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: PipelineProgress(label: 'Refreshing pipeline detail'),
|
||||
),
|
||||
if (_controller.detailError != null)
|
||||
PipelineErrorBanner(
|
||||
message: _controller.detailError!,
|
||||
onRetry: _controller.retryDetail,
|
||||
),
|
||||
PipelineDetailTabs(
|
||||
selected: _tab,
|
||||
onSelected: (tab) => setState(() => _tab = tab),
|
||||
),
|
||||
switch (_tab) {
|
||||
PipelineDetailTab.summary => PipelineSummaryView(
|
||||
controller: _controller,
|
||||
detail: detail,
|
||||
),
|
||||
PipelineDetailTab.graph => _graph(context, detail),
|
||||
PipelineDetailTab.source => _source(context, detail),
|
||||
},
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
_retainGraphSelection(detail);
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final headerLimit = _headerLimit(constraints);
|
||||
return Column(
|
||||
key: const Key('pipeline-detail'),
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: headerLimit),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_header(context, detail),
|
||||
if (_controller.detailLoading)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: PipelineProgress(
|
||||
label: 'Refreshing pipeline detail',
|
||||
),
|
||||
),
|
||||
if (_controller.detailError != null)
|
||||
PipelineErrorBanner(
|
||||
message: _controller.detailError!,
|
||||
onRetry: _controller.retryDetail,
|
||||
),
|
||||
PipelineDetailTabs(
|
||||
selected: _tab,
|
||||
onSelected: (tab) => setState(() => _tab = tab),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Every tab gets the bounded remaining height. Summary/source
|
||||
// scroll their own content; the graph fills the slot so its canvas
|
||||
// is never asked for an unbounded extent inside a scroll view.
|
||||
Expanded(
|
||||
child: switch (_tab) {
|
||||
PipelineDetailTab.summary => _scrolling(
|
||||
PipelineSummaryView(controller: _controller, detail: detail),
|
||||
),
|
||||
PipelineDetailTab.graph => PipelineGraphTab(
|
||||
detail: detail,
|
||||
selectedStage: _graphSelection,
|
||||
onSelected: (stageKey) =>
|
||||
_openGraphStage(context, detail, stageKey),
|
||||
),
|
||||
PipelineDetailTab.source => _source(context, detail),
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// The header keeps its natural height while at least
|
||||
/// [kPipelineDetailMinContentHeight] remains for the tab, and never more than
|
||||
/// the panel itself; past that it scrolls.
|
||||
double _headerLimit(BoxConstraints constraints) {
|
||||
if (!constraints.hasBoundedHeight) return double.infinity;
|
||||
final height = constraints.maxHeight;
|
||||
// Below twice the reserve the two shares meet at 40%, so the header stays
|
||||
// reachable even in a panel shorter than the reserve itself.
|
||||
final floorShare = height * 0.4;
|
||||
final reserve = height - kPipelineDetailMinContentHeight;
|
||||
return math.max(floorShare, reserve).clamp(0.0, height);
|
||||
}
|
||||
|
||||
/// Clears a selection whose pinned definition is no longer the one shown.
|
||||
///
|
||||
/// This runs during build because detail replies arrive through the
|
||||
/// controller's notifier (a reconnect can replace a detail without ever
|
||||
/// nulling it), not through a new widget. The cleared value is used by this
|
||||
/// same build, so no extra frame is needed.
|
||||
void _retainGraphSelection(PipelineDetail detail) {
|
||||
final pin = '${detail.id}@${detail.resolvedVersion}';
|
||||
if (pin == _graphPin) return;
|
||||
_graphPin = pin;
|
||||
_graphSelection = null;
|
||||
}
|
||||
|
||||
/// Selects a node and opens the landed definition page for the pinned graph.
|
||||
void _openGraphStage(
|
||||
BuildContext context,
|
||||
PipelineDetail detail,
|
||||
String stageKey,
|
||||
) {
|
||||
final graph = detail.graph;
|
||||
if (graph == null) return;
|
||||
setState(() => _graphSelection = stageKey);
|
||||
openStageDefinition(
|
||||
context,
|
||||
graph: graph,
|
||||
stageKey: stageKey,
|
||||
pipelineId: detail.id,
|
||||
pipelineName: detail.name,
|
||||
version: detail.resolvedVersion,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _scrolling(Widget child) =>
|
||||
ListView(children: [child, const SizedBox(height: 24)]);
|
||||
|
||||
Widget _withoutDetail(BuildContext context) {
|
||||
if (!_controller.hasSelection) {
|
||||
return Center(
|
||||
@@ -140,36 +231,15 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _graph(BuildContext context, PipelineDetail detail) {
|
||||
final builder = widget.graphBuilder;
|
||||
if (builder == null) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
'Graph rendering is pending (P2).',
|
||||
style: pipelineMutedStyle(context),
|
||||
),
|
||||
);
|
||||
}
|
||||
return builder(
|
||||
context,
|
||||
detail,
|
||||
(stageKey) => widget.onStageSelected?.call(
|
||||
PipelineStageRef(
|
||||
pipelineId: detail.id,
|
||||
version: detail.resolvedVersion,
|
||||
stageKey: stageKey,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _source(BuildContext context, PipelineDetail detail) {
|
||||
return Padding(
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: detail.source.isEmpty
|
||||
? Text('No source recorded.', style: pipelineMutedStyle(context))
|
||||
: SelectableText(detail.source, style: pipelineValueStyle(context)),
|
||||
children: [
|
||||
if (detail.source.isEmpty)
|
||||
Text('No source recorded.', style: pipelineMutedStyle(context))
|
||||
else
|
||||
SelectableText(detail.source, style: pipelineValueStyle(context)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/// The detail sections. Graph rendering is owned by the later graph item; the
|
||||
/// tab row provides the tab and an optional integration hook.
|
||||
/// The detail sections: Summary, the pinned definition Graph and Source.
|
||||
enum PipelineDetailTab {
|
||||
summary('Summary'),
|
||||
graph('Graph'),
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../graph/widgets/definition_graph_view.dart';
|
||||
import '../pipeline_models.dart';
|
||||
import 'pipeline_controls.dart';
|
||||
import 'pipeline_detail_styles.dart';
|
||||
|
||||
/// The Graph tab's guidance note. Gestures stay the host's own: wheel or pinch
|
||||
/// zoom, drag pan, and an ordinary tap/click selects a node.
|
||||
const String pipelineGraphNote =
|
||||
'Scroll or pinch to zoom, drag to pan, select a stage for details. '
|
||||
'Edges are labelled with their outcome; error* is the implicit fallback.';
|
||||
|
||||
/// A reply that carried no definition graph: nothing is reconstructed from the
|
||||
/// source and no empty graph stands in for the missing definition.
|
||||
const String pipelineGraphMissing =
|
||||
'This reply did not include the pipeline definition graph, so it cannot be '
|
||||
'drawn. No graph has been reconstructed from the source.';
|
||||
|
||||
/// The most of the tab's slot the guidance note may take.
|
||||
///
|
||||
/// The graph is the tab's content and the note is guidance, so the note starts
|
||||
/// from one third. When the whole note does not fit it keeps whole lines only
|
||||
/// and scrolls behind a native, visible scrollbar instead of ending on a
|
||||
/// half-drawn row. A share shorter than two lines grows to two whole lines (one
|
||||
/// line for very large text), and never past half the tab, so the canvas always
|
||||
/// keeps at least half of it.
|
||||
const double pipelineGraphNoteShare = 1 / 3;
|
||||
|
||||
/// The detail Graph tab: the pinned definition as a bounded native canvas.
|
||||
///
|
||||
/// The graph comes from [PipelineDetail.graph] exactly as the reply pinned it
|
||||
/// for the selected version. Selecting any node, including a terminal, reports
|
||||
/// its key so the host can open the landed full-screen stage-definition page
|
||||
/// for that same pipeline id, name and resolved version. No run evidence is
|
||||
/// read, so nodes and terminals can never look visited.
|
||||
class PipelineGraphTab extends StatelessWidget {
|
||||
const PipelineGraphTab({
|
||||
super.key,
|
||||
required this.detail,
|
||||
required this.selectedStage,
|
||||
required this.onSelected,
|
||||
});
|
||||
|
||||
final PipelineDetail detail;
|
||||
|
||||
/// The selected node key, kept by the detail panel so it survives a tab
|
||||
/// switch. Null means nothing is selected.
|
||||
final String? selectedStage;
|
||||
|
||||
/// Reports the exact node key activated, including `#success`/`#failure`.
|
||||
final ValueChanged<String> onSelected;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final graph = detail.graph;
|
||||
if (graph == null) {
|
||||
return ListView(
|
||||
key: const Key('pipeline-graph-missing'),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Text(pipelineGraphMissing, style: pipelineMutedStyle(context)),
|
||||
],
|
||||
);
|
||||
}
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// The panel gives this tab the remaining bounded height. Cap the note
|
||||
// against that same slot so a short window or scaled text can only
|
||||
// scroll the note, never overflow the column or leave the canvas at
|
||||
// zero height.
|
||||
final noteLimit = constraints.hasBoundedHeight
|
||||
? constraints.maxHeight * pipelineGraphNoteShare
|
||||
: double.infinity;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_GraphGuidanceNote(
|
||||
maxHeight: noteLimit,
|
||||
slotHeight: constraints.hasBoundedHeight
|
||||
? constraints.maxHeight
|
||||
: double.infinity,
|
||||
),
|
||||
Expanded(
|
||||
child: DefinitionGraphView(
|
||||
key: const Key('pipeline-definition-graph'),
|
||||
graph: graph,
|
||||
selectedStage: selectedStage,
|
||||
onSelected: onSelected,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The guidance note, kept to a readable share of the tab without ever cutting
|
||||
/// a text line.
|
||||
///
|
||||
/// An earlier cap let the note end on a partially drawn row with no hint that
|
||||
/// more guidance existed. The note is measured with the same style, width and
|
||||
/// text scale its [Text] will use, so the visible part is always a whole number
|
||||
/// of lines, and the hidden rest scrolls behind the host's own scrollbar. That
|
||||
/// keeps a visible affordance while the graph below keeps at least half the
|
||||
/// slot.
|
||||
class _GraphGuidanceNote extends StatefulWidget {
|
||||
const _GraphGuidanceNote({required this.maxHeight, required this.slotHeight});
|
||||
|
||||
/// The note's starting share of the tab (see [pipelineGraphNoteShare]).
|
||||
final double maxHeight;
|
||||
|
||||
/// The whole tab slot, so two whole lines may exceed [maxHeight] while the
|
||||
/// canvas still keeps at least half of it.
|
||||
final double slotHeight;
|
||||
|
||||
@override
|
||||
State<_GraphGuidanceNote> createState() => _GraphGuidanceNoteState();
|
||||
}
|
||||
|
||||
class _GraphGuidanceNoteState extends State<_GraphGuidanceNote> {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final style = DefaultTextStyle.of(
|
||||
context,
|
||||
).style.merge(pipelineMutedStyle(context));
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(text: pipelineGraphNote, style: style),
|
||||
textDirection: Directionality.of(context),
|
||||
textScaler: MediaQuery.textScalerOf(context),
|
||||
)..layout(maxWidth: math.max(0, constraints.maxWidth - 32));
|
||||
final totalHeight = painter.height;
|
||||
final limit = _noteLimit(painter);
|
||||
final truncated = totalHeight > limit + 0.5;
|
||||
final visibleHeight = truncated
|
||||
? _wholeLineHeight(painter, limit)
|
||||
: totalHeight;
|
||||
final text = Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 0, 16, truncated ? 0 : 8),
|
||||
child: Text(pipelineGraphNote, style: style),
|
||||
);
|
||||
return SizedBox(
|
||||
key: const Key('pipeline-graph-note'),
|
||||
height: truncated ? visibleHeight : totalHeight + 8,
|
||||
child: truncated
|
||||
? _scrollbar(
|
||||
SingleChildScrollView(
|
||||
key: const Key('pipeline-graph-note-scroll'),
|
||||
controller: _scrollController,
|
||||
primary: false,
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: text,
|
||||
),
|
||||
)
|
||||
: text,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// The note's slot: its [pipelineGraphNoteShare] of the tab, or two whole
|
||||
/// lines when that share is shorter, and never more than half the tab so the
|
||||
/// canvas always keeps the other half.
|
||||
double _noteLimit(TextPainter painter) {
|
||||
if (!widget.slotHeight.isFinite) return widget.maxHeight;
|
||||
final lines = painter.computeLineMetrics();
|
||||
final lineHeight = lines.isEmpty
|
||||
? painter.preferredLineHeight
|
||||
: lines.first.height;
|
||||
return math.max(
|
||||
widget.maxHeight,
|
||||
math.min(lineHeight * 2, widget.slotHeight * 0.5),
|
||||
);
|
||||
}
|
||||
|
||||
/// The largest whole-line height that fits in [limit].
|
||||
///
|
||||
/// Whole lines keep the clipped edge from cutting through a glyph row. If
|
||||
/// even the first line is taller than the limit the row is clipped anyway:
|
||||
/// that only happens when the whole tab is barely two lines tall.
|
||||
double _wholeLineHeight(TextPainter painter, double limit) {
|
||||
final lines = painter.computeLineMetrics();
|
||||
var consumed = 0.0;
|
||||
for (final line in lines) {
|
||||
final next = consumed + line.height;
|
||||
if (next > limit + 0.5) break;
|
||||
consumed = next;
|
||||
}
|
||||
if (consumed > 0 || lines.isEmpty) return consumed;
|
||||
return math.min(lines.first.height, limit);
|
||||
}
|
||||
|
||||
/// The host's own scrollbar: visible whenever the note is clipped, and
|
||||
/// draggable with the pointer, so the rest is discoverable without a wheel.
|
||||
Widget _scrollbar(Widget child) {
|
||||
if (useCupertinoControls(context)) {
|
||||
return CupertinoScrollbar(
|
||||
key: const Key('pipeline-graph-note-scrollbar'),
|
||||
controller: _scrollController,
|
||||
thumbVisibility: true,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
return Scrollbar(
|
||||
key: const Key('pipeline-graph-note-scrollbar'),
|
||||
controller: _scrollController,
|
||||
thumbVisibility: true,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user