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), // Stock dark theme so the forced `prefers-color-scheme` capture is // a real dark render rather than a duplicate light one. darkTheme: ThemeData( platform: TargetPlatform.android, brightness: Brightness.dark, ), themeMode: ThemeMode.system, home: const _Probe(cupertino: false), ), ); }