Skip to content

Commit

Permalink
fixup! TW-2169 added avatar and name for sender messages in web
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledNjim committed Dec 9, 2024
1 parent ddd99b4 commit a99bec9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/pages/chat/events/message/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,19 @@ class _MessageState extends State<Message> {
);
}

bool shouldDisplayAvatar(bool sameSender, bool ownMessage) {
return sameSender &&
(!ownMessage || !Message.responsiveUtils.isMobile(context));
}

Widget _placeHolderWidget(bool sameSender, bool ownMessage, Event event) {
if (widget.selectMode || event.room.isDirectChat) {
if (widget.selectMode ||
(event.room.isDirectChat &&
Message.responsiveUtils.isMobile(context))) {
return const SizedBox();
}

if (sameSender &&
(!ownMessage || !Message.responsiveUtils.isMobile(context))) {
if (shouldDisplayAvatar(sameSender, ownMessage)) {
return Padding(
padding: MessageStyle.paddingAvatar,
child: FutureBuilder<User?>(
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/chat/events/message/message_content_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:fluffychat/pages/chat/events/message/reply_content_widget.dart';
import 'package:fluffychat/pages/chat/events/message_content.dart';
import 'package:matrix/matrix.dart' hide Visibility;
import 'message.dart';

class MessageContentBuilder extends StatelessWidget
with MessageContentBuilderMixin {
Expand Down Expand Up @@ -46,6 +47,7 @@ class MessageContentBuilder extends StatelessWidget
ownMessage: event.isOwnMessage,
hideDisplayName: event.hideDisplayName(
nextEvent,
Message.responsiveUtils.isMobile(context),
),
);
final stepWidth = sizeMessageBubble?.totalMessageWidth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ class MessageContentWithTimestampBuilder extends StatelessWidget {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
event.hideDisplayName(nextEvent)
event.hideDisplayName(
nextEvent,
responsiveUtils.isMobile(context),
)
? const SizedBox()
: DisplayNameWidget(
event: event,
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/matrix_sdk_extensions/event_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ extension LocalizedBody on Event {
MessageTypes.File,
}.contains(messageType);

bool hideDisplayName(Event? nextEvent) =>
bool hideDisplayName(Event? nextEvent, bool isMobile) =>
(isMobile && isOwnMessage) ||
room.isDirectChat ||
!isSameSenderWith(nextEvent) ||
type == EventTypes.Encrypted;
Expand Down

0 comments on commit a99bec9

Please sign in to comment.