feat(app): stage tabs are Summary (input and output), Artifacts, Changes and More (session and definition)
This commit is contained in:
@@ -51,7 +51,7 @@ class RunVisitPane extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RunVisitPaneState extends State<RunVisitPane> {
|
class _RunVisitPaneState extends State<RunVisitPane> {
|
||||||
RunVisitSection _section = RunVisitSection.input;
|
RunVisitSection _section = RunVisitSection.summary;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant RunVisitPane oldWidget) {
|
void didUpdateWidget(covariant RunVisitPane oldWidget) {
|
||||||
@@ -59,7 +59,7 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
|||||||
// A different visit starts at its first section, like a newly opened pane.
|
// A different visit starts at its first section, like a newly opened pane.
|
||||||
if (oldWidget.visit.sequence != widget.visit.sequence ||
|
if (oldWidget.visit.sequence != widget.visit.sequence ||
|
||||||
oldWidget.visit.stage != widget.visit.stage) {
|
oldWidget.visit.stage != widget.visit.stage) {
|
||||||
_section = RunVisitSection.input;
|
_section = RunVisitSection.summary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import '../../../core/api_gateway.dart';
|
|||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import '../../changes/changes.dart';
|
import '../../changes/changes.dart';
|
||||||
import 'run_detail_tab_bodies.dart';
|
import 'run_detail_tab_bodies.dart';
|
||||||
|
import 'run_field_body.dart';
|
||||||
import 'run_detail_visit_artifacts.dart';
|
import 'run_detail_visit_artifacts.dart';
|
||||||
import 'run_detail_visit_definition.dart';
|
import 'run_detail_visit_definition.dart';
|
||||||
import 'run_detail_visit_facts.dart';
|
import 'run_detail_visit_facts.dart';
|
||||||
@@ -14,6 +15,8 @@ import 'run_detail_visit_session.dart';
|
|||||||
/// client follows: the turn's Input and Output, its Artifacts, the files this
|
/// client follows: the turn's Input and Output, its Artifacts, the files this
|
||||||
/// visit changed, its Session and the authored Definition.
|
/// visit changed, its Session and the authored Definition.
|
||||||
enum RunVisitSection {
|
enum RunVisitSection {
|
||||||
|
summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text),
|
||||||
|
more('More', Icons.more_horiz, CupertinoIcons.ellipsis_circle),
|
||||||
input('Input', Icons.input, CupertinoIcons.arrow_down_doc),
|
input('Input', Icons.input, CupertinoIcons.arrow_down_doc),
|
||||||
output('Output', Icons.output, CupertinoIcons.arrow_up_doc),
|
output('Output', Icons.output, CupertinoIcons.arrow_up_doc),
|
||||||
artifacts('Artifacts', Icons.inventory_2_outlined, CupertinoIcons.cube_box),
|
artifacts('Artifacts', Icons.inventory_2_outlined, CupertinoIcons.cube_box),
|
||||||
@@ -77,7 +80,7 @@ class RunVisitSectionStrip extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _materialControl() => SegmentedButton<RunVisitSection>(
|
Widget _materialControl() => SegmentedButton<RunVisitSection>(
|
||||||
segments: [
|
segments: [
|
||||||
for (final section in RunVisitSection.values)
|
for (final section in shownVisitSections)
|
||||||
ButtonSegment(value: section, label: _label(section)),
|
ButtonSegment(value: section, label: _label(section)),
|
||||||
],
|
],
|
||||||
selected: {selected},
|
selected: {selected},
|
||||||
@@ -93,7 +96,7 @@ class RunVisitSectionStrip extends StatelessWidget {
|
|||||||
groupValue: selected,
|
groupValue: selected,
|
||||||
onValueChanged: onSelected,
|
onValueChanged: onSelected,
|
||||||
children: {
|
children: {
|
||||||
for (final section in RunVisitSection.values)
|
for (final section in shownVisitSections)
|
||||||
section: Padding(
|
section: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||||
child: _label(section),
|
child: _label(section),
|
||||||
@@ -122,6 +125,22 @@ class RunVisitSectionStrip extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The stage page's tabs: Summary (Input and Output), Artifacts, Changes and
|
||||||
|
/// More (Session and Definition). The finer sections stay addressable.
|
||||||
|
const shownVisitSections = [
|
||||||
|
RunVisitSection.summary,
|
||||||
|
RunVisitSection.artifacts,
|
||||||
|
RunVisitSection.changes,
|
||||||
|
RunVisitSection.more,
|
||||||
|
];
|
||||||
|
|
||||||
|
/// The tab that shows [section].
|
||||||
|
RunVisitSection visitTabFor(RunVisitSection section) => switch (section) {
|
||||||
|
RunVisitSection.input || RunVisitSection.output => RunVisitSection.summary,
|
||||||
|
RunVisitSection.session || RunVisitSection.definition => RunVisitSection.more,
|
||||||
|
_ => section,
|
||||||
|
};
|
||||||
|
|
||||||
/// The selected section's body for one recorded visit.
|
/// The selected section's body for one recorded visit.
|
||||||
Widget runVisitSectionBody({
|
Widget runVisitSectionBody({
|
||||||
required RunVisitSection section,
|
required RunVisitSection section,
|
||||||
@@ -135,7 +154,45 @@ Widget runVisitSectionBody({
|
|||||||
required String configuredEndpoint,
|
required String configuredEndpoint,
|
||||||
required bool cupertino,
|
required bool cupertino,
|
||||||
}) {
|
}) {
|
||||||
|
Widget body(RunVisitSection section) => runVisitSectionBody(
|
||||||
|
section: section,
|
||||||
|
run: run,
|
||||||
|
step: step,
|
||||||
|
visitIndex: visitIndex,
|
||||||
|
stageKey: stageKey,
|
||||||
|
runSteps: runSteps,
|
||||||
|
gateway: gateway,
|
||||||
|
onRunChanged: onRunChanged,
|
||||||
|
configuredEndpoint: configuredEndpoint,
|
||||||
|
cupertino: cupertino,
|
||||||
|
);
|
||||||
switch (section) {
|
switch (section) {
|
||||||
|
case RunVisitSection.summary:
|
||||||
|
// Input then Output, each under its own heading.
|
||||||
|
return ListView(
|
||||||
|
key: const Key('run-visit-body-summary'),
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
children: [
|
||||||
|
_heading('Input', cupertino),
|
||||||
|
RunFieldBody(
|
||||||
|
value: step['input'],
|
||||||
|
empty: visitEmptyInput,
|
||||||
|
cupertino: cupertino,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_heading('Output', cupertino),
|
||||||
|
RunFieldBody(
|
||||||
|
value: step['output'],
|
||||||
|
empty: visitEmptyOutput,
|
||||||
|
cupertino: cupertino,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
case RunVisitSection.more:
|
||||||
|
return _MoreSection(
|
||||||
|
session: body(RunVisitSection.session),
|
||||||
|
definition: body(RunVisitSection.definition),
|
||||||
|
);
|
||||||
case RunVisitSection.input:
|
case RunVisitSection.input:
|
||||||
return runDetailFieldTab(
|
return runDetailFieldTab(
|
||||||
tabKey: 'visit-input',
|
tabKey: 'visit-input',
|
||||||
@@ -183,3 +240,68 @@ Widget runVisitSectionBody({
|
|||||||
return RunVisitDefinition(run: run, stageKey: stageKey);
|
return RunVisitDefinition(run: run, stageKey: stageKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _heading(String text, bool cupertino) => Builder(
|
||||||
|
builder: (context) => Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 6),
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 15,
|
||||||
|
color: cupertino
|
||||||
|
? CupertinoColors.label.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Session and Definition behind one tab, with a small switch between them.
|
||||||
|
class _MoreSection extends StatefulWidget {
|
||||||
|
const _MoreSection({required this.session, required this.definition});
|
||||||
|
|
||||||
|
final Widget session;
|
||||||
|
final Widget definition;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_MoreSection> createState() => _MoreSectionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MoreSectionState extends State<_MoreSection> {
|
||||||
|
var _definition = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino = usesCupertinoHost(context);
|
||||||
|
final control = cupertino
|
||||||
|
? CupertinoSlidingSegmentedControl<bool>(
|
||||||
|
key: const Key('run-visit-more-switch'),
|
||||||
|
groupValue: _definition,
|
||||||
|
onValueChanged: (value) =>
|
||||||
|
setState(() => _definition = value ?? false),
|
||||||
|
children: const {false: Text('Session'), true: Text('Definition')},
|
||||||
|
)
|
||||||
|
: SegmentedButton<bool>(
|
||||||
|
key: const Key('run-visit-more-switch'),
|
||||||
|
showSelectedIcon: false,
|
||||||
|
segments: const [
|
||||||
|
ButtonSegment(value: false, label: Text('Session')),
|
||||||
|
ButtonSegment(value: true, label: Text('Definition')),
|
||||||
|
],
|
||||||
|
selected: {_definition},
|
||||||
|
onSelectionChanged: (value) =>
|
||||||
|
setState(() => _definition = value.single),
|
||||||
|
);
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||||
|
child: control,
|
||||||
|
),
|
||||||
|
Expanded(child: _definition ? widget.definition : widget.session),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,8 +21,18 @@ void main() {
|
|||||||
expect(find.text('Back'), findsNothing);
|
expect(find.text('Back'), findsNothing);
|
||||||
// The page bar's own Back is the only one.
|
// The page bar's own Back is the only one.
|
||||||
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
|
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
|
||||||
|
// Four tabs: Summary, Artifacts, Changes, More.
|
||||||
|
expect(shownVisitSections, [
|
||||||
|
RunVisitSection.summary,
|
||||||
|
RunVisitSection.artifacts,
|
||||||
|
RunVisitSection.changes,
|
||||||
|
RunVisitSection.more,
|
||||||
|
]);
|
||||||
|
// Summary holds both Input and Output.
|
||||||
|
expect(find.text('Input'), findsOneWidget);
|
||||||
|
expect(find.text('Output'), findsOneWidget);
|
||||||
// Every tab shows its glyph above its name.
|
// Every tab shows its glyph above its name.
|
||||||
for (final section in RunVisitSection.values) {
|
for (final section in shownVisitSections) {
|
||||||
final tab = find.byKey(ValueKey('run-visit-tab-${section.name}'));
|
final tab = find.byKey(ValueKey('run-visit-tab-${section.name}'));
|
||||||
expect(
|
expect(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
|
|||||||
@@ -115,10 +115,24 @@ Future<void> openVisit(
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Opens the tab showing [section]: Input and Output are on Summary, Session
|
||||||
|
/// and Definition behind More's switch.
|
||||||
Future<void> openVisitTab(WidgetTester tester, RunVisitSection section) async {
|
Future<void> openVisitTab(WidgetTester tester, RunVisitSection section) async {
|
||||||
final tab = find.byKey(ValueKey('run-visit-tab-${section.name}'));
|
final shown = visitTabFor(section);
|
||||||
|
final tab = find.byKey(ValueKey('run-visit-tab-${shown.name}'));
|
||||||
await tester.ensureVisible(tab);
|
await tester.ensureVisible(tab);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(tab);
|
await tester.tap(tab);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
if (section == RunVisitSection.session ||
|
||||||
|
section == RunVisitSection.definition) {
|
||||||
|
final choice = find.descendant(
|
||||||
|
of: find.byKey(const Key('run-visit-more-switch')),
|
||||||
|
matching: find.text(
|
||||||
|
section == RunVisitSection.session ? 'Session' : 'Definition',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.tap(choice);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user