ae208699d8
Keep the Material-only session UI and narrow its tests to the supported host. Preserve public Cupertino parameters for callers while removing unreachable Cupertino widgets and variants.
65 lines
1.7 KiB
Dart
65 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'chat_create_fields.dart';
|
|
|
|
/// Native platform controls for choosing what editable prompt to start with.
|
|
class ChatPromptChooser extends StatelessWidget {
|
|
const ChatPromptChooser({
|
|
super.key,
|
|
required this.cupertino,
|
|
required this.enabled,
|
|
required this.choice,
|
|
required this.hasLastUsed,
|
|
required this.onEnabled,
|
|
required this.onChoice,
|
|
});
|
|
|
|
static const custom = 'custom';
|
|
static const careful = 'careful';
|
|
static const lastUsed = 'last-used';
|
|
|
|
/// Kept for callers; the Material switch and picker are always drawn.
|
|
final bool cupertino;
|
|
final bool enabled;
|
|
final String choice;
|
|
final bool hasLastUsed;
|
|
final ValueChanged<bool> onEnabled;
|
|
final ValueChanged<String> onChoice;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final choices = <String>[custom, careful, if (hasLastUsed) lastUsed];
|
|
String label(String value) => switch (value) {
|
|
custom => 'Custom',
|
|
careful => 'Careful coding',
|
|
lastUsed => 'Last used prompt',
|
|
_ => value,
|
|
};
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
const Expanded(child: Text('Start with a prompt')),
|
|
Switch(
|
|
key: const Key('chat-create-send-prompt'),
|
|
value: enabled,
|
|
onChanged: onEnabled,
|
|
),
|
|
],
|
|
),
|
|
if (enabled)
|
|
MaterialPickerField(
|
|
fieldKey: const Key('chat-create-prompt-choice'),
|
|
label: 'Prompt',
|
|
value: choices.contains(choice) ? choice : custom,
|
|
values: choices,
|
|
labelOf: label,
|
|
onSelected: onChoice,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|