feat(learn): the assistant's conversation a dialog on the desktop and in expanded windows (Todo's ADR 0033, D11)

- halkyon_ui's sheetShowsAsDialog says whether showAdaptiveSheet shows
  a dialog here, for a sheet of its own that can't go through it.
- Learn's conversation, a half-height sheet dragged up, asks it: where
  sheets are dialogs it is a dialog up to 720 wide and as tall as the
  window, with no handle to drag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-11-01 18:20:58 +01:00
commit 4898d0a04a
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 145 additions and 23 deletions

View file

@ -28,7 +28,7 @@ Future<T?> showAdaptiveSheet<T>(
required WidgetBuilder builder,
bool swipeable = true,
}) {
if (!context.windowSize.isAtLeastExpanded && !_onDesktop) {
if (!sheetShowsAsDialog(context)) {
return showModalBottomSheet<T>(
context: context,
useRootNavigator: true,
@ -63,6 +63,13 @@ Future<T?> showAdaptiveSheet<T>(
);
}
/// Whether [showAdaptiveSheet] shows a sheet as a dialog here: from
/// expanded windows on, and on the desktop at every width. For a sheet of
/// its own that can't go through it (one dragged to its height, as Learn's
/// conversation), so that it follows the same rule.
bool sheetShowsAsDialog(BuildContext context) =>
context.windowSize.isAtLeastExpanded || _onDesktop;
/// Whether the app runs on the desktop, where sheets are dialogs at every
/// width.
bool get _onDesktop => switch (defaultTargetPlatform) {

View file

@ -63,6 +63,36 @@ void main() {
expect(find.byType(BottomSheet), findsNothing);
});
testWidgets('sheetShowsAsDialog says which a sheet of its own will be: '
'a dialog from expanded windows on, and on the desktop at every width', (
tester,
) async {
Future<bool> at(double width) async {
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
late bool shows;
await tester.pumpWidget(
MaterialApp(
home: Builder(
builder: (context) {
shows = sheetShowsAsDialog(context);
return const SizedBox();
},
),
),
);
return shows;
}
addTearDown(tester.view.reset);
expect(await at(400), isFalse);
expect(await at(840), isTrue);
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
addTearDown(() => debugDefaultTargetPlatformOverride = null);
expect(await at(400), isTrue);
debugDefaultTargetPlatformOverride = null;
});
for (final platform in [
TargetPlatform.linux,
TargetPlatform.macOS,