Add adaptive popup helpers: anchored choice menus and details dialogs
Phase 2b.1 of docs/plans/floating-windows.md. showAppChoiceMenu is a menu panel anchored to its button on a wide app and a bottom sheet on a phone; showAppDetails is a dialog or a bottom sheet. Both are on the root navigator, and the app's width decides, so content in a narrow floating window still gets desktop popups. The probe window exercises both.
This commit is contained in:
@@ -79,6 +79,29 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('app choice menu and details dialog', (tester) async {
|
||||
await open(tester, destination);
|
||||
final button = tester.getRect(find.byKey(const ValueKey('a-choice')));
|
||||
await tester.tap(find.byKey(const ValueKey('a-choice')));
|
||||
await tester.pumpAndSettle();
|
||||
// A menu at its button, not a sheet, though the window is narrow.
|
||||
expect(find.byType(BottomSheet), findsNothing);
|
||||
expect(find.text('Choice two').hitTestable(), findsOneWidget);
|
||||
final menu = tester.getRect(
|
||||
find.byKey(const ValueKey('app-choice-menu')),
|
||||
);
|
||||
expect((menu.top - button.bottom).abs(), lessThan(40));
|
||||
expect(menu.left, button.left);
|
||||
await tester.tap(find.text('Choice two'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(picked(tester, 'a'), 'Choice two');
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('a-details')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(Dialog), findsOneWidget);
|
||||
expect(find.text('Details body').hitTestable(), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('MenuAnchor', (tester) async {
|
||||
await open(tester, destination);
|
||||
await tester.tap(find.byKey(const ValueKey('a-anchor')));
|
||||
|
||||
Reference in New Issue
Block a user