build method

  1. @override
dynamic build(
  1. dynamic context,
  2. dynamic ref
)

Implementation

@override
Widget build(BuildContext context, WidgetRef ref) {
  Map<String, int>? receipts = message.metadata?['receipts'];
  if (receipts != null && receipts.isNotEmpty) {
    return _UserReceiptsWidget(
      roomId: roomId,
      seenList: receipts.keys.toList(),
    );
  }
  EventSendState? sendState = message.metadata?['eventState'];
  final result = switch (sendState?.state()) {
    'NotSentYet' => const SizedBox(
      height: 8,
      width: 8,
      child: CircularProgressIndicator(),
    ),
    'SendingFailed' => Row(
      children: <Widget>[
        Icon(
          Atlas.warning_thin,
          color: Theme.of(context).colorScheme.error,
          size: 8,
        ),
        const SizedBox(width: 5),
        Text(L10n.of(context).chatSendingFailed),
        const SizedBox(width: 5),
        ActerInlineTextButton.icon(
          onPressed: () async {
            try {
              sendState?.abort();
            } catch (e) {
              EasyLoading.showError(L10n.of(context).error(e));
            }
          },
          icon: Icon(PhosphorIconsRegular.trash, size: 8),
          label: Text(L10n.of(context).cancel),
        ),
      ],
    ),
    'Sent' => const Icon(Atlas.check_circle_thin, size: 8),
    _ => null,
  };
  return result ?? const SizedBox.shrink();
}