diff --git a/app/lib/features/runs/ui/run_detail_tab_bodies.dart b/app/lib/features/runs/ui/run_detail_tab_bodies.dart index ca94f650..fe30c67a 100644 --- a/app/lib/features/runs/ui/run_detail_tab_bodies.dart +++ b/app/lib/features/runs/ui/run_detail_tab_bodies.dart @@ -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], ); } diff --git a/app/lib/features/runs/ui/run_detail_tabs.dart b/app/lib/features/runs/ui/run_detail_tabs.dart index 4f5e2f68..0cda33a3 100644 --- a/app/lib/features/runs/ui/run_detail_tabs.dart +++ b/app/lib/features/runs/ui/run_detail_tabs.dart @@ -302,12 +302,24 @@ class _RunDetailTabsState extends State { 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), ); }, diff --git a/app/lib/features/runs/ui/run_detail_visit.dart b/app/lib/features/runs/ui/run_detail_visit.dart index 447fdfee..289924ec 100644 --- a/app/lib/features/runs/ui/run_detail_visit.dart +++ b/app/lib/features/runs/ui/run_detail_visit.dart @@ -74,7 +74,7 @@ class _RunVisitPaneState extends State { 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 { ), ), ), - 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 { 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 { diff --git a/app/lib/features/runs/ui/run_detail_visit_sections.dart b/app/lib/features/runs/ui/run_detail_visit_sections.dart index 59d77994..15d692af 100644 --- a/app/lib/features/runs/ui/run_detail_visit_sections.dart +++ b/app/lib/features/runs/ui/run_detail_visit_sections.dart @@ -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'; @@ -43,12 +42,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 +70,7 @@ class RunVisitSectionStrip extends StatelessWidget { ], selected: {selected}, showSelectedIcon: false, + expandedInsets: EdgeInsets.zero, onSelectionChanged: (selection) => onSelected(selection.single), ); @@ -73,7 +83,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 +91,11 @@ 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: Text(section.label, maxLines: 1, softWrap: false), + ), ); } diff --git a/app/test/features/runs/ui/run_detail_visit_sections_test.dart b/app/test/features/runs/ui/run_detail_visit_sections_test.dart index 9c3abe0c..920627f1 100644 --- a/app/test/features/runs/ui/run_detail_visit_sections_test.dart +++ b/app/test/features/runs/ui/run_detail_visit_sections_test.dart @@ -11,13 +11,29 @@ 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); + }); + 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);