diff --git a/lib/pages/chat/chat_app_bar_title.dart b/lib/pages/chat/chat_app_bar_title.dart index 1d8129f6..6ec52eb7 100644 --- a/lib/pages/chat/chat_app_bar_title.dart +++ b/lib/pages/chat/chat_app_bar_title.dart @@ -21,7 +21,10 @@ class ChatAppBarTitle extends StatelessWidget { return Text(controller.selectedEvents.length.toString()); } return ListTile( - leading: Avatar(controller.room.avatar, controller.room.displayname), + leading: Avatar( + mxContent: controller.room.avatar, + name: controller.room.displayname, + ), contentPadding: EdgeInsets.zero, onTap: controller.room.isDirectChat ? () => showModalBottomSheet( diff --git a/lib/pages/chat/chat_input_row.dart b/lib/pages/chat/chat_input_row.dart index d555be31..45af040d 100644 --- a/lib/pages/chat/chat_input_row.dart +++ b/lib/pages/chat/chat_input_row.dart @@ -268,8 +268,9 @@ class _ChatAccountPicker extends StatelessWidget { future: client.ownProfile, builder: (context, snapshot) => ListTile( leading: Avatar( - snapshot.data?.avatarUrl, - snapshot.data?.displayName ?? client.userID.localpart, + mxContent: snapshot.data?.avatarUrl, + name: snapshot.data?.displayName ?? + client.userID.localpart, size: 20, ), title: @@ -280,8 +281,8 @@ class _ChatAccountPicker extends StatelessWidget { )) .toList(), child: Avatar( - snapshot.data?.avatarUrl, - snapshot.data?.displayName ?? + mxContent: snapshot.data?.avatarUrl, + name: snapshot.data?.displayName ?? controller.matrix.client.userID.localpart, size: 20, ), diff --git a/lib/pages/chat/event_info_dialog.dart b/lib/pages/chat/event_info_dialog.dart index 7f8ddded..15f765d5 100644 --- a/lib/pages/chat/event_info_dialog.dart +++ b/lib/pages/chat/event_info_dialog.dart @@ -46,8 +46,10 @@ class EventInfoDialog extends StatelessWidget { body: ListView( children: [ ListTile( - leading: - Avatar(event.sender.avatarUrl, event.sender.calcDisplayname()), + leading: Avatar( + mxContent: event.sender.avatarUrl, + name: event.sender.calcDisplayname(), + ), title: Text(L10n.of(context).sender), subtitle: Text('${event.sender.calcDisplayname()} <${event.senderId}>'), diff --git a/lib/pages/chat/events/message.dart b/lib/pages/chat/events/message.dart index 52373f31..6579ad13 100644 --- a/lib/pages/chat/events/message.dart +++ b/lib/pages/chat/events/message.dart @@ -121,8 +121,8 @@ class Message extends StatelessWidget { : null, ) : Avatar( - event.sender.avatarUrl, - event.sender.calcDisplayname(), + mxContent: event.sender.avatarUrl, + name: event.sender.calcDisplayname(), onTap: () => onAvatarTab(event), ), Expanded( diff --git a/lib/pages/chat/events/message_reactions.dart b/lib/pages/chat/events/message_reactions.dart index a735d7bf..a61a4572 100644 --- a/lib/pages/chat/events/message_reactions.dart +++ b/lib/pages/chat/events/message_reactions.dart @@ -213,8 +213,8 @@ class _AdaptableReactorsDialog extends StatelessWidget { for (var reactor in reactionEntry.reactors) Chip( avatar: Avatar( - reactor.avatarUrl, - reactor.displayName, + mxContent: reactor.avatarUrl, + name: reactor.displayName, client: client, ), label: Text(reactor.displayName), diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 42a0ebd6..7cc0abd0 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -259,8 +259,10 @@ class InputBar extends StatelessWidget { opacity: suggestion['pack_avatar_url'] != null ? 0.8 : 0.5, child: suggestion['pack_avatar_url'] != null ? Avatar( - Uri.parse(suggestion['pack_avatar_url']), - suggestion['pack_display_name'], + mxContent: Uri.tryParse( + suggestion.tryGet('pack_avatar_url') ?? + ''), + name: suggestion.tryGet('pack_display_name'), size: size * 0.9, client: client, ) @@ -280,8 +282,9 @@ class InputBar extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ Avatar( - url, - suggestion['displayname'] ?? suggestion['mxid'], + mxContent: url, + name: suggestion.tryGet('displayname') ?? + suggestion.tryGet('mxid'), size: size, client: client, ), diff --git a/lib/pages/chat/seen_by_row.dart b/lib/pages/chat/seen_by_row.dart index 5b539378..50c2650b 100644 --- a/lib/pages/chat/seen_by_row.dart +++ b/lib/pages/chat/seen_by_row.dart @@ -42,8 +42,8 @@ class SeenByRow extends StatelessWidget { : seenByUsers) .map( (user) => Avatar( - user.avatarUrl, - user.calcDisplayname(), + mxContent: user.avatarUrl, + name: user.calcDisplayname(), size: 16, fontSize: 9, ), diff --git a/lib/pages/chat/sticker_picker_dialog.dart b/lib/pages/chat/sticker_picker_dialog.dart index f12dd644..d3c5e657 100644 --- a/lib/pages/chat/sticker_picker_dialog.dart +++ b/lib/pages/chat/sticker_picker_dialog.dart @@ -49,8 +49,8 @@ class StickerPickerDialogState extends State { if (packName != 'user') ListTile( leading: Avatar( - pack.pack.avatarUrl, - packName, + mxContent: pack.pack.avatarUrl, + name: packName, client: widget.room.client, ), title: Text(packName), diff --git a/lib/pages/chat/typing_indicators.dart b/lib/pages/chat/typing_indicators.dart index ef9dc87c..1ab3f335 100644 --- a/lib/pages/chat/typing_indicators.dart +++ b/lib/pages/chat/typing_indicators.dart @@ -48,17 +48,17 @@ class TypingIndicators extends StatelessWidget { children: [ if (typingUsers.isNotEmpty) Avatar( - typingUsers.first.avatarUrl, - typingUsers.first.calcDisplayname(), + mxContent: typingUsers.first.avatarUrl, + name: typingUsers.first.calcDisplayname(), ), if (typingUsers.length == 2) Padding( padding: const EdgeInsets.only(left: 8), child: Avatar( - typingUsers.length == 2 + mxContent: typingUsers.length == 2 ? typingUsers.last.avatarUrl : null, - typingUsers.length == 2 + name: typingUsers.length == 2 ? typingUsers.last.calcDisplayname() : '+${typingUsers.length - 1}', ), diff --git a/lib/pages/chat_details/participant_list_item.dart b/lib/pages/chat_details/participant_list_item.dart index de911604..4496a908 100644 --- a/lib/pages/chat_details/participant_list_item.dart +++ b/lib/pages/chat_details/participant_list_item.dart @@ -61,7 +61,7 @@ class ParticipantListItem extends StatelessWidget { ], ), subtitle: Text(user.id), - leading: Avatar(user.avatarUrl, user.calcDisplayname()), + leading: Avatar(mxContent: user.avatarUrl, name: user.calcDisplayname()), ); } } diff --git a/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart b/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart index 2caff933..0dce464b 100644 --- a/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart +++ b/lib/pages/chat_encryption_settings/chat_encryption_settings_view.dart @@ -91,10 +91,10 @@ class ChatEncryptionSettingsView extends StatelessWidget { }, child: ListTile( leading: Avatar( - room + mxContent: room .getUserByMXIDSync(deviceKeys[i].userId) .avatarUrl, - room + name: room .getUserByMXIDSync(deviceKeys[i].userId) .calcDisplayname(), ), diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 793507de..2a02c095 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -171,7 +171,11 @@ class ChatListItem extends StatelessWidget { child: const Icon(Icons.check, color: Colors.white), ), ) - : Avatar(room.avatar, room.displayname, onTap: onLongPress), + : Avatar( + mxContent: room.avatar, + name: room.displayname, + onTap: onLongPress, + ), title: Row( children: [ Expanded( diff --git a/lib/pages/chat_list/client_chooser_button.dart b/lib/pages/chat_list/client_chooser_button.dart index 190989ce..73717741 100644 --- a/lib/pages/chat_list/client_chooser_button.dart +++ b/lib/pages/chat_list/client_chooser_button.dart @@ -48,8 +48,9 @@ class ClientChooserButton extends StatelessWidget { builder: (context, snapshot) => Row( children: [ Avatar( - snapshot.data?.avatarUrl, - snapshot.data?.displayName ?? client.userID.localpart, + mxContent: snapshot.data?.avatarUrl, + name: snapshot.data?.displayName ?? + client.userID.localpart, size: 28, fontSize: 12, ), @@ -84,8 +85,8 @@ class ClientChooserButton extends StatelessWidget { future: matrix.client.ownProfile, builder: (context, snapshot) => PopupMenuButton( child: Avatar( - snapshot.data?.avatarUrl, - snapshot.data?.displayName ?? matrix.client.userID.localpart, + mxContent: snapshot.data?.avatarUrl, + name: snapshot.data?.displayName ?? matrix.client.userID.localpart, size: 28, fontSize: 12, ), diff --git a/lib/pages/chat_list/spaces_bottom_bar.dart b/lib/pages/chat_list/spaces_bottom_bar.dart index e3c9b641..9cef8027 100644 --- a/lib/pages/chat_list/spaces_bottom_bar.dart +++ b/lib/pages/chat_list/spaces_bottom_bar.dart @@ -59,8 +59,8 @@ class SpacesBottomBar extends StatelessWidget { onLongPress: () => controller.editSpace(context, space.id), child: Avatar( - space.avatar, - space.displayname, + mxContent: space.avatar, + name: space.displayname, size: 24, fontSize: 12, ), diff --git a/lib/pages/invitation_selection/invitation_selection_view.dart b/lib/pages/invitation_selection/invitation_selection_view.dart index 02cff19d..41a05735 100644 --- a/lib/pages/invitation_selection/invitation_selection_view.dart +++ b/lib/pages/invitation_selection/invitation_selection_view.dart @@ -45,8 +45,8 @@ class InvitationSelectionView extends StatelessWidget { itemCount: controller.foundProfiles.length, itemBuilder: (BuildContext context, int i) => ListTile( leading: Avatar( - controller.foundProfiles[i].avatarUrl, - controller.foundProfiles[i].displayName ?? + mxContent: controller.foundProfiles[i].avatarUrl, + name: controller.foundProfiles[i].displayName ?? controller.foundProfiles[i].userId, ), title: Text( @@ -73,8 +73,8 @@ class InvitationSelectionView extends StatelessWidget { itemCount: contacts.length, itemBuilder: (BuildContext context, int i) => ListTile( leading: Avatar( - contacts[i].avatarUrl, - contacts[i].calcDisplayname(), + mxContent: contacts[i].avatarUrl, + name: contacts[i].calcDisplayname(), ), title: Text(contacts[i].calcDisplayname()), subtitle: Text(contacts[i].id), diff --git a/lib/pages/key_verification/key_verification_dialog.dart b/lib/pages/key_verification/key_verification_dialog.dart index 0a458a15..3f9c8095 100644 --- a/lib/pages/key_verification/key_verification_dialog.dart +++ b/lib/pages/key_verification/key_verification_dialog.dart @@ -171,7 +171,7 @@ class _KeyVerificationPageState extends State { children: [ Row(children: [ if (!PlatformInfos.isCupertinoStyle) - Avatar(user?.avatarUrl, displayName), + Avatar(mxContent: user?.avatarUrl, name: displayName), const SizedBox(width: 12), Expanded( child: Column( diff --git a/lib/pages/search/search_view.dart b/lib/pages/search/search_view.dart index 1a0dff6f..317b93ac 100644 --- a/lib/pages/search/search_view.dart +++ b/lib/pages/search/search_view.dart @@ -195,8 +195,11 @@ class SearchView extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - Avatar(publicRoomsResponse.chunk[i].avatarUrl, - publicRoomsResponse.chunk[i].name), + Avatar( + mxContent: + publicRoomsResponse.chunk[i].avatarUrl, + name: publicRoomsResponse.chunk[i].name, + ), Text( publicRoomsResponse.chunk[i].name, style: const TextStyle( @@ -262,8 +265,8 @@ class SearchView extends StatelessWidget { } }, leading: Avatar( - foundProfile.avatarUrl, - foundProfile.displayName ?? foundProfile.userId, + mxContent: foundProfile.avatarUrl, + name: foundProfile.displayName ?? foundProfile.userId, //size: 24, ), title: Text( diff --git a/lib/pages/settings_ignore_list/settings_ignore_list_view.dart b/lib/pages/settings_ignore_list/settings_ignore_list_view.dart index 86ff8291..07c0692b 100644 --- a/lib/pages/settings_ignore_list/settings_ignore_list_view.dart +++ b/lib/pages/settings_ignore_list/settings_ignore_list_view.dart @@ -68,8 +68,8 @@ class SettingsIgnoreListView extends StatelessWidget { client.getProfileFromUserId(client.ignoredUsers[i]), builder: (c, s) => ListTile( leading: Avatar( - s.data?.avatarUrl ?? Uri.parse(''), - s.data?.displayName ?? client.ignoredUsers[i], + mxContent: s.data?.avatarUrl ?? Uri.parse(''), + name: s.data?.displayName ?? client.ignoredUsers[i], ), title: Text( s.data?.displayName ?? client.ignoredUsers[i]), diff --git a/lib/widgets/avatar.dart b/lib/widgets/avatar.dart index 8d33c286..7d4b0c97 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -18,9 +18,9 @@ class Avatar extends StatelessWidget { final Client? client; final double fontSize; - const Avatar( + const Avatar({ this.mxContent, - this.name, { + this.name, this.size = defaultSize, this.onTap, this.client, diff --git a/lib/widgets/contacts_list.dart b/lib/widgets/contacts_list.dart index b7a4f942..00df9e9d 100644 --- a/lib/widgets/contacts_list.dart +++ b/lib/widgets/contacts_list.dart @@ -87,7 +87,12 @@ class _ContactListTile extends StatelessWidget { height: Avatar.defaultSize, child: Stack( children: [ - Center(child: Avatar(avatarUrl, displayname)), + Center( + child: Avatar( + mxContent: avatarUrl, + name: displayname, + ), + ), Align( alignment: Alignment.bottomRight, child: Icon(