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
|
/// The run-detail sections in the web's order: Summary first, the run Graph
|
||||||
/// second, then the recorded Input, Output and Timeline.
|
/// second, then the recorded Input, Output and Timeline.
|
||||||
///
|
///
|
||||||
@@ -5,15 +8,23 @@
|
|||||||
/// are the same words. `renderedRunDetailTabs` decides which keys the strip
|
/// are the same words. `renderedRunDetailTabs` decides which keys the strip
|
||||||
/// draws, so Input and Output stay addressable without being tabs.
|
/// draws, so Input and Output stay addressable without being tabs.
|
||||||
enum RunDetailTab {
|
enum RunDetailTab {
|
||||||
summary('Summary'),
|
summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text),
|
||||||
graph('Graph'),
|
graph('Graph', Icons.account_tree_outlined, CupertinoIcons.arrow_branch),
|
||||||
input('Input'),
|
input('Input', Icons.input, CupertinoIcons.arrow_down_doc),
|
||||||
output('Output'),
|
output('Output', Icons.output, CupertinoIcons.arrow_up_doc),
|
||||||
timeline('Timeline'),
|
timeline('Timeline', Icons.timeline, CupertinoIcons.list_bullet),
|
||||||
artifacts('Artifacts'),
|
artifacts('Artifacts', Icons.inventory_2_outlined, CupertinoIcons.cube_box),
|
||||||
changes('Changes');
|
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;
|
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 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import 'run_detail_content.dart';
|
|
||||||
import 'run_detail_summary_fields.dart';
|
import 'run_detail_summary_fields.dart';
|
||||||
import 'run_detail_visit_facts.dart';
|
import 'run_detail_visit_facts.dart';
|
||||||
import 'run_field_body.dart';
|
import 'run_field_body.dart';
|
||||||
@@ -117,18 +116,19 @@ Widget runDetailFieldTab({
|
|||||||
required String empty,
|
required String empty,
|
||||||
required bool cupertino,
|
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) {
|
if (cupertino) {
|
||||||
return ListView(
|
return ListView(
|
||||||
key: Key('run-detail-tab-body-$tabKey'),
|
key: Key('run-detail-tab-body-$tabKey'),
|
||||||
children: [
|
children: [
|
||||||
CupertinoListSection.insetGrouped(
|
CupertinoListSection.insetGrouped(
|
||||||
children: [
|
children: [Padding(padding: const EdgeInsets.all(16), child: body)],
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: _CupertinoSelectableText(text),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -136,7 +136,7 @@ Widget runDetailFieldTab({
|
|||||||
return ListView(
|
return ListView(
|
||||||
key: Key('run-detail-tab-body-$tabKey'),
|
key: Key('run-detail-tab-body-$tabKey'),
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
children: [SelectableText(text)],
|
children: [body],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,11 +136,21 @@ class _RunDetailTabStripState extends State<RunDetailTabStrip> {
|
|||||||
key: _labels[tab],
|
key: _labels[tab],
|
||||||
child: KeyedSubtree(
|
child: KeyedSubtree(
|
||||||
key: ValueKey('run-detail-tab-${tab.name}'),
|
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
|
child: widget.bottom
|
||||||
? FittedBox(
|
? FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
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),
|
: Text(tab.label, maxLines: 1, softWrap: false),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -302,12 +302,24 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
|||||||
final title = detailTitle(run);
|
final title = detailTitle(run);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
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),
|
child: SafeArea(child: pane),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
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),
|
body: SafeArea(top: false, child: pane),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 3,
|
flex: 2,
|
||||||
fit: FlexFit.loose,
|
fit: FlexFit.loose,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
key: const Key('run-visit-facts'),
|
key: const Key('run-visit-facts'),
|
||||||
@@ -100,12 +100,8 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
RunVisitSectionStrip(
|
|
||||||
selected: _section,
|
|
||||||
onSelected: (section) => setState(() => _section = section),
|
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 5,
|
||||||
child: runVisitSectionBody(
|
child: runVisitSectionBody(
|
||||||
section: _section,
|
section: _section,
|
||||||
run: widget.run,
|
run: widget.run,
|
||||||
@@ -119,58 +115,27 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
|||||||
cupertino: widget.cupertino,
|
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) {
|
/// The visit's name; Back is the page bar's.
|
||||||
final close = widget.cupertino
|
Widget _bar(_VisitStyle style) => Padding(
|
||||||
? CupertinoButton(
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
key: const Key('run-visit-back'),
|
child: Text(
|
||||||
padding: EdgeInsets.zero,
|
widget.visit.title,
|
||||||
onPressed: widget.onClose,
|
key: const Key('run-visit-title'),
|
||||||
child: const Row(
|
style: style.heading,
|
||||||
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,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FactRow extends StatelessWidget {
|
class _FactRow extends StatelessWidget {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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_detail_tab_strip.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';
|
||||||
@@ -15,16 +14,28 @@ 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 {
|
||||||
input('Input'),
|
input('Input', Icons.input, CupertinoIcons.arrow_down_doc),
|
||||||
output('Output'),
|
output('Output', Icons.output, CupertinoIcons.arrow_up_doc),
|
||||||
artifacts('Artifacts'),
|
artifacts('Artifacts', Icons.inventory_2_outlined, CupertinoIcons.cube_box),
|
||||||
changes('Changes'),
|
changes(
|
||||||
session('Session'),
|
'Changes',
|
||||||
definition('Definition');
|
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;
|
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
|
/// The visit pane's native tab strip: a Material segmented button or a Cupertino
|
||||||
@@ -43,12 +54,22 @@ class RunVisitSectionStrip extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
final cupertino = usesCupertinoHost(context);
|
||||||
return Padding(
|
// A full-width bar under the section, as the run's own tabs on a phone.
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
final divider = cupertino
|
||||||
child: ScrollWhenOverflowing(
|
? CupertinoColors.separator.resolveFrom(context)
|
||||||
child: KeyedSubtree(
|
: Theme.of(context).colorScheme.outlineVariant;
|
||||||
key: const Key('run-visit-tabs'),
|
return DecoratedBox(
|
||||||
child: cupertino ? _cupertinoControl() : _materialControl(),
|
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},
|
selected: {selected},
|
||||||
showSelectedIcon: false,
|
showSelectedIcon: false,
|
||||||
|
expandedInsets: EdgeInsets.zero,
|
||||||
onSelectionChanged: (selection) => onSelected(selection.single),
|
onSelectionChanged: (selection) => onSelected(selection.single),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -73,7 +95,7 @@ class RunVisitSectionStrip extends StatelessWidget {
|
|||||||
children: {
|
children: {
|
||||||
for (final section in RunVisitSection.values)
|
for (final section in RunVisitSection.values)
|
||||||
section: Padding(
|
section: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||||
child: _label(section),
|
child: _label(section),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -81,7 +103,22 @@ class RunVisitSectionStrip extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _label(RunVisitSection section) => KeyedSubtree(
|
Widget _label(RunVisitSection section) => KeyedSubtree(
|
||||||
key: ValueKey('run-visit-tab-${section.name}'),
|
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() {
|
void main() {
|
||||||
for (final platform in RunDetailTestPlatform.values) {
|
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 '
|
testWidgets('${platform.name} tabs show recorded values and exact empty '
|
||||||
'wording', (tester) async {
|
'wording', (tester) async {
|
||||||
await openVisit(tester, platform);
|
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);
|
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);
|
await openVisitTab(tester, RunVisitSection.artifacts);
|
||||||
expect(find.text('plan.csv'), findsOneWidget);
|
expect(find.text('plan.csv'), findsOneWidget);
|
||||||
|
|||||||
Reference in New Issue
Block a user