merge(app): land stage page tabs and tab icons
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The run-detail sections in the web's order: Summary first, the run Graph
|
||||
/// second, then the recorded Input, Output and Timeline.
|
||||
///
|
||||
@@ -5,15 +8,23 @@
|
||||
/// are the same words. `renderedRunDetailTabs` decides which keys the strip
|
||||
/// draws, so Input and Output stay addressable without being tabs.
|
||||
enum RunDetailTab {
|
||||
summary('Summary'),
|
||||
graph('Graph'),
|
||||
input('Input'),
|
||||
output('Output'),
|
||||
timeline('Timeline'),
|
||||
artifacts('Artifacts'),
|
||||
changes('Changes');
|
||||
summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text),
|
||||
graph('Graph', Icons.account_tree_outlined, CupertinoIcons.arrow_branch),
|
||||
input('Input', Icons.input, CupertinoIcons.arrow_down_doc),
|
||||
output('Output', Icons.output, CupertinoIcons.arrow_up_doc),
|
||||
timeline('Timeline', Icons.timeline, CupertinoIcons.list_bullet),
|
||||
artifacts('Artifacts', Icons.inventory_2_outlined, CupertinoIcons.cube_box),
|
||||
changes(
|
||||
'Changes',
|
||||
Icons.difference_outlined,
|
||||
CupertinoIcons.arrow_right_arrow_left,
|
||||
);
|
||||
|
||||
const RunDetailTab(this.label);
|
||||
const RunDetailTab(this.label, this.icon, this.cupertinoIcon);
|
||||
|
||||
final String label;
|
||||
|
||||
/// The tab's glyph, so a tab is recognisable at a glance.
|
||||
final IconData icon;
|
||||
final IconData cupertinoIcon;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_summary_fields.dart';
|
||||
import 'run_detail_visit_facts.dart';
|
||||
import 'run_field_body.dart';
|
||||
@@ -117,18 +116,19 @@ Widget runDetailFieldTab({
|
||||
required String empty,
|
||||
required bool cupertino,
|
||||
}) {
|
||||
final text = detailEmpty(value) ? empty : detailJson(value);
|
||||
// The recorded fields by name, as values, never raw JSON.
|
||||
final body = RunFieldBody(
|
||||
value: value,
|
||||
empty: empty,
|
||||
cupertino: cupertino,
|
||||
textBuilder: cupertino ? _CupertinoSelectableText.new : null,
|
||||
);
|
||||
if (cupertino) {
|
||||
return ListView(
|
||||
key: Key('run-detail-tab-body-$tabKey'),
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _CupertinoSelectableText(text),
|
||||
),
|
||||
],
|
||||
children: [Padding(padding: const EdgeInsets.all(16), child: body)],
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -136,7 +136,7 @@ Widget runDetailFieldTab({
|
||||
return ListView(
|
||||
key: Key('run-detail-tab-body-$tabKey'),
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [SelectableText(text)],
|
||||
children: [body],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,11 +136,21 @@ class _RunDetailTabStripState extends State<RunDetailTabStrip> {
|
||||
key: _labels[tab],
|
||||
child: KeyedSubtree(
|
||||
key: ValueKey('run-detail-tab-${tab.name}'),
|
||||
// A full-width bar shrinks a long label rather than overflowing it.
|
||||
// A full-width bar shrinks a long label rather than overflowing it,
|
||||
// and shows the tab's glyph above its name.
|
||||
child: widget.bottom
|
||||
? FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(tab.label, maxLines: 1, softWrap: false),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
usesCupertinoHost(context) ? tab.cupertinoIcon : tab.icon,
|
||||
size: 18,
|
||||
),
|
||||
Text(tab.label, maxLines: 1, softWrap: false),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Text(tab.label, maxLines: 1, softWrap: false),
|
||||
),
|
||||
|
||||
@@ -302,12 +302,24 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
final title = detailTitle(run);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(middle: Text(title)),
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
leading: CupertinoNavigationBarBackButton(
|
||||
key: const Key('run-visit-back'),
|
||||
onPressed: () => Navigator.of(pageContext).pop(),
|
||||
),
|
||||
middle: Text(title),
|
||||
),
|
||||
child: SafeArea(child: pane),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(title)),
|
||||
appBar: AppBar(
|
||||
leading: BackButton(
|
||||
key: const Key('run-visit-back'),
|
||||
onPressed: () => Navigator.of(pageContext).pop(),
|
||||
),
|
||||
title: Text(title),
|
||||
),
|
||||
body: SafeArea(top: false, child: pane),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -74,7 +74,7 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 3,
|
||||
flex: 2,
|
||||
fit: FlexFit.loose,
|
||||
child: SingleChildScrollView(
|
||||
key: const Key('run-visit-facts'),
|
||||
@@ -100,12 +100,8 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
||||
),
|
||||
),
|
||||
),
|
||||
RunVisitSectionStrip(
|
||||
selected: _section,
|
||||
onSelected: (section) => setState(() => _section = section),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 5,
|
||||
child: runVisitSectionBody(
|
||||
section: _section,
|
||||
run: widget.run,
|
||||
@@ -119,58 +115,27 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
||||
cupertino: widget.cupertino,
|
||||
),
|
||||
),
|
||||
// The sections are tabs at the bottom, under what they show.
|
||||
SafeArea(
|
||||
top: false,
|
||||
child: RunVisitSectionStrip(
|
||||
selected: _section,
|
||||
onSelected: (section) => setState(() => _section = section),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _bar(_VisitStyle style) {
|
||||
final close = widget.cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('run-visit-back'),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: widget.onClose,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(CupertinoIcons.back),
|
||||
SizedBox(width: 4),
|
||||
Flexible(child: Text('Back to timeline')),
|
||||
],
|
||||
),
|
||||
)
|
||||
: TextButton.icon(
|
||||
key: const Key('run-visit-back'),
|
||||
onPressed: widget.onClose,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
label: const Text('Back to timeline'),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// The close and change actions wrap instead of overflowing when the
|
||||
// pane is narrow or the text is scaled.
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [close],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.visit.title,
|
||||
key: const Key('run-visit-title'),
|
||||
style: style.heading,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
/// The visit's name; Back is the page bar's.
|
||||
Widget _bar(_VisitStyle style) => Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Text(
|
||||
widget.visit.title,
|
||||
key: const Key('run-visit-title'),
|
||||
style: style.heading,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _FactRow extends StatelessWidget {
|
||||
|
||||
@@ -5,7 +5,6 @@ import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../changes/changes.dart';
|
||||
import 'run_detail_tab_bodies.dart';
|
||||
import 'run_detail_tab_strip.dart';
|
||||
import 'run_detail_visit_artifacts.dart';
|
||||
import 'run_detail_visit_definition.dart';
|
||||
import 'run_detail_visit_facts.dart';
|
||||
@@ -15,16 +14,28 @@ import 'run_detail_visit_session.dart';
|
||||
/// client follows: the turn's Input and Output, its Artifacts, the files this
|
||||
/// visit changed, its Session and the authored Definition.
|
||||
enum RunVisitSection {
|
||||
input('Input'),
|
||||
output('Output'),
|
||||
artifacts('Artifacts'),
|
||||
changes('Changes'),
|
||||
session('Session'),
|
||||
definition('Definition');
|
||||
input('Input', Icons.input, CupertinoIcons.arrow_down_doc),
|
||||
output('Output', Icons.output, CupertinoIcons.arrow_up_doc),
|
||||
artifacts('Artifacts', Icons.inventory_2_outlined, CupertinoIcons.cube_box),
|
||||
changes(
|
||||
'Changes',
|
||||
Icons.difference_outlined,
|
||||
CupertinoIcons.arrow_right_arrow_left,
|
||||
),
|
||||
session('Session', Icons.forum_outlined, CupertinoIcons.chat_bubble_2),
|
||||
definition(
|
||||
'Definition',
|
||||
Icons.description_outlined,
|
||||
CupertinoIcons.doc_plaintext,
|
||||
);
|
||||
|
||||
const RunVisitSection(this.label);
|
||||
const RunVisitSection(this.label, this.icon, this.cupertinoIcon);
|
||||
|
||||
final String label;
|
||||
|
||||
/// The section's glyph, so a tab is recognisable at a glance.
|
||||
final IconData icon;
|
||||
final IconData cupertinoIcon;
|
||||
}
|
||||
|
||||
/// The visit pane's native tab strip: a Material segmented button or a Cupertino
|
||||
@@ -43,12 +54,22 @@ class RunVisitSectionStrip extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: ScrollWhenOverflowing(
|
||||
child: KeyedSubtree(
|
||||
key: const Key('run-visit-tabs'),
|
||||
child: cupertino ? _cupertinoControl() : _materialControl(),
|
||||
// A full-width bar under the section, as the run's own tabs on a phone.
|
||||
final divider = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(top: BorderSide(color: divider, width: 0.5)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 8, 8, 8),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: KeyedSubtree(
|
||||
key: const Key('run-visit-tabs'),
|
||||
child: cupertino ? _cupertinoControl() : _materialControl(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -61,6 +82,7 @@ class RunVisitSectionStrip extends StatelessWidget {
|
||||
],
|
||||
selected: {selected},
|
||||
showSelectedIcon: false,
|
||||
expandedInsets: EdgeInsets.zero,
|
||||
onSelectionChanged: (selection) => onSelected(selection.single),
|
||||
);
|
||||
|
||||
@@ -73,7 +95,7 @@ class RunVisitSectionStrip extends StatelessWidget {
|
||||
children: {
|
||||
for (final section in RunVisitSection.values)
|
||||
section: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||
child: _label(section),
|
||||
),
|
||||
},
|
||||
@@ -81,7 +103,22 @@ class RunVisitSectionStrip extends StatelessWidget {
|
||||
|
||||
Widget _label(RunVisitSection section) => KeyedSubtree(
|
||||
key: ValueKey('run-visit-tab-${section.name}'),
|
||||
child: Text(section.label, maxLines: 1, softWrap: false),
|
||||
// Six sections share the width; a long label shrinks rather than clips.
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Builder(
|
||||
builder: (context) => Icon(
|
||||
usesCupertinoHost(context) ? section.cupertinoIcon : section.icon,
|
||||
size: 18,
|
||||
),
|
||||
),
|
||||
Text(section.label, maxLines: 1, softWrap: false),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,45 @@ import 'run_detail_visit_support.dart';
|
||||
|
||||
void main() {
|
||||
for (final platform in RunDetailTestPlatform.values) {
|
||||
testWidgets('${platform.name} stage tabs sit at the bottom with one Back', (
|
||||
tester,
|
||||
) async {
|
||||
await openVisit(tester, platform, size: const Size(390, 844));
|
||||
final tabs = tester.getRect(find.byKey(const Key('run-visit-tabs')));
|
||||
expect(tabs.bottom, greaterThan(844 - 90));
|
||||
expect(find.text('Back to timeline'), findsNothing);
|
||||
expect(find.text('Back'), findsNothing);
|
||||
// The page bar's own Back is the only one.
|
||||
expect(find.byKey(const Key('run-visit-back')), findsOneWidget);
|
||||
// Every tab shows its glyph above its name.
|
||||
for (final section in RunVisitSection.values) {
|
||||
final tab = find.byKey(ValueKey('run-visit-tab-${section.name}'));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: tab,
|
||||
matching: find.byIcon(
|
||||
platform == RunDetailTestPlatform.cupertino
|
||||
? section.cupertinoIcon
|
||||
: section.icon,
|
||||
),
|
||||
),
|
||||
findsOneWidget,
|
||||
reason: section.name,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('${platform.name} tabs show recorded values and exact empty '
|
||||
'wording', (tester) async {
|
||||
await openVisit(tester, platform);
|
||||
|
||||
expect(find.textContaining('"prompt": "Ship it."'), findsOneWidget);
|
||||
// Each field by name with its value, never raw JSON.
|
||||
expect(find.text('prompt'), findsOneWidget);
|
||||
expect(find.text('Ship it.'), findsOneWidget);
|
||||
expect(find.textContaining('"prompt"'), findsNothing);
|
||||
await openVisitTab(tester, RunVisitSection.output);
|
||||
expect(find.textContaining('"result": "ok"'), findsOneWidget);
|
||||
expect(find.text('result'), findsOneWidget);
|
||||
expect(find.text('ok'), findsOneWidget);
|
||||
|
||||
await openVisitTab(tester, RunVisitSection.artifacts);
|
||||
expect(find.text('plan.csv'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user