From c4b35f67c76204c215467ac6c400502c9cd256ea Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:12:11 -0500 Subject: [PATCH] fix: fix message overflow for activity messages on mobile (#1573) --- .../activity_plan_message.dart | 190 +++++++++--------- .../widgets/message_selection_positioner.dart | 7 +- 2 files changed, 96 insertions(+), 101 deletions(-) diff --git a/lib/pangea/activity_planner/activity_plan_message.dart b/lib/pangea/activity_planner/activity_plan_message.dart index 4c9697750..f44b8a9ee 100644 --- a/lib/pangea/activity_planner/activity_plan_message.dart +++ b/lib/pangea/activity_planner/activity_plan_message.dart @@ -65,112 +65,104 @@ class ActivityPlanMessage extends StatelessWidget { ? const SizedBox(height: 0, width: double.infinity) : Container( alignment: Alignment.center, - child: Row( - mainAxisSize: MainAxisSize.min, + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - AnimatedOpacity( - opacity: animateIn - ? 0 - : event.messageType == - MessageTypes.BadEncrypted || - event.status.isSending - ? 0.5 - : 1, - duration: FluffyThemes.animationDuration, - curve: FluffyThemes.animationCurve, + AnimatedOpacity( + opacity: animateIn + ? 0 + : event.messageType == MessageTypes.BadEncrypted || + event.status.isSending + ? 0.5 + : 1, + duration: FluffyThemes.animationDuration, + curve: FluffyThemes.animationCurve, + child: Container( + decoration: BoxDecoration( + color: color, + borderRadius: borderRadius, + ), + clipBehavior: Clip.antiAlias, + child: CompositedTransformTarget( + link: MatrixState.pAnyState + .layerLinkAndKey( + event.eventId, + ) + .link, child: Container( + key: MatrixState.pAnyState + .layerLinkAndKey( + event.eventId, + ) + .key, decoration: BoxDecoration( - color: color, - borderRadius: borderRadius, - ), - clipBehavior: Clip.antiAlias, - child: CompositedTransformTarget( - link: MatrixState.pAnyState - .layerLinkAndKey( - event.eventId, - ) - .link, - child: Container( - key: MatrixState.pAnyState - .layerLinkAndKey( - event.eventId, - ) - .key, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular( - AppConfig.borderRadius, - ), - ), - padding: const EdgeInsets.symmetric( - horizontal: 16, - vertical: 8, - ), - constraints: const BoxConstraints( - maxWidth: FluffyThemes.columnWidth * 1.5, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - MessageContent( - displayEvent, - textColor: textColor, - borderRadius: borderRadius, - controller: controller, - immersionMode: false, - ), - if (event.hasAggregatedEvents( - timeline, - RelationshipTypes.edit, - )) - Padding( - padding: const EdgeInsets.only( - top: 4.0, - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - if (event.hasAggregatedEvents( - timeline, - RelationshipTypes.edit, - )) ...[ - Icon( - Icons.edit_outlined, - color: - textColor.withAlpha(164), - size: 14, - ), - Text( - ' - ${displayEvent.originServerTs.localizedTimeShort(context)}', - style: TextStyle( - color: textColor.withAlpha( - 164, - ), - fontSize: 12, - ), - ), - ], - ], - ), - ), - ], - ), + borderRadius: BorderRadius.circular( + AppConfig.borderRadius, ), ), + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + constraints: const BoxConstraints( + maxWidth: FluffyThemes.columnWidth * 1.5, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MessageContent( + displayEvent, + textColor: textColor, + borderRadius: borderRadius, + controller: controller, + immersionMode: false, + ), + if (event.hasAggregatedEvents( + timeline, + RelationshipTypes.edit, + )) + Padding( + padding: const EdgeInsets.only( + top: 4.0, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (event.hasAggregatedEvents( + timeline, + RelationshipTypes.edit, + )) ...[ + Icon( + Icons.edit_outlined, + color: textColor.withAlpha(164), + size: 14, + ), + Text( + ' - ${displayEvent.originServerTs.localizedTimeShort(context)}', + style: TextStyle( + color: textColor.withAlpha( + 164, + ), + fontSize: 12, + ), + ), + ], + ], + ), + ), + ], + ), ), ), - Padding( - padding: const EdgeInsets.only( - top: 4.0, - right: 4.0, - ), - child: MessageReactions(event, timeline), - ), - ], + ), + ), + Padding( + padding: const EdgeInsets.only( + top: 4.0, + right: 4.0, + ), + child: MessageReactions(event, timeline), ), ], ), diff --git a/lib/pangea/toolbar/widgets/message_selection_positioner.dart b/lib/pangea/toolbar/widgets/message_selection_positioner.dart index 492ca5224..80336cbe2 100644 --- a/lib/pangea/toolbar/widgets/message_selection_positioner.dart +++ b/lib/pangea/toolbar/widgets/message_selection_positioner.dart @@ -11,6 +11,7 @@ import 'package:fluffychat/pages/chat/chat.dart'; import 'package:fluffychat/pages/chat/events/message_reactions.dart'; import 'package:fluffychat/pangea/common/utils/error_handler.dart'; import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart'; +import 'package:fluffychat/pangea/events/extensions/pangea_event_extension.dart'; import 'package:fluffychat/pangea/events/models/pangea_token_model.dart'; import 'package:fluffychat/pangea/toolbar/widgets/message_selection_overlay.dart'; import 'package:fluffychat/pangea/toolbar/widgets/message_toolbar.dart'; @@ -152,8 +153,10 @@ class MessageSelectionPositionerState extends State _adjustedMessageHeight ?? _messageSize?.height ?? 0; double get _messageMaxWidth { - const double messageMargin = Avatar.defaultSize + 16 + 8; - const totalMaxWidth = (FluffyThemes.columnWidth * 2.5) - messageMargin; + final double messageMargin = + widget.event.isActivityMessage ? 0 : Avatar.defaultSize + 16 + 8; + final double totalMaxWidth = + (FluffyThemes.columnWidth * 2.5) - messageMargin; double? maxWidth; if (_mediaQuery != null) {