import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:matrix/matrix.dart'; import 'package:fluffychat/config/setting_keys.dart'; import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/l10n/l10n.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; import '../../../config/app_config.dart'; class StateMessage extends StatelessWidget { final Event event; final void Function()? onExpand; final bool isCollapsed; // #Pangea final bool moreEventButtonExpands; // Pangea# const StateMessage( this.event, { this.onExpand, this.isCollapsed = false, // #Pangea this.moreEventButtonExpands = true, // Pangea# super.key, }); @override Widget build(BuildContext context) { final theme = Theme.of(context); return AnimatedSize( duration: FluffyThemes.animationDuration, curve: FluffyThemes.animationCurve, child: isCollapsed ? const SizedBox.shrink() : Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Center( child: Padding( padding: const EdgeInsets.all(4), child: Material( color: theme.colorScheme.surface.withAlpha(128), borderRadius: BorderRadius.circular( AppConfig.borderRadius / 3, ), child: Padding( padding: const EdgeInsets.symmetric( horizontal: 8.0, vertical: 4.0, ), child: Text.rich( TextSpan( children: [ TextSpan( // #Pangea // text: event.calcLocalizedBodyFallback( // MatrixLocals(L10n.of(context)), // ), text: (event.type == EventTypes.RoomMember) && (event.roomMemberChangeType == RoomMemberChangeType.leave) && (event.stateKey == event.room.client.userID) ? L10n.of(context).youLeftTheChat : event.calcLocalizedBodyFallback( MatrixLocals(L10n.of(context)), ), // Pangea# ), if (onExpand != null) ...[ const TextSpan(text: '\n'), TextSpan( style: TextStyle( color: theme.colorScheme.primary, decoration: TextDecoration.underline, ), recognizer: TapGestureRecognizer() ..onTap = onExpand, // #Pangea // text: L10n.of(context).moreEvents, text: moreEventButtonExpands ? L10n.of(context).moreEvents : L10n.of(context).hideEvents, // Pangea# ), ], ], ), textAlign: TextAlign.center, style: TextStyle( fontSize: 11 * AppSettings.fontSizeFactor.value, decoration: event.redacted ? TextDecoration.lineThrough : null, ), ), ), ), ), ), ), ); } }