import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart'; const String _longKey = 'implementer-with-an-unusually-long-stage-label'; /// A definition with forward, fallback, self-loop and terminal edges so one /// canvas shows measured wrapping nodes, native outcome labels and arrows. JsonMap _definition() => { 'stages': [ { 'key': 'plan', 'type': 'model', 'edges': {'success': 'build', 'error': '#'}, 'fallback_error': true, }, { 'key': 'build', 'type': 'model', 'edges': {'success': _longKey, 'retry': 'build'}, }, { 'key': _longKey, 'type': 'model', 'edges': {'success': 'audit', 'blocked': '#failure'}, }, { 'key': 'audit', 'type': 'model', 'edges': {'success': '#success', 'error': '#failure'}, }, ], }; /// Isolated browser fixture for `DefinitionGraphView` only. /// /// Not wired into the app or shell. `style=cupertino` selects the native /// Cupertino host, `scale=2` applies a real 2x text scale to the graph viewport, /// and a click reports the exact stage key in the status line. void main() { final parameters = Uri.base.queryParameters; final cupertino = parameters['style'] == 'cupertino'; final scale = double.tryParse(parameters['scale'] ?? '') ?? 1; runApp(_ProbeApp(cupertino: cupertino, scale: scale)); } class _ProbeApp extends StatelessWidget { const _ProbeApp({required this.cupertino, required this.scale}); final bool cupertino; final double scale; @override Widget build(BuildContext context) { final page = _ProbePage(scale: scale); if (cupertino) { return CupertinoApp( home: CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar( middle: Text('Definition graph'), ), child: SafeArea(child: page), ), ); } return MaterialApp( theme: ThemeData(platform: TargetPlatform.android), darkTheme: ThemeData( platform: TargetPlatform.android, brightness: Brightness.dark, ), themeMode: ThemeMode.system, home: Scaffold( appBar: AppBar(title: const Text('Definition graph')), body: SafeArea(child: page), ), ); } } class _ProbePage extends StatefulWidget { const _ProbePage({required this.scale}); final double scale; @override State<_ProbePage> createState() => _ProbePageState(); } class _ProbePageState extends State<_ProbePage> { String? _selected = 'build'; @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Selected: ${_selected ?? 'none'}'), const SizedBox(height: 8), Expanded( child: MediaQuery( data: MediaQuery.of( context, ).copyWith(textScaler: TextScaler.linear(widget.scale)), child: DefinitionGraphView( graph: _definition(), selectedStage: _selected, onSelected: (key) => setState(() => _selected = key), ), ), ), ], ), ); } }