feat(app): add native content-sized graph stage node
One content-sized stage node as an ordinary native control. Material uses stock Card.outlined/Card.filled inside an InkWell; Cupertino uses CupertinoButton.tinted/filled. onSelected reports the definition key verbatim, one merged button semantics node carries the exact label and selected state, recorded status is shown only when the caller supplies it, and invisible U+200B break opportunities reproduce the web's anywhere wrapping. Painted-boundary and painted-surface tests cover the UI-review 2x outline and Cupertino container defects.
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pipelines_app/features/graph/domain/graph_definition.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
|
||||
|
||||
const _longKey = 'implementer-with-an-unshortened-stage-label';
|
||||
const _oneXKey = 'narrow-one-x-stage-key-that-wraps';
|
||||
|
||||
/// Keys rendered in a 150 logical px box, with the text scale applied to them.
|
||||
const _scaled = {_longKey: 2.0, _oneXKey: 1.0};
|
||||
|
||||
const _nodes = [
|
||||
GraphNode(key: 'plan', terminal: false, stageIndex: 0),
|
||||
GraphNode(key: 'build', terminal: false, stageIndex: 1),
|
||||
GraphNode(key: _longKey, terminal: false, stageIndex: 2),
|
||||
GraphNode(key: _oneXKey, terminal: false, stageIndex: 3),
|
||||
GraphNode(key: '#success', terminal: true),
|
||||
GraphNode(key: '#failure', terminal: true),
|
||||
];
|
||||
|
||||
/// A fixture-only page: one measured node per definition identity, with the
|
||||
/// selected key reported so a browser click can prove the exact callback.
|
||||
class _Probe extends StatefulWidget {
|
||||
const _Probe({required this.cupertino});
|
||||
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
State<_Probe> createState() => _ProbeState();
|
||||
}
|
||||
|
||||
class _ProbeState extends State<_Probe> {
|
||||
String? _selected = 'build';
|
||||
|
||||
Widget _node(GraphNode node) {
|
||||
final child = GraphStageNode(
|
||||
node: node,
|
||||
recordedStatus: node.key == 'build' ? 'running' : null,
|
||||
selected: node.key == _selected,
|
||||
onSelected: (key) => setState(() => _selected = key),
|
||||
);
|
||||
final scale = _scaled[node.key];
|
||||
if (scale == null) return child;
|
||||
return MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(scale)),
|
||||
child: SizedBox(width: 150, child: child),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final page = ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
Text('Selected: ${_selected ?? 'none'}'),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 12,
|
||||
children: [for (final node in _nodes) _node(node)],
|
||||
),
|
||||
],
|
||||
);
|
||||
return widget.cupertino
|
||||
? CupertinoPageScaffold(child: SafeArea(child: page))
|
||||
: Scaffold(body: SafeArea(child: page));
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
final cupertino = Uri.base.queryParameters['style'] == 'cupertino';
|
||||
runApp(
|
||||
cupertino
|
||||
? CupertinoApp(home: const _Probe(cupertino: true))
|
||||
: MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: const _Probe(cupertino: false),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user