8e98651db6
Keep the Material-only chat shell path while preserving public Cupertino parameters for callers. Narrow matching tests to the supported Material host.
58 lines
1.7 KiB
Dart
58 lines
1.7 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/adaptive/segmented_bar_overflow.dart';
|
|
import 'chat_shell_runs_controller.dart';
|
|
|
|
const String chatShellDismissLabel = 'Dismiss';
|
|
const String chatShellDismissAllLabel = 'Dismiss all finished commands';
|
|
|
|
/// The card's Dismiss button, offered once the command has finished.
|
|
class ChatShellDismissButton extends StatelessWidget {
|
|
const ChatShellDismissButton({
|
|
super.key,
|
|
required this.cupertino,
|
|
required this.onPressed,
|
|
});
|
|
|
|
final bool cupertino;
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return IconButton(
|
|
key: const Key('chat-shell-run-dismiss'),
|
|
tooltip: chatShellDismissLabel,
|
|
icon: const Icon(Icons.close),
|
|
onPressed: onPressed,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The conversation's "Dismiss all finished commands" More menu entry.
|
|
Widget chatShellDismissAllMenuAction({required VoidCallback onPressed}) =>
|
|
SegmentedOverflowAction(
|
|
key: const ValueKey<String>('chat-shell-dismiss-all-action'),
|
|
overflowEntry: SegmentedOverflowEntry(
|
|
label: chatShellDismissAllLabel,
|
|
icon: Icons.clear_all,
|
|
onPressed: onPressed,
|
|
),
|
|
child: const SizedBox.shrink(),
|
|
);
|
|
|
|
/// Dismisses [ids] for every client of the chat. The card simply goes away;
|
|
/// no notice is shown. A refusal goes to [onRefused].
|
|
Future<void> dismissChatShellRuns(
|
|
BuildContext context,
|
|
ChatShellRunsController controller,
|
|
List<String> ids, {
|
|
required bool cupertino,
|
|
void Function(String refusal)? onRefused,
|
|
}) async {
|
|
if (ids.isEmpty) return;
|
|
final refusal = await controller.dismiss(ids);
|
|
if (refusal != null) onRefused?.call(refusal);
|
|
}
|