diff --git a/lib/pangea/common/widgets/error_indicator.dart b/lib/pangea/common/widgets/error_indicator.dart index fa74eb2c5..d5317120c 100644 --- a/lib/pangea/common/widgets/error_indicator.dart +++ b/lib/pangea/common/widgets/error_indicator.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:fluffychat/config/app_config.dart'; + class ErrorIndicator extends StatelessWidget { final String message; final double? iconSize; + final Color? iconColor; final TextStyle? style; final VoidCallback? onTap; @@ -10,25 +13,28 @@ class ErrorIndicator extends StatelessWidget { super.key, required this.message, this.iconSize, + this.iconColor, this.style, this.onTap, }); @override Widget build(BuildContext context) { - final content = Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.error, - color: Theme.of(context).colorScheme.error, - size: iconSize ?? 24.0, - ), - const SizedBox(width: 8), - Flexible( - child: Text(message, style: style, textAlign: TextAlign.center), - ), - ], + final content = RichText( + text: TextSpan( + children: [ + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: Icon( + Icons.error, + color: iconColor ?? AppConfig.error, + size: iconSize ?? 24.0, + ), + ), + TextSpan(text: ' '), + TextSpan(text: message, style: style), + ], + ), ); if (onTap != null) { diff --git a/lib/pangea/toolbar/layout/overlay_message.dart b/lib/pangea/toolbar/layout/overlay_message.dart index ec9018ace..f50a096ee 100644 --- a/lib/pangea/toolbar/layout/overlay_message.dart +++ b/lib/pangea/toolbar/layout/overlay_message.dart @@ -367,20 +367,9 @@ class _MessageSelectModeContent extends StatelessWidget { ), ], ), - AsyncError(error: final _) => Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.error_outline, - color: Theme.of(context).colorScheme.error, - ), - const SizedBox(width: 8), - Text( - L10n.of(context).translationError, - textScaler: TextScaler.noScaling, - style: style.copyWith(fontStyle: FontStyle.italic), - ), - ], + AsyncError(error: final _) => ErrorIndicator( + message: L10n.of(context).translationError, + style: style.copyWith(fontStyle: FontStyle.italic), ), AsyncLoaded(value: final value) => Container( constraints: BoxConstraints(maxWidth: maxWidth),