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.
96 lines
3.0 KiB
Dart
96 lines
3.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'chat_deliveries.dart';
|
|
|
|
/// The words each delivery state reads as, beside its icon.
|
|
String chatDeliveryLabel(ChatDelivery state) => switch (state) {
|
|
ChatDelivery.sending => 'Sending…',
|
|
ChatDelivery.sent => 'Sent',
|
|
ChatDelivery.queued => 'Queued',
|
|
ChatDelivery.steered => 'Delivered to the running reply',
|
|
ChatDelivery.failed => 'Not sent',
|
|
};
|
|
|
|
/// A small muted line under the operator's own bubble saying whether the
|
|
/// server has the message. "Not sent" takes the error colour and offers the
|
|
/// native Retry (same operation id) and Edit (back into the composer) — or
|
|
/// Discard when the stored intent can no longer be sent as it was. "Queued"
|
|
/// offers Remove, which takes the message off the server's queue.
|
|
class ChatDeliveryIndicator extends StatelessWidget {
|
|
const ChatDeliveryIndicator({
|
|
super.key,
|
|
required this.state,
|
|
this.onRetry,
|
|
this.onEdit,
|
|
this.editLabel = 'Edit',
|
|
this.onRemove,
|
|
});
|
|
|
|
final ChatDelivery state;
|
|
final VoidCallback? onRetry;
|
|
final VoidCallback? onEdit;
|
|
final String editLabel;
|
|
|
|
/// Takes a "Queued" message back off the server's queue before it is sent.
|
|
final VoidCallback? onRemove;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final failed = state == ChatDelivery.failed;
|
|
final color = failed
|
|
? Theme.of(context).colorScheme.error
|
|
: Theme.of(context).colorScheme.onSurfaceVariant;
|
|
final style = DefaultTextStyle.of(
|
|
context,
|
|
).style.merge(TextStyle(fontSize: 12, color: color));
|
|
final label = chatDeliveryLabel(state);
|
|
return Semantics(
|
|
container: true,
|
|
label: 'Delivery: $label',
|
|
child: Wrap(
|
|
key: Key('chat-delivery-${state.name}'),
|
|
spacing: 4,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
children: [
|
|
ExcludeSemantics(
|
|
child: Icon(_icon, size: style.fontSize! + 2, color: color),
|
|
),
|
|
ExcludeSemantics(child: Text(label, style: style)),
|
|
if (failed && onRetry != null)
|
|
_action('chat-delivery-retry', 'Retry', onRetry!, style),
|
|
if (failed && onEdit != null)
|
|
_action('chat-delivery-edit', editLabel, onEdit!, style),
|
|
if (state == ChatDelivery.queued && onRemove != null)
|
|
_action('chat-delivery-remove', 'Remove', onRemove!, style),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
IconData get _icon => switch (state) {
|
|
ChatDelivery.sending => Icons.schedule,
|
|
ChatDelivery.sent => Icons.done,
|
|
ChatDelivery.queued => Icons.hourglass_empty,
|
|
ChatDelivery.steered => Icons.done,
|
|
ChatDelivery.failed => Icons.error_outline,
|
|
};
|
|
|
|
Widget _action(
|
|
String key,
|
|
String text,
|
|
VoidCallback onPressed,
|
|
TextStyle style,
|
|
) {
|
|
return TextButton(
|
|
key: Key(key),
|
|
style: TextButton.styleFrom(
|
|
foregroundColor: style.color,
|
|
visualDensity: VisualDensity.compact,
|
|
textStyle: style.copyWith(fontWeight: FontWeight.w600),
|
|
),
|
|
onPressed: onPressed,
|
|
child: Text(text),
|
|
);
|
|
}
|
|
}
|