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.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'; final bool enabled; final String choice; final bool hasLastUsed; final ValueChanged onEnabled; final ValueChanged onChoice; @override Widget build(BuildContext context) { final choices = [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, ), ], ); } }