Use adaptive popups for chat details
Present chat turn and shell-history detail surfaces through the shared adaptive popup helpers so desktop uses dialogs while phone layouts retain bottom sheets. Update focused tests and document the verified behavior.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/app_popups.dart';
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
|
||||
/// The quiet chip under an agent turn (its tools, its permissions) and the
|
||||
@@ -25,7 +26,7 @@ class ChatTurnChip extends StatelessWidget {
|
||||
final Color color;
|
||||
final String semanticsLabel;
|
||||
|
||||
/// The native sheet the chip opens, unless [open] presents it instead.
|
||||
/// The detail content the chip opens, unless [open] presents it instead.
|
||||
final Widget? sheet;
|
||||
|
||||
/// A custom presentation (a full-screen route on a narrow window).
|
||||
@@ -110,28 +111,12 @@ class ChatTurnChip extends StatelessWidget {
|
||||
|
||||
Future<void> _open(BuildContext context, bool cupertino) {
|
||||
if (open case final open?) return open(context, cupertino);
|
||||
return showChatTurnSheet(context, cupertino, sheet!);
|
||||
return showChatTurnSheet(context, sheet!);
|
||||
}
|
||||
}
|
||||
|
||||
/// The native sheet a turn chip opens: a Cupertino popup surface or a
|
||||
/// Material modal bottom sheet.
|
||||
Future<void> showChatTurnSheet(
|
||||
BuildContext context,
|
||||
bool cupertino,
|
||||
Widget sheet,
|
||||
) {
|
||||
if (cupertino) {
|
||||
return showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
|
||||
);
|
||||
}
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
useSafeArea: true,
|
||||
builder: (_) => sheet,
|
||||
);
|
||||
/// The detail surface a turn chip opens: a dialog on desktop and a bottom
|
||||
/// sheet on a phone.
|
||||
Future<void> showChatTurnSheet(BuildContext context, Widget sheet) {
|
||||
return showAppDetails<void>(context, builder: (_) => sheet);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../shell/list_detail_policy.dart';
|
||||
import '../../../../ui/adaptive/app_popups.dart';
|
||||
import '../../../changes/widgets/change_style.dart'
|
||||
show addedColor, removedColor;
|
||||
import '../../domain/chat_turn_diffs.dart';
|
||||
@@ -65,31 +65,9 @@ class ChatTurnDiffChip extends StatelessWidget {
|
||||
}
|
||||
|
||||
Future<void> _open(BuildContext context, bool cupertino) {
|
||||
if (MediaQuery.sizeOf(context).width >= kListDetailMinWidth) {
|
||||
return showChatTurnSheet(
|
||||
context,
|
||||
cupertino,
|
||||
ChatTurnDiffView(summary: summary, load: load),
|
||||
);
|
||||
}
|
||||
final view = ChatTurnDiffView(summary: summary, load: load, inSheet: false);
|
||||
const title = Text('Turn changes');
|
||||
return Navigator.of(context).push<void>(
|
||||
cupertino
|
||||
? CupertinoPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(middle: title),
|
||||
child: SafeArea(child: view),
|
||||
),
|
||||
)
|
||||
: MaterialPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => Scaffold(
|
||||
appBar: AppBar(title: title),
|
||||
body: SafeArea(child: view),
|
||||
),
|
||||
),
|
||||
return showAppDetails<void>(
|
||||
context,
|
||||
builder: (_) => ChatTurnDiffView(summary: summary, load: load),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user