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.
This commit is contained in:
@@ -2,6 +2,8 @@ import 'dart:typed_data';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/app_popups.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
import '../actions/artifact_file_actions.dart';
|
import '../actions/artifact_file_actions.dart';
|
||||||
import '../actions/artifact_file_bridge.dart';
|
import '../actions/artifact_file_bridge.dart';
|
||||||
@@ -168,9 +170,8 @@ class ArtifactViewerInfoAction extends StatelessWidget {
|
|||||||
final Widget facts;
|
final Widget facts;
|
||||||
|
|
||||||
void _show(BuildContext context) {
|
void _show(BuildContext context) {
|
||||||
showModalBottomSheet<void>(
|
showAppDetails<void>(
|
||||||
context: context,
|
context,
|
||||||
showDragHandle: true,
|
|
||||||
builder: (context) => SafeArea(
|
builder: (context) => SafeArea(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import 'dart:math' as math;
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/app_popups.dart';
|
||||||
|
|
||||||
enum DiffForm { rendered, raw }
|
enum DiffForm { rendered, raw }
|
||||||
|
|
||||||
const diffFormLabels = <DiffForm, String>{
|
const diffFormLabels = <DiffForm, String>{
|
||||||
@@ -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(
|
Widget diffFormMenu(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required DiffForm form,
|
required DiffForm form,
|
||||||
@@ -59,9 +61,8 @@ Widget diffFormMenu(
|
|||||||
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
icon: const Icon(Icons.more_vert, size: 28),
|
icon: const Icon(Icons.more_vert, size: 28),
|
||||||
onPressed: () => showModalBottomSheet<void>(
|
onPressed: () => showAppChoiceMenu<void>(
|
||||||
context: context,
|
context,
|
||||||
showDragHandle: true,
|
|
||||||
builder: (sheetContext) => SafeArea(
|
builder: (sheetContext) => SafeArea(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -77,13 +78,13 @@ Widget diffFormMenu(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
for (final entry in diffFormLabels.entries)
|
for (final entry in diffFormLabels.entries)
|
||||||
ListTile(
|
AppChoiceMenuItem(
|
||||||
title: Text(entry.value),
|
|
||||||
selected: entry.key == form,
|
selected: entry.key == form,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(sheetContext).pop();
|
Navigator.of(sheetContext).pop();
|
||||||
onChanged(entry.key);
|
onChanged(entry.key);
|
||||||
},
|
},
|
||||||
|
child: Text(entry.value),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,3 +14,11 @@
|
|||||||
Material widgets and layouts.
|
Material widgets and layouts.
|
||||||
- Remaining shared compatibility metadata/flags are outside this focused edit
|
- Remaining shared compatibility metadata/flags are outside this focused edit
|
||||||
and should be removed only after all callers migrate during final integration.
|
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.
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user