mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
refactor: Avatar widget
This commit is contained in:
parent
dace2311ce
commit
2da94897e5
@ -21,7 +21,10 @@ class ChatAppBarTitle extends StatelessWidget {
|
|||||||
return Text(controller.selectedEvents.length.toString());
|
return Text(controller.selectedEvents.length.toString());
|
||||||
}
|
}
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Avatar(controller.room.avatar, controller.room.displayname),
|
leading: Avatar(
|
||||||
|
mxContent: controller.room.avatar,
|
||||||
|
name: controller.room.displayname,
|
||||||
|
),
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
onTap: controller.room.isDirectChat
|
onTap: controller.room.isDirectChat
|
||||||
? () => showModalBottomSheet(
|
? () => showModalBottomSheet(
|
||||||
|
@ -268,8 +268,9 @@ class _ChatAccountPicker extends StatelessWidget {
|
|||||||
future: client.ownProfile,
|
future: client.ownProfile,
|
||||||
builder: (context, snapshot) => ListTile(
|
builder: (context, snapshot) => ListTile(
|
||||||
leading: Avatar(
|
leading: Avatar(
|
||||||
snapshot.data?.avatarUrl,
|
mxContent: snapshot.data?.avatarUrl,
|
||||||
snapshot.data?.displayName ?? client.userID.localpart,
|
name: snapshot.data?.displayName ??
|
||||||
|
client.userID.localpart,
|
||||||
size: 20,
|
size: 20,
|
||||||
),
|
),
|
||||||
title:
|
title:
|
||||||
@ -280,8 +281,8 @@ class _ChatAccountPicker extends StatelessWidget {
|
|||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
child: Avatar(
|
child: Avatar(
|
||||||
snapshot.data?.avatarUrl,
|
mxContent: snapshot.data?.avatarUrl,
|
||||||
snapshot.data?.displayName ??
|
name: snapshot.data?.displayName ??
|
||||||
controller.matrix.client.userID.localpart,
|
controller.matrix.client.userID.localpart,
|
||||||
size: 20,
|
size: 20,
|
||||||
),
|
),
|
||||||
|
@ -46,8 +46,10 @@ class EventInfoDialog extends StatelessWidget {
|
|||||||
body: ListView(
|
body: ListView(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
leading:
|
leading: Avatar(
|
||||||
Avatar(event.sender.avatarUrl, event.sender.calcDisplayname()),
|
mxContent: event.sender.avatarUrl,
|
||||||
|
name: event.sender.calcDisplayname(),
|
||||||
|
),
|
||||||
title: Text(L10n.of(context).sender),
|
title: Text(L10n.of(context).sender),
|
||||||
subtitle:
|
subtitle:
|
||||||
Text('${event.sender.calcDisplayname()} <${event.senderId}>'),
|
Text('${event.sender.calcDisplayname()} <${event.senderId}>'),
|
||||||
|
@ -121,8 +121,8 @@ class Message extends StatelessWidget {
|
|||||||
: null,
|
: null,
|
||||||
)
|
)
|
||||||
: Avatar(
|
: Avatar(
|
||||||
event.sender.avatarUrl,
|
mxContent: event.sender.avatarUrl,
|
||||||
event.sender.calcDisplayname(),
|
name: event.sender.calcDisplayname(),
|
||||||
onTap: () => onAvatarTab(event),
|
onTap: () => onAvatarTab(event),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -213,8 +213,8 @@ class _AdaptableReactorsDialog extends StatelessWidget {
|
|||||||
for (var reactor in reactionEntry.reactors)
|
for (var reactor in reactionEntry.reactors)
|
||||||
Chip(
|
Chip(
|
||||||
avatar: Avatar(
|
avatar: Avatar(
|
||||||
reactor.avatarUrl,
|
mxContent: reactor.avatarUrl,
|
||||||
reactor.displayName,
|
name: reactor.displayName,
|
||||||
client: client,
|
client: client,
|
||||||
),
|
),
|
||||||
label: Text(reactor.displayName),
|
label: Text(reactor.displayName),
|
||||||
|
@ -259,8 +259,10 @@ class InputBar extends StatelessWidget {
|
|||||||
opacity: suggestion['pack_avatar_url'] != null ? 0.8 : 0.5,
|
opacity: suggestion['pack_avatar_url'] != null ? 0.8 : 0.5,
|
||||||
child: suggestion['pack_avatar_url'] != null
|
child: suggestion['pack_avatar_url'] != null
|
||||||
? Avatar(
|
? Avatar(
|
||||||
Uri.parse(suggestion['pack_avatar_url']),
|
mxContent: Uri.tryParse(
|
||||||
suggestion['pack_display_name'],
|
suggestion.tryGet<String>('pack_avatar_url') ??
|
||||||
|
''),
|
||||||
|
name: suggestion.tryGet<String>('pack_display_name'),
|
||||||
size: size * 0.9,
|
size: size * 0.9,
|
||||||
client: client,
|
client: client,
|
||||||
)
|
)
|
||||||
@ -280,8 +282,9 @@ class InputBar extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Avatar(
|
Avatar(
|
||||||
url,
|
mxContent: url,
|
||||||
suggestion['displayname'] ?? suggestion['mxid'],
|
name: suggestion.tryGet<String>('displayname') ??
|
||||||
|
suggestion.tryGet<String>('mxid'),
|
||||||
size: size,
|
size: size,
|
||||||
client: client,
|
client: client,
|
||||||
),
|
),
|
||||||
|
@ -42,8 +42,8 @@ class SeenByRow extends StatelessWidget {
|
|||||||
: seenByUsers)
|
: seenByUsers)
|
||||||
.map(
|
.map(
|
||||||
(user) => Avatar(
|
(user) => Avatar(
|
||||||
user.avatarUrl,
|
mxContent: user.avatarUrl,
|
||||||
user.calcDisplayname(),
|
name: user.calcDisplayname(),
|
||||||
size: 16,
|
size: 16,
|
||||||
fontSize: 9,
|
fontSize: 9,
|
||||||
),
|
),
|
||||||
|
@ -49,8 +49,8 @@ class StickerPickerDialogState extends State<StickerPickerDialog> {
|
|||||||
if (packName != 'user')
|
if (packName != 'user')
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Avatar(
|
leading: Avatar(
|
||||||
pack.pack.avatarUrl,
|
mxContent: pack.pack.avatarUrl,
|
||||||
packName,
|
name: packName,
|
||||||
client: widget.room.client,
|
client: widget.room.client,
|
||||||
),
|
),
|
||||||
title: Text(packName),
|
title: Text(packName),
|
||||||
|
@ -48,17 +48,17 @@ class TypingIndicators extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
if (typingUsers.isNotEmpty)
|
if (typingUsers.isNotEmpty)
|
||||||
Avatar(
|
Avatar(
|
||||||
typingUsers.first.avatarUrl,
|
mxContent: typingUsers.first.avatarUrl,
|
||||||
typingUsers.first.calcDisplayname(),
|
name: typingUsers.first.calcDisplayname(),
|
||||||
),
|
),
|
||||||
if (typingUsers.length == 2)
|
if (typingUsers.length == 2)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 8),
|
padding: const EdgeInsets.only(left: 8),
|
||||||
child: Avatar(
|
child: Avatar(
|
||||||
typingUsers.length == 2
|
mxContent: typingUsers.length == 2
|
||||||
? typingUsers.last.avatarUrl
|
? typingUsers.last.avatarUrl
|
||||||
: null,
|
: null,
|
||||||
typingUsers.length == 2
|
name: typingUsers.length == 2
|
||||||
? typingUsers.last.calcDisplayname()
|
? typingUsers.last.calcDisplayname()
|
||||||
: '+${typingUsers.length - 1}',
|
: '+${typingUsers.length - 1}',
|
||||||
),
|
),
|
||||||
|
@ -61,7 +61,7 @@ class ParticipantListItem extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
subtitle: Text(user.id),
|
subtitle: Text(user.id),
|
||||||
leading: Avatar(user.avatarUrl, user.calcDisplayname()),
|
leading: Avatar(mxContent: user.avatarUrl, name: user.calcDisplayname()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,10 +91,10 @@ class ChatEncryptionSettingsView extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: Avatar(
|
leading: Avatar(
|
||||||
room
|
mxContent: room
|
||||||
.getUserByMXIDSync(deviceKeys[i].userId)
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
||||||
.avatarUrl,
|
.avatarUrl,
|
||||||
room
|
name: room
|
||||||
.getUserByMXIDSync(deviceKeys[i].userId)
|
.getUserByMXIDSync(deviceKeys[i].userId)
|
||||||
.calcDisplayname(),
|
.calcDisplayname(),
|
||||||
),
|
),
|
||||||
|
@ -171,7 +171,11 @@ class ChatListItem extends StatelessWidget {
|
|||||||
child: const Icon(Icons.check, color: Colors.white),
|
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(
|
title: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -48,8 +48,9 @@ class ClientChooserButton extends StatelessWidget {
|
|||||||
builder: (context, snapshot) => Row(
|
builder: (context, snapshot) => Row(
|
||||||
children: [
|
children: [
|
||||||
Avatar(
|
Avatar(
|
||||||
snapshot.data?.avatarUrl,
|
mxContent: snapshot.data?.avatarUrl,
|
||||||
snapshot.data?.displayName ?? client.userID.localpart,
|
name: snapshot.data?.displayName ??
|
||||||
|
client.userID.localpart,
|
||||||
size: 28,
|
size: 28,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
@ -84,8 +85,8 @@ class ClientChooserButton extends StatelessWidget {
|
|||||||
future: matrix.client.ownProfile,
|
future: matrix.client.ownProfile,
|
||||||
builder: (context, snapshot) => PopupMenuButton<Object>(
|
builder: (context, snapshot) => PopupMenuButton<Object>(
|
||||||
child: Avatar(
|
child: Avatar(
|
||||||
snapshot.data?.avatarUrl,
|
mxContent: snapshot.data?.avatarUrl,
|
||||||
snapshot.data?.displayName ?? matrix.client.userID.localpart,
|
name: snapshot.data?.displayName ?? matrix.client.userID.localpart,
|
||||||
size: 28,
|
size: 28,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
|
@ -59,8 +59,8 @@ class SpacesBottomBar extends StatelessWidget {
|
|||||||
onLongPress: () =>
|
onLongPress: () =>
|
||||||
controller.editSpace(context, space.id),
|
controller.editSpace(context, space.id),
|
||||||
child: Avatar(
|
child: Avatar(
|
||||||
space.avatar,
|
mxContent: space.avatar,
|
||||||
space.displayname,
|
name: space.displayname,
|
||||||
size: 24,
|
size: 24,
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
|
@ -45,8 +45,8 @@ class InvitationSelectionView extends StatelessWidget {
|
|||||||
itemCount: controller.foundProfiles.length,
|
itemCount: controller.foundProfiles.length,
|
||||||
itemBuilder: (BuildContext context, int i) => ListTile(
|
itemBuilder: (BuildContext context, int i) => ListTile(
|
||||||
leading: Avatar(
|
leading: Avatar(
|
||||||
controller.foundProfiles[i].avatarUrl,
|
mxContent: controller.foundProfiles[i].avatarUrl,
|
||||||
controller.foundProfiles[i].displayName ??
|
name: controller.foundProfiles[i].displayName ??
|
||||||
controller.foundProfiles[i].userId,
|
controller.foundProfiles[i].userId,
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
@ -73,8 +73,8 @@ class InvitationSelectionView extends StatelessWidget {
|
|||||||
itemCount: contacts.length,
|
itemCount: contacts.length,
|
||||||
itemBuilder: (BuildContext context, int i) => ListTile(
|
itemBuilder: (BuildContext context, int i) => ListTile(
|
||||||
leading: Avatar(
|
leading: Avatar(
|
||||||
contacts[i].avatarUrl,
|
mxContent: contacts[i].avatarUrl,
|
||||||
contacts[i].calcDisplayname(),
|
name: contacts[i].calcDisplayname(),
|
||||||
),
|
),
|
||||||
title: Text(contacts[i].calcDisplayname()),
|
title: Text(contacts[i].calcDisplayname()),
|
||||||
subtitle: Text(contacts[i].id),
|
subtitle: Text(contacts[i].id),
|
||||||
|
@ -171,7 +171,7 @@ class _KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||||||
children: [
|
children: [
|
||||||
Row(children: [
|
Row(children: [
|
||||||
if (!PlatformInfos.isCupertinoStyle)
|
if (!PlatformInfos.isCupertinoStyle)
|
||||||
Avatar(user?.avatarUrl, displayName),
|
Avatar(mxContent: user?.avatarUrl, name: displayName),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -195,8 +195,11 @@ class SearchView extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Avatar(publicRoomsResponse.chunk[i].avatarUrl,
|
Avatar(
|
||||||
publicRoomsResponse.chunk[i].name),
|
mxContent:
|
||||||
|
publicRoomsResponse.chunk[i].avatarUrl,
|
||||||
|
name: publicRoomsResponse.chunk[i].name,
|
||||||
|
),
|
||||||
Text(
|
Text(
|
||||||
publicRoomsResponse.chunk[i].name,
|
publicRoomsResponse.chunk[i].name,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@ -262,8 +265,8 @@ class SearchView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
leading: Avatar(
|
leading: Avatar(
|
||||||
foundProfile.avatarUrl,
|
mxContent: foundProfile.avatarUrl,
|
||||||
foundProfile.displayName ?? foundProfile.userId,
|
name: foundProfile.displayName ?? foundProfile.userId,
|
||||||
//size: 24,
|
//size: 24,
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
|
@ -68,8 +68,8 @@ class SettingsIgnoreListView extends StatelessWidget {
|
|||||||
client.getProfileFromUserId(client.ignoredUsers[i]),
|
client.getProfileFromUserId(client.ignoredUsers[i]),
|
||||||
builder: (c, s) => ListTile(
|
builder: (c, s) => ListTile(
|
||||||
leading: Avatar(
|
leading: Avatar(
|
||||||
s.data?.avatarUrl ?? Uri.parse(''),
|
mxContent: s.data?.avatarUrl ?? Uri.parse(''),
|
||||||
s.data?.displayName ?? client.ignoredUsers[i],
|
name: s.data?.displayName ?? client.ignoredUsers[i],
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
s.data?.displayName ?? client.ignoredUsers[i]),
|
s.data?.displayName ?? client.ignoredUsers[i]),
|
||||||
|
@ -18,9 +18,9 @@ class Avatar extends StatelessWidget {
|
|||||||
final Client? client;
|
final Client? client;
|
||||||
final double fontSize;
|
final double fontSize;
|
||||||
|
|
||||||
const Avatar(
|
const Avatar({
|
||||||
this.mxContent,
|
this.mxContent,
|
||||||
this.name, {
|
this.name,
|
||||||
this.size = defaultSize,
|
this.size = defaultSize,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
this.client,
|
this.client,
|
||||||
|
@ -87,7 +87,12 @@ class _ContactListTile extends StatelessWidget {
|
|||||||
height: Avatar.defaultSize,
|
height: Avatar.defaultSize,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Center(child: Avatar(avatarUrl, displayname)),
|
Center(
|
||||||
|
child: Avatar(
|
||||||
|
mxContent: avatarUrl,
|
||||||
|
name: displayname,
|
||||||
|
),
|
||||||
|
),
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.bottomRight,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
|
Loading…
Reference in New Issue
Block a user