Skip to content

Commit

Permalink
fix: make overlay accurate for message with edits and replies (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggurdin authored Dec 31, 2024
1 parent 6f06cfd commit dd2cccc
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/pages/chat/events/message_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class MessageContent extends StatelessWidget {
}

controller.showToolbar(
event,
pangeaMessageEvent!.event,
pangeaMessageEvent: pangeaMessageEvent,
selectedToken: token,
);
Expand Down
108 changes: 96 additions & 12 deletions lib/pangea/widgets/chat/overlay_message.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/pages/chat/events/message_content.dart';
import 'package:fluffychat/pages/chat/events/reply_content.dart';
import 'package:fluffychat/pangea/matrix_event_wrappers/pangea_message_event.dart';
import 'package:fluffychat/pangea/widgets/chat/message_selection_overlay.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
Expand Down Expand Up @@ -93,6 +94,9 @@ class OverlayMessage extends StatelessWidget {
MessageTypes.Audio,
}.contains(event.messageType);

final textColor =
ownMessage ? theme.colorScheme.onPrimary : theme.colorScheme.onSurface;

return Material(
color: color,
clipBehavior: Clip.antiAlias,
Expand All @@ -113,18 +117,98 @@ class OverlayMessage extends StatelessWidget {
vertical: 8,
),
width: messageWidth,
child: MessageContent(
event,
textColor: ownMessage
? theme.colorScheme.onPrimary
: theme.colorScheme.onSurface,
pangeaMessageEvent: pangeaMessageEvent,
immersionMode: immersionMode,
overlayController: overlayController,
controller: controller,
nextEvent: nextEvent,
prevEvent: prevEvent,
borderRadius: borderRadius,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (event.relationshipType == RelationshipTypes.reply)
FutureBuilder<Event?>(
future: event.getReplyEvent(
timeline,
),
builder: (
BuildContext context,
snapshot,
) {
final replyEvent = snapshot.hasData
? snapshot.data!
: Event(
eventId: event.relationshipEventId!,
content: {
'msgtype': 'm.text',
'body': '...',
},
senderId: event.senderId,
type: 'm.room.message',
room: event.room,
status: EventStatus.sent,
originServerTs: DateTime.now(),
);
return Padding(
padding: const EdgeInsets.only(
bottom: 4.0,
),
child: InkWell(
borderRadius: ReplyContent.borderRadius,
onTap: () => controller.scrollToEventId(
replyEvent.eventId,
),
child: AbsorbPointer(
child: ReplyContent(
replyEvent,
ownMessage: ownMessage,
timeline: timeline,
),
),
),
);
},
),
MessageContent(
event,
textColor: textColor,
pangeaMessageEvent: pangeaMessageEvent,
immersionMode: immersionMode,
overlayController: overlayController,
controller: controller,
nextEvent: nextEvent,
prevEvent: prevEvent,
borderRadius: borderRadius,
),
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,
),
),
],
],
),
),
],
),
),
),
Expand Down

0 comments on commit dd2cccc

Please sign in to comment.