From 2da375ccce14528305d19416678bc2667520afa9 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 20:57:08 +0000 Subject: [PATCH] Adapt remaining feature popups for desktop Use the shared anchored choices and bounded details dialogs for diff form and artifact facts while preserving narrow Material sheets. Cover both width branches and dismissal behavior. --- .../artifacts/ui/artifact_viewer_body.dart | 7 +- .../changes/widgets/diff_form_control.dart | 13 ++-- app/notes/material-cleanup-feature-surface.md | 8 ++ .../changes/desktop_feature_popups_test.dart | 74 +++++++++++++++++++ 4 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 app/test/features/changes/desktop_feature_popups_test.dart diff --git a/app/lib/features/artifacts/ui/artifact_viewer_body.dart b/app/lib/features/artifacts/ui/artifact_viewer_body.dart index 903ba0d9..552a2227 100644 --- a/app/lib/features/artifacts/ui/artifact_viewer_body.dart +++ b/app/lib/features/artifacts/ui/artifact_viewer_body.dart @@ -2,6 +2,8 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; +import '../../../ui/adaptive/app_popups.dart'; + import '../../../ui/adaptive/floating_bar_layout.dart'; import '../actions/artifact_file_actions.dart'; import '../actions/artifact_file_bridge.dart'; @@ -168,9 +170,8 @@ class ArtifactViewerInfoAction extends StatelessWidget { final Widget facts; void _show(BuildContext context) { - showModalBottomSheet( - context: context, - showDragHandle: true, + showAppDetails( + context, builder: (context) => SafeArea( child: SingleChildScrollView( padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), diff --git a/app/lib/features/changes/widgets/diff_form_control.dart b/app/lib/features/changes/widgets/diff_form_control.dart index d8c6af55..2b4a939f 100644 --- a/app/lib/features/changes/widgets/diff_form_control.dart +++ b/app/lib/features/changes/widgets/diff_form_control.dart @@ -2,6 +2,8 @@ import 'dart:math' as math; import 'package:flutter/material.dart'; +import '../../../ui/adaptive/app_popups.dart'; + enum DiffForm { rendered, raw } const diffFormLabels = { @@ -48,7 +50,7 @@ Widget diffFormControl( ); } -/// Native action sheet/bottom sheet when fixed segment labels cannot fit. +/// An anchored desktop menu or narrow sheet when segment labels cannot fit. Widget diffFormMenu( BuildContext context, { required DiffForm form, @@ -59,9 +61,8 @@ Widget diffFormMenu( constraints: const BoxConstraints(minWidth: 48, minHeight: 48), padding: EdgeInsets.zero, icon: const Icon(Icons.more_vert, size: 28), - onPressed: () => showModalBottomSheet( - context: context, - showDragHandle: true, + onPressed: () => showAppChoiceMenu( + context, builder: (sheetContext) => SafeArea( child: Column( mainAxisSize: MainAxisSize.min, @@ -77,13 +78,13 @@ Widget diffFormMenu( ), ), for (final entry in diffFormLabels.entries) - ListTile( - title: Text(entry.value), + AppChoiceMenuItem( selected: entry.key == form, onTap: () { Navigator.of(sheetContext).pop(); onChanged(entry.key); }, + child: Text(entry.value), ), ], ), diff --git a/app/notes/material-cleanup-feature-surface.md b/app/notes/material-cleanup-feature-surface.md index 649815fa..f42c1125 100644 --- a/app/notes/material-cleanup-feature-surface.md +++ b/app/notes/material-cleanup-feature-surface.md @@ -14,3 +14,11 @@ Material widgets and layouts. - Remaining shared compatibility metadata/flags are outside this focused edit and should be removed only after all callers migrate during final integration. + +## Remaining desktop popups + +The manager completed two additional unconditional-sheet paths from the audit: +diff-form choices now use the shared anchored choice menu on desktop, and +artifact facts use the shared bounded details dialog. Narrow layouts retain +Material bottom sheets. Wide/narrow selection and dismissal regressions plus +the artifact viewer page tests passed: 24 tests, zero failures. diff --git a/app/test/features/changes/desktop_feature_popups_test.dart b/app/test/features/changes/desktop_feature_popups_test.dart new file mode 100644 index 00000000..376e6c0d --- /dev/null +++ b/app/test/features/changes/desktop_feature_popups_test.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_body.dart'; +import 'package:pipelines_app/features/changes/widgets/diff_form_control.dart'; + +void main() { + for (final width in [400.0, 1000.0]) { + testWidgets('diff choices adapt to app width $width', (tester) async { + tester.view.physicalSize = Size(width, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + DiffForm? selected; + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Align( + alignment: Alignment.topLeft, + child: Builder( + builder: (context) => diffFormMenu( + context, + form: DiffForm.rendered, + onChanged: (value) => selected = value, + ), + ), + ), + ), + ), + ); + await tester.tap(find.byTooltip('Diff form')); + await tester.pumpAndSettle(); + expect( + find.byType(BottomSheet), + width < 600 ? findsOneWidget : findsNothing, + ); + expect( + find.byKey(const ValueKey('app-choice-menu')), + width >= 600 ? findsOneWidget : findsNothing, + ); + await tester.tap(find.text('Raw patch')); + await tester.pumpAndSettle(); + expect(selected, DiffForm.raw); + expect(find.text('Raw patch'), findsNothing); + expect(tester.takeException(), isNull); + }); + + testWidgets('artifact details adapt to app width $width', (tester) async { + tester.view.physicalSize = Size(width, 900); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: ArtifactViewerInfoAction( + facts: Text('Recorded artifact facts'), + ), + ), + ), + ); + await tester.tap(find.byTooltip('Details')); + await tester.pumpAndSettle(); + expect(find.text('Recorded artifact facts'), findsOneWidget); + expect(find.byType(Dialog), width >= 600 ? findsOneWidget : findsNothing); + expect( + find.byType(BottomSheet), + width < 600 ? findsOneWidget : findsNothing, + ); + final context = tester.element(find.text('Recorded artifact facts')); + Navigator.of(context).pop(); + await tester.pumpAndSettle(); + expect(find.text('Recorded artifact facts'), findsNothing); + expect(tester.takeException(), isNull); + }); + } +}