Remove Cupertino chat session branches

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.
This commit is contained in:
2026-11-11 14:18:04 +00:00
parent 96de9f5bea
commit ae208699d8
37 changed files with 566 additions and 2121 deletions
@@ -1,8 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'chat_adaptive.dart';
/// The web's directory prompt, also the directory picker's label.
const String chatCreatePrompt = 'Where should this chat live?';
@@ -70,11 +67,9 @@ class ChatCatalogFields extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
if (loading) return const Text('Loading directories…');
if (error != null) {
return _message(cupertino, 'Unable to load chat options: $error');
return _message('Unable to load chat options: $error');
}
final choices = chatDirectoryChoices(directories);
String directoryLabel(String choice) =>
@@ -82,90 +77,50 @@ class ChatCatalogFields extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (cupertino)
CupertinoPickerField(
// Keyed by the value so a folder chosen in the picker replaces the
// dropdown's retained initial value.
KeyedSubtree(
key: ValueKey('chat-create-directory-$directory'),
child: MaterialPickerField(
fieldKey: const Key('chat-create-server-directory'),
label: chatCreatePrompt,
value: directory,
values: choices,
labelOf: directoryLabel,
onSelected: onDirectory,
)
else
// Keyed by the value so a folder chosen in the picker replaces the
// dropdown's retained initial value.
KeyedSubtree(
key: ValueKey('chat-create-directory-$directory'),
child: MaterialPickerField(
fieldKey: const Key('chat-create-server-directory'),
label: chatCreatePrompt,
value: directory,
values: choices,
labelOf: directoryLabel,
onSelected: onDirectory,
),
),
),
if (onBrowse != null)
Align(
alignment: AlignmentDirectional.centerStart,
child: cupertino
? CupertinoButton(
key: const Key('chat-create-choose-folder'),
padding: const EdgeInsets.symmetric(vertical: 4),
onPressed: onBrowse,
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(CupertinoIcons.folder),
SizedBox(width: 6),
Flexible(child: Text(chatChooseFolderLabel)),
],
),
)
: TextButton.icon(
key: const Key('chat-create-choose-folder'),
onPressed: onBrowse,
icon: const Icon(Icons.folder_open),
label: const Text(chatChooseFolderLabel),
),
child: TextButton.icon(
key: const Key('chat-create-choose-folder'),
onPressed: onBrowse,
icon: const Icon(Icons.folder_open),
label: const Text(chatChooseFolderLabel),
),
),
if (backends.length > 1)
if (cupertino)
CupertinoPickerField(
fieldKey: const Key('chat-create-backend'),
label: 'Chat harness',
value: backend,
values: backends,
labelOf: chatBackendLabel,
onSelected: onBackend,
)
else
MaterialPickerField(
fieldKey: const Key('chat-create-backend'),
label: 'Chat harness',
value: backend,
values: backends,
labelOf: chatBackendLabel,
onSelected: onBackend,
),
MaterialPickerField(
fieldKey: const Key('chat-create-backend'),
label: 'Chat harness',
value: backend,
values: backends,
labelOf: chatBackendLabel,
onSelected: onBackend,
),
],
);
}
Widget _message(bool cupertino, String text) {
Widget _message(String text) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(text),
Align(
alignment: AlignmentDirectional.centerStart,
child: cupertino
? CupertinoButton(
padding: EdgeInsets.zero,
onPressed: onRetry,
child: const Text('Retry'),
)
: TextButton(onPressed: onRetry, child: const Text('Retry')),
child: TextButton(onPressed: onRetry, child: const Text('Retry')),
),
],
);
@@ -221,68 +176,3 @@ class MaterialPickerField extends StatelessWidget {
return Text(_text(item), maxLines: 1, overflow: TextOverflow.ellipsis);
}
}
class CupertinoPickerField extends StatelessWidget {
const CupertinoPickerField({
super.key,
required this.fieldKey,
required this.label,
required this.value,
required this.values,
required this.onSelected,
this.labelOf,
});
final String label;
final String? value;
final List<String> values;
final ValueChanged<String> onSelected;
final Key fieldKey;
/// The visible text of a value; the value itself is what is sent.
final String Function(String value)? labelOf;
String _text(String value) => labelOf?.call(value) ?? value;
Future<void> _choose(BuildContext context) async {
final choice = await showCupertinoModalPopup<String>(
context: context,
builder: (sheetContext) => CupertinoActionSheet(
title: Text(label),
actions: [
for (final item in values)
CupertinoActionSheetAction(
onPressed: () => Navigator.pop(sheetContext, item),
child: Text(_text(item)),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(sheetContext),
child: const Text('Cancel'),
),
),
);
if (choice != null) onSelected(choice);
}
@override
Widget build(BuildContext context) {
return Semantics(
label: '$label: ${value == null ? '' : _text(value!)}',
button: true,
child: CupertinoButton(
key: fieldKey,
padding: const EdgeInsets.symmetric(vertical: 4),
onPressed: () => _choose(context),
child: Row(
children: [
Expanded(
child: Text('$label: ${value == null ? '' : _text(value!)}'),
),
const Icon(CupertinoIcons.chevron_down),
],
),
),
);
}
}