121 lines
3.5 KiB
Dart
121 lines
3.5 KiB
Dart
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() => <String, dynamic>{
|
|
'stages': <dynamic>[
|
|
<String, dynamic>{
|
|
'key': 'plan',
|
|
'type': 'model',
|
|
'edges': <String, String?>{'success': 'build', 'error': '#'},
|
|
'fallback_error': true,
|
|
},
|
|
<String, dynamic>{
|
|
'key': 'build',
|
|
'type': 'model',
|
|
'edges': <String, String?>{'success': _longKey, 'retry': 'build'},
|
|
},
|
|
<String, dynamic>{
|
|
'key': _longKey,
|
|
'type': 'model',
|
|
'edges': <String, String?>{'success': 'audit', 'blocked': '#failure'},
|
|
},
|
|
<String, dynamic>{
|
|
'key': 'audit',
|
|
'type': 'model',
|
|
'edges': <String, String?>{'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),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|