9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
214 lines
5.6 KiB
Dart
214 lines
5.6 KiB
Dart
import '../../../../ui/adaptive/segmented_bar_overflow.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class ChatBarAction extends StatelessWidget implements SegmentedOverflowable {
|
|
const ChatBarAction({
|
|
super.key,
|
|
required this.label,
|
|
required this.onPressed,
|
|
required this.materialIcon,
|
|
this.identifier,
|
|
});
|
|
|
|
final String label;
|
|
final VoidCallback onPressed;
|
|
final IconData materialIcon;
|
|
|
|
final String? identifier;
|
|
|
|
/// A narrow bar moves it into its More menu, under the bar's host's icon.
|
|
@override
|
|
SegmentedOverflowEntry get overflowEntry => SegmentedOverflowEntry(
|
|
label: label,
|
|
icon: materialIcon,
|
|
onPressed: onPressed,
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Semantics(
|
|
identifier: identifier,
|
|
child: IconButton(
|
|
tooltip: label,
|
|
onPressed: onPressed,
|
|
icon: Icon(materialIcon),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The chat toolbar's one primary create action, labelled as on the web
|
|
/// (`+ New chat`), not an unlabelled glyph.
|
|
class ChatNewChatButton extends StatelessWidget {
|
|
const ChatNewChatButton({super.key, required this.onPressed});
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FilledButton.icon(
|
|
onPressed: onPressed,
|
|
icon: const Icon(Icons.add),
|
|
label: const Text('New chat'),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ChatSearchField extends StatelessWidget {
|
|
const ChatSearchField({
|
|
super.key,
|
|
required this.controller,
|
|
required this.onChanged,
|
|
this.trailing = const [],
|
|
this.autofocus = false,
|
|
});
|
|
|
|
final TextEditingController controller;
|
|
final ValueChanged<String> onChanged;
|
|
final bool autofocus;
|
|
|
|
/// Actions on the search row's trailing edge, as the web's chat toolbar
|
|
/// keeps New chat beside its search input.
|
|
final List<Widget> trailing;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final field = TextField(
|
|
controller: controller,
|
|
onChanged: onChanged,
|
|
autofocus: autofocus,
|
|
decoration: const InputDecoration(
|
|
prefixIcon: Icon(Icons.search),
|
|
labelText: 'Search chats',
|
|
),
|
|
);
|
|
return Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: trailing.isEmpty
|
|
? field
|
|
: Row(
|
|
children: [
|
|
Expanded(child: field),
|
|
for (final action in trailing) ...[
|
|
const SizedBox(width: 8),
|
|
action,
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// A row action's refusal, shown at full width beneath its tile.
|
|
///
|
|
/// It must not sit in a list tile's subtitle slot: that slot forces every
|
|
/// paragraph to one ellipsised line, which cut the server's reason down to its
|
|
/// first few words. Full width also stops a long refusal from turning a single
|
|
/// Material row into a column taller than the viewport.
|
|
class ChatRowError extends StatelessWidget {
|
|
const ChatRowError({
|
|
super.key,
|
|
required this.message,
|
|
this.messageKey,
|
|
this.onDismiss,
|
|
});
|
|
|
|
final String message;
|
|
|
|
/// Clears this refusal; its control reads the web report's `OK`.
|
|
final VoidCallback? onDismiss;
|
|
|
|
/// Key placed on the message paragraph itself, so a test can assert that the
|
|
/// rendered text did not exceed its line limit.
|
|
final Key? messageKey;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final style = TextStyle(color: Theme.of(context).colorScheme.error);
|
|
return Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 12),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: DefaultTextStyle.merge(
|
|
style: style,
|
|
child: Text(message, key: messageKey),
|
|
),
|
|
),
|
|
if (onDismiss != null)
|
|
Semantics(
|
|
button: true,
|
|
label: 'Dismiss refusal',
|
|
excludeSemantics: true,
|
|
child: TextButton(onPressed: onDismiss, child: const Text('OK')),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ChatErrorNotice extends StatelessWidget {
|
|
const ChatErrorNotice({
|
|
super.key,
|
|
required this.message,
|
|
required this.onRetry,
|
|
});
|
|
|
|
final String message;
|
|
final VoidCallback onRetry;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialBanner(
|
|
content: Text(message),
|
|
actions: [TextButton(onPressed: onRetry, child: const Text('Retry'))],
|
|
);
|
|
}
|
|
}
|
|
|
|
class ChatLoadingIndicator extends StatelessWidget {
|
|
const ChatLoadingIndicator({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
}
|
|
|
|
/// One-row report after hiding a session on this device, with its Undo.
|
|
///
|
|
/// The screen floats this over the list like the web's fixed report, so a long
|
|
/// message can never push the list out of the body's column.
|
|
class ChatUndoBar extends StatelessWidget {
|
|
const ChatUndoBar({super.key, required this.message, required this.onUndo});
|
|
|
|
final String message;
|
|
final VoidCallback onUndo;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final content = Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: DefaultTextStyle.merge(
|
|
style: DefaultTextStyle.of(context).style,
|
|
child: Text(message),
|
|
),
|
|
),
|
|
TextButton(onPressed: onUndo, child: const Text('Undo')),
|
|
],
|
|
),
|
|
);
|
|
return Material(
|
|
elevation: 3,
|
|
borderRadius: BorderRadius.circular(8),
|
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
|
child: content,
|
|
);
|
|
}
|
|
}
|