-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added widget test for message_avatar_mixin
- Loading branch information
1 parent
f7a7f81
commit 6cbdae8
Showing
4 changed files
with
364 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:fluffychat/di/global/get_it_initializer.dart'; | ||
import 'package:fluffychat/pages/chat/events/message/message_style.dart'; | ||
import 'package:fluffychat/utils/responsive/responsive_utils.dart'; | ||
import 'package:fluffychat/widgets/avatar/avatar.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
|
||
mixin MessageAvatarMixin { | ||
ResponsiveUtils responsive = getIt.get<ResponsiveUtils>(); | ||
|
||
bool _shouldDisplayAvatar( | ||
bool sameSender, | ||
bool ownMessage, | ||
BuildContext context, | ||
) { | ||
return sameSender && !(ownMessage && responsive.isMobile(context)); | ||
} | ||
|
||
Widget placeHolderWidget( | ||
Function(Event)? onAvatarTap, { | ||
required bool sameSender, | ||
required bool ownMessage, | ||
required Event event, | ||
required BuildContext context, | ||
required bool selectMode, | ||
}) { | ||
if (selectMode || | ||
(event.room.isDirectChat && responsive.isMobile(context))) { | ||
return const SizedBox(); | ||
} | ||
|
||
if (_shouldDisplayAvatar(sameSender, ownMessage, context)) { | ||
return Padding( | ||
padding: MessageStyle.paddingAvatar, | ||
child: FutureBuilder<User?>( | ||
future: event.fetchSenderUser(), | ||
builder: (context, snapshot) { | ||
final user = snapshot.data ?? event.senderFromMemoryOrFallback; | ||
return Avatar( | ||
size: MessageStyle.avatarSize, | ||
fontSize: MessageStyle.fontSize, | ||
mxContent: user.avatarUrl, | ||
name: user.calcDisplayname(), | ||
onTap: () => onAvatarTap!(event), | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
|
||
return const Padding( | ||
padding: MessageStyle.paddingAvatar, | ||
child: SizedBox(width: MessageStyle.avatarSize), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1877,7 +1877,7 @@ packages: | |
description: | ||
path: "." | ||
ref: "twake-supported-0.22.6" | ||
resolved-ref: "04ec6f3b9ece8e64e031cbe5c6e8164dc2ec7f2d" | ||
resolved-ref: "58585a19abc4693d96eab4f8dad9c56bf8699cc1" | ||
url: "[email protected]:linagora/matrix-dart-sdk.git" | ||
source: git | ||
version: "0.22.6" | ||
|
Oops, something went wrong.