8e98651db6
Keep the Material-only chat shell path while preserving public Cupertino parameters for callers. Narrow matching tests to the supported Material host.
76 lines
2.1 KiB
Dart
76 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../ui/text/monospace.dart';
|
|
import 'chat_shell_command.dart';
|
|
|
|
/// The chat actions menu's "Run command…": a small host dialog with one
|
|
/// command field. Returns the trimmed command, or null when cancelled.
|
|
Future<String?> showChatShellRunDialog(
|
|
BuildContext context, {
|
|
required bool cupertino,
|
|
}) => showDialog<String>(
|
|
context: context,
|
|
builder: (_) => const ChatShellRunDialog(cupertino: false),
|
|
);
|
|
|
|
class ChatShellRunDialog extends StatefulWidget {
|
|
const ChatShellRunDialog({super.key, required this.cupertino});
|
|
|
|
final bool cupertino;
|
|
|
|
@override
|
|
State<ChatShellRunDialog> createState() => _ChatShellRunDialogState();
|
|
}
|
|
|
|
class _ChatShellRunDialogState extends State<ChatShellRunDialog> {
|
|
final TextEditingController _text = TextEditingController();
|
|
|
|
@override
|
|
void dispose() {
|
|
_text.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _submit() {
|
|
final command = _text.text.trim();
|
|
Navigator.pop(context, command.isEmpty ? null : command);
|
|
}
|
|
|
|
void _cancel() => Navigator.pop(context);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
const mono = TextStyle(fontFamily: appMonospaceFamily);
|
|
return AlertDialog(
|
|
title: const Text(chatShellRunDialogTitle),
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Text(chatShellModeHint),
|
|
const SizedBox(height: 12),
|
|
TextField(
|
|
key: const Key('chat-shell-run-field'),
|
|
controller: _text,
|
|
autofocus: true,
|
|
style: mono,
|
|
decoration: const InputDecoration(
|
|
labelText: 'Command',
|
|
prefixText: '\$ ',
|
|
),
|
|
onSubmitted: (_) => _submit(),
|
|
),
|
|
],
|
|
),
|
|
actions: [
|
|
TextButton(onPressed: _cancel, child: const Text('Cancel')),
|
|
FilledButton(
|
|
key: const Key('chat-shell-run-confirm'),
|
|
onPressed: _submit,
|
|
child: const Text(chatShellRunDialogConfirm),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|